View Javadoc
1   /*
2    * Copyright (C) 2010, 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.file;
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 ObjectDirectory}. */
18  class LocalObjectToPack extends ObjectToPack {
19  	/** Pack to reuse compressed data from, otherwise null. */
20  	PackFile pack;
21  
22  	/** Offset of the object's header in {@link #pack}. */
23  	long offset;
24  
25  	/** Length of the data section of the object. */
26  	long length;
27  
28  	LocalObjectToPack(AnyObjectId src, int type) {
29  		super(src, type);
30  	}
31  
32  	/** {@inheritDoc} */
33  	@Override
34  	protected void clearReuseAsIs() {
35  		super.clearReuseAsIs();
36  		pack = null;
37  	}
38  
39  	/** {@inheritDoc} */
40  	@Override
41  	public void select(StoredObjectRepresentation ref) {
42  		LocalObjectRepresentation ptr = (LocalObjectRepresentation) ref;
43  		this.pack = ptr.pack;
44  		this.offset = ptr.offset;
45  		this.length = ptr.length;
46  	}
47  }