View Javadoc
1   /*
2    * Copyright (C) 2011, Google Inc. and others
3    *
4    * This program and the accompanying materials are made available under the
5    * terms of the Eclipse Distribution License v. 1.0 which is available at
6    * https://www.eclipse.org/org/documents/edl-v10.php.
7    *
8    * SPDX-License-Identifier: BSD-3-Clause
9    */
10  
11  package org.eclipse.jgit.internal.storage.dfs;
12  
13  import org.eclipse.jgit.internal.storage.pack.ObjectToPack;
14  import org.eclipse.jgit.internal.storage.pack.StoredObjectRepresentation;
15  import org.eclipse.jgit.lib.AnyObjectId;
16  
17  /** {@link ObjectToPack} for {@link DfsObjDatabase}. */
18  class DfsObjectToPack extends ObjectToPack {
19  	private static final int FLAG_FOUND = 1 << 0;
20  
21  	/** Pack to reuse compressed data from, otherwise null. */
22  	DfsPackFile pack;
23  
24  	/** Offset of the object's header in {@link #pack}. */
25  	long offset;
26  
27  	/** Length of the data section of the object. */
28  	long length;
29  
30  	DfsObjectToPack(AnyObjectId src, int type) {
31  		super(src, type);
32  	}
33  
34  	final boolean isFound() {
35  		return isExtendedFlag(FLAG_FOUND);
36  	}
37  
38  	final void setFound() {
39  		setExtendedFlag(FLAG_FOUND);
40  	}
41  
42  	/** {@inheritDoc} */
43  	@Override
44  	protected void clearReuseAsIs() {
45  		super.clearReuseAsIs();
46  		pack = null;
47  	}
48  
49  	/** {@inheritDoc} */
50  	@Override
51  	public void select(StoredObjectRepresentation ref) {
52  		DfsObjectRepresentation ptr = (DfsObjectRepresentation) ref;
53  		this.pack = ptr.pack;
54  		this.offset = ptr.offset;
55  		this.length = ptr.length;
56  	}
57  }