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.StoredObjectRepresentation;
14  import org.eclipse.jgit.lib.ObjectId;
15  
16  class DfsObjectRepresentation extends StoredObjectRepresentation {
17  	final DfsPackFile pack;
18  	int format;
19  	long offset;
20  	long length;
21  	ObjectId baseId;
22  
23  	DfsObjectRepresentation(DfsPackFile pack) {
24  		this.pack = pack;
25  	}
26  
27  	/** {@inheritDoc} */
28  	@Override
29  	public int getFormat() {
30  		return format;
31  	}
32  
33  	/** {@inheritDoc} */
34  	@Override
35  	public int getWeight() {
36  		return (int) Math.min(length, Integer.MAX_VALUE);
37  	}
38  
39  	/** {@inheritDoc} */
40  	@Override
41  	public ObjectId getDeltaBase() {
42  		return baseId;
43  	}
44  
45  	/** {@inheritDoc} */
46  	@Override
47  	public boolean wasDeltaAttempted() {
48  		switch (pack.getPackDescription().getPackSource()) {
49  		case GC:
50  		case GC_REST:
51  		case GC_TXN:
52  			return true;
53  		default:
54  			return false;
55  		}
56  	}
57  }