Class LargePackedWholeObject
- java.lang.Object
-
- org.eclipse.jgit.lib.ObjectLoader
-
- org.eclipse.jgit.internal.storage.file.LargePackedWholeObject
-
class LargePackedWholeObject extends ObjectLoader
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.jgit.lib.ObjectLoader
ObjectLoader.Filter, ObjectLoader.SmallObject
-
-
Field Summary
Fields Modifier and Type Field Description private FileObjectDatabasedbprivate intheaderLengthprivate longobjectOffsetprivate Packpackprivate longsizeprivate inttype
-
Constructor Summary
Constructors Constructor Description LargePackedWholeObject(int type, long size, long objectOffset, int headerLength, Pack pack, FileObjectDatabase db)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]getCachedBytes()Obtain a reference to the (possibly cached) bytes of this object.private ObjectIdgetObjectId()longgetSize()Get size of object in bytesintgetType()Get Git in pack object typebooleanisLarge()Whether this object is too large to obtain as a byte array.ObjectStreamopenStream()Obtain an input stream to read this object's data.-
Methods inherited from class org.eclipse.jgit.lib.ObjectLoader
copyTo, getBytes, getBytes, getCachedBytes
-
-
-
-
Field Detail
-
type
private final int type
-
size
private final long size
-
objectOffset
private final long objectOffset
-
headerLength
private final int headerLength
-
pack
private final Pack pack
-
db
private final FileObjectDatabase db
-
-
Constructor Detail
-
LargePackedWholeObject
LargePackedWholeObject(int type, long size, long objectOffset, int headerLength, Pack pack, FileObjectDatabase db)
-
-
Method Detail
-
getType
public int getType()
Get Git in pack object type- Specified by:
getTypein classObjectLoader- Returns:
- Git in pack object type, see
Constants.
-
getSize
public long getSize()
Get size of object in bytes- Specified by:
getSizein classObjectLoader- Returns:
- size of object in bytes
-
isLarge
public boolean isLarge()
Whether this object is too large to obtain as a byte array.- Overrides:
isLargein classObjectLoader- Returns:
- true if this object is too large to obtain as a byte array.
Objects over a certain threshold should be accessed only by their
ObjectLoader.openStream()to prevent overflowing the JVM heap.
-
getCachedBytes
public byte[] getCachedBytes() throws LargeObjectExceptionObtain a reference to the (possibly cached) bytes of this object.This method offers direct access to the internal caches, potentially saving on data copies between the internal cache and higher level code. Callers who receive this reference must not modify its contents. Changes (if made) will affect the cache but not the repository itself.
- Specified by:
getCachedBytesin classObjectLoader- Returns:
- the cached bytes of this object. Do not modify it.
- Throws:
LargeObjectException- if the object won't fit into a byte array, becauseObjectLoader.isLarge()returns true. Callers should useObjectLoader.openStream()instead to access the contents.
-
openStream
public ObjectStream openStream() throws MissingObjectException, java.io.IOException
Obtain an input stream to read this object's data.- Specified by:
openStreamin classObjectLoader- Returns:
- a stream of this object's data. Caller must close the stream when through with it. The returned stream is buffered with a reasonable buffer size.
- Throws:
MissingObjectException- the object no longer exists.java.io.IOException- the object store cannot be accessed.
-
getObjectId
private ObjectId getObjectId() throws java.io.IOException
- Throws:
java.io.IOException
-
-