Top Description Inners Constructors Methods
org.eclipse.jgit.lib

public abstract Class ObjectLoader

extends Object
Class Inheritance
Known Direct Subclasses
org.eclipse.jgit.lib.ObjectLoader.SmallObject, org.eclipse.jgit.lib.ObjectLoader.Filter, org.eclipse.jgit.internal.storage.dfs.DfsInserter.StreamLoader, org.eclipse.jgit.internal.storage.dfs.LargePackedWholeObject, org.eclipse.jgit.internal.storage.file.LargePackedWholeObject, org.eclipse.jgit.internal.storage.file.UnpackedObject.LargeObject, org.eclipse.jgit.internal.storage.file.PackInserter.Reader.StreamLoader
Imports
java.io.EOFException, .IOException, .OutputStream, org.eclipse.jgit.errors.LargeObjectException, .MissingObjectException, org.eclipse.jgit.util.IO

Base class for a set of loaders for different representations of Git objects. New loaders are constructed for every object.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
ObjectLoader.Filter

Wraps a delegate ObjectLoader.

public static class
ObjectLoader.SmallObject

Simple loader around the cached byte array.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static byte[]
cloneArray(byte[] data)

public void
copyTo(OutputStream
stream to receive the complete copy of this object's data. Caller is responsible for flushing or closing this stream after this method returns.
out
)

Copy this object to the output stream.

public final byte[]

Returns:

the bytes of this object.
getBytes
()

Obtain a copy of the bytes of this object.

public final byte[]

Returns:

the bytes of this object.
getBytes
(int
maximum number of bytes to return. If the object is larger than this limit, org.eclipse.jgit.errors.LargeObjectException will be thrown.
sizeLimit
)

Obtain a copy of the bytes of this object.

public abstract byte[]

Returns:

the cached bytes of this object. Do not modify it.
getCachedBytes
()

Obtain a reference to the (possibly cached) bytes of this object.

public byte[]

Returns:

the cached bytes of this object. Do not modify it.
getCachedBytes
(int
maximum number of bytes to return. If the object size is larger than this limit and isLarge() is true, org.eclipse.jgit.errors.LargeObjectException will be thrown.
sizeLimit
)

Obtain a reference to the (possibly cached) bytes of this object.

public abstract long

Returns:

size of object in bytes
getSize
()

Get size of object in bytes

public abstract int

Returns:

Git in pack object type, see org.eclipse.jgit.lib.Constants.
getType
()

Get Git in pack object type

public boolean

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 openStream() to prevent overflowing the JVM heap.
isLarge
()

Whether this object is too large to obtain as a byte array.

public abstract ObjectStream

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.
openStream
()

Obtain an input stream to read this object's data.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ObjectLoaderback to summary
public ObjectLoader()

Method Detail

cloneArrayback to summary
private static byte[] cloneArray(byte[] data)
copyToback to summary
public void copyTo(OutputStream out) throws MissingObjectException, IOException

Copy this object to the output stream.

For some object store implementations, this method may be more efficient than reading from openStream() into a temporary byte array, then writing to the destination stream.

The default implementation of this method is to copy with a temporary byte array for large objects, or to pass through the cached byte array for small objects.

Parameters
out:OutputStream

stream to receive the complete copy of this object's data. Caller is responsible for flushing or closing this stream after this method returns.

Exceptions
MissingObjectException:
the object no longer exists.
IOException:
the object store cannot be accessed, or the stream cannot be written to.
getBytesback to summary
public final byte[] getBytes() throws LargeObjectException

Obtain a copy of the bytes of this object.

Unlike getCachedBytes() this method returns an array that might be modified by the caller.

Returns:byte[]

the bytes of this object.

Exceptions
LargeObjectException:
if the object won't fit into a byte array, because isLarge() returns true. Callers should use openStream() instead to access the contents.
getBytesback to summary
public final byte[] getBytes(int sizeLimit) throws LargeObjectException, MissingObjectException, IOException

Obtain a copy of the bytes of this object. If the object size is less than or equal to sizeLimit this method will provide it as a byte array, even if isLarge() is true. This utility is useful for application code that absolutely must have the object as a single contiguous byte array in memory. Unlike getCachedBytes(int) this method returns an array that might be modified by the caller.

Parameters
sizeLimit:int

maximum number of bytes to return. If the object is larger than this limit, org.eclipse.jgit.errors.LargeObjectException will be thrown.

Returns:byte[]

the bytes of this object.

Exceptions
LargeObjectException:
if the object is bigger than sizeLimit, or if java.lang.OutOfMemoryError occurs during allocation of the result array. Callers should use openStream() instead to access the contents.
MissingObjectException:
the object is large, and it no longer exists.
IOException:
the object store cannot be accessed.
getCachedBytesback to summary
public abstract byte[] getCachedBytes() throws LargeObjectException

Obtain 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.

Returns:byte[]

the cached bytes of this object. Do not modify it.

Exceptions
LargeObjectException:
if the object won't fit into a byte array, because isLarge() returns true. Callers should use openStream() instead to access the contents.
getCachedBytesback to summary
public byte[] getCachedBytes(int sizeLimit) throws LargeObjectException, MissingObjectException, IOException

Obtain a reference to the (possibly cached) bytes of this object. If the object size is less than or equal to sizeLimit this method will provide it as a byte array, even if isLarge() is true. This utility is useful for application code that absolutely must have the object as a single contiguous byte array in memory. 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.

Parameters
sizeLimit:int

maximum number of bytes to return. If the object size is larger than this limit and isLarge() is true, org.eclipse.jgit.errors.LargeObjectException will be thrown.

Returns:byte[]

the cached bytes of this object. Do not modify it.

Exceptions
LargeObjectException:
if the object is bigger than sizeLimit, or if java.lang.OutOfMemoryError occurs during allocation of the result array. Callers should use openStream() instead to access the contents.
MissingObjectException:
the object is large, and it no longer exists.
IOException:
the object store cannot be accessed.
getSizeback to summary
public abstract long getSize()

Get size of object in bytes

Returns:long

size of object in bytes

getTypeback to summary
public abstract int getType()

Get Git in pack object type

Returns:int

Git in pack object type, see org.eclipse.jgit.lib.Constants.

isLargeback to summary
public boolean isLarge()

Whether this object is too large to obtain as a byte array.

Returns:boolean

true if this object is too large to obtain as a byte array. Objects over a certain threshold should be accessed only by their openStream() to prevent overflowing the JVM heap.

openStreamback to summary
public abstract ObjectStream openStream() throws MissingObjectException, IOException

Obtain an input stream to read this object's data.

Returns:ObjectStream

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.

Exceptions
MissingObjectException:
the object no longer exists.
IOException:
the object store cannot be accessed.
org.eclipse.jgit.lib back to summary

public abstract Class ObjectLoader.Filter

extends ObjectLoader
Class Inheritance

Wraps a delegate ObjectLoader.
Since
4.10

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected abstract ObjectLoader

Returns:

delegate ObjectLoader to handle all processing.
delegate
()

Get delegate ObjectLoader to handle all processing.

public byte[]
getCachedBytes()

Implements abstract org.eclipse.jgit.lib.ObjectLoader.getCachedBytes.

Obtain a reference to the (possibly cached) bytes of this object.

public long
getSize()

Implements abstract org.eclipse.jgit.lib.ObjectLoader.getSize.

Get size of object in bytes

public int
getType()

Implements abstract org.eclipse.jgit.lib.ObjectLoader.getType.

Get Git in pack object type

public boolean
isLarge()

Overrides org.eclipse.jgit.lib.ObjectLoader.isLarge.

Whether this object is too large to obtain as a byte array.

public ObjectStream
openStream()

Implements abstract org.eclipse.jgit.lib.ObjectLoader.openStream.

Obtain an input stream to read this object's data.

Inherited from org.eclipse.jgit.lib.ObjectLoader:
copyTogetBytesgetBytesgetCachedBytes

Constructor Detail

Filterback to summary
public Filter()

Method Detail

delegateback to summary
protected abstract ObjectLoader delegate()

Get delegate ObjectLoader to handle all processing.

Returns:ObjectLoader

delegate ObjectLoader to handle all processing.

Since
4.10
getCachedBytesback to summary
public byte[] getCachedBytes()

Implements abstract org.eclipse.jgit.lib.ObjectLoader.getCachedBytes.

Doc from org.eclipse.jgit.lib.ObjectLoader.getCachedBytes.

Obtain 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.

Returns:byte[]

the cached bytes of this object. Do not modify it.

Annotations
@Override
getSizeback to summary
public long getSize()

Implements abstract org.eclipse.jgit.lib.ObjectLoader.getSize.

Doc from org.eclipse.jgit.lib.ObjectLoader.getSize.

Get size of object in bytes

Returns:long

size of object in bytes

Annotations
@Override
getTypeback to summary
public int getType()

Implements abstract org.eclipse.jgit.lib.ObjectLoader.getType.

Doc from org.eclipse.jgit.lib.ObjectLoader.getType.

Get Git in pack object type

Returns:int

Git in pack object type, see org.eclipse.jgit.lib.Constants.

Annotations
@Override
isLargeback to summary
public boolean isLarge()

Overrides org.eclipse.jgit.lib.ObjectLoader.isLarge.

Doc from org.eclipse.jgit.lib.ObjectLoader.isLarge.

Whether this object is too large to obtain as a byte array.

Returns:boolean

true if this object is too large to obtain as a byte array. Objects over a certain threshold should be accessed only by their openStream() to prevent overflowing the JVM heap.

Annotations
@Override
openStreamback to summary
public ObjectStream openStream() throws IOException

Implements abstract org.eclipse.jgit.lib.ObjectLoader.openStream.

Doc from org.eclipse.jgit.lib.ObjectLoader.openStream.

Obtain an input stream to read this object's data.

Returns:ObjectStream

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.

Annotations
@Override
Exceptions
IOException:
the object store cannot be accessed.
org.eclipse.jgit.lib back to summary

public Class ObjectLoader.SmallObject

extends ObjectLoader
Class Inheritance

Simple loader around the cached byte array.

ObjectReader implementations can use this stream type when the object's content is small enough to be accessed as a single byte array.

Field Summary

Modifier and TypeField and Description
private final byte[]
private final int

Constructor Summary

AccessConstructor and Description
public
SmallObject(int
type of the object.
type
,
byte[]
the object's data array. This array will be returned as-is for the getCachedBytes() method.
data
)

Construct a small object loader.

Method Summary

Modifier and TypeMethod and Description
public byte[]
getCachedBytes()

Implements abstract org.eclipse.jgit.lib.ObjectLoader.getCachedBytes.

Obtain a reference to the (possibly cached) bytes of this object.

public long
getSize()

Implements abstract org.eclipse.jgit.lib.ObjectLoader.getSize.

Get size of object in bytes

public int
getType()

Implements abstract org.eclipse.jgit.lib.ObjectLoader.getType.

Get Git in pack object type

public boolean
isLarge()

Overrides org.eclipse.jgit.lib.ObjectLoader.isLarge.

Whether this object is too large to obtain as a byte array.

public ObjectStream
openStream()

Implements abstract org.eclipse.jgit.lib.ObjectLoader.openStream.

Obtain an input stream to read this object's data.

Inherited from org.eclipse.jgit.lib.ObjectLoader:
copyTogetBytesgetBytesgetCachedBytes

Field Detail

databack to summary
private final byte[] data
typeback to summary
private final int type

Constructor Detail

SmallObjectback to summary
public SmallObject(int type, byte[] data)

Construct a small object loader.

Parameters
type:int

type of the object.

data:byte[]

the object's data array. This array will be returned as-is for the getCachedBytes() method.

Method Detail

getCachedBytesback to summary
public byte[] getCachedBytes()

Implements abstract org.eclipse.jgit.lib.ObjectLoader.getCachedBytes.

Doc from org.eclipse.jgit.lib.ObjectLoader.getCachedBytes.

Obtain 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.

Returns:byte[]

the cached bytes of this object. Do not modify it.

Annotations
@Override
getSizeback to summary
public long getSize()

Implements abstract org.eclipse.jgit.lib.ObjectLoader.getSize.

Doc from org.eclipse.jgit.lib.ObjectLoader.getSize.

Get size of object in bytes

Returns:long

size of object in bytes

Annotations
@Override
getTypeback to summary
public int getType()

Implements abstract org.eclipse.jgit.lib.ObjectLoader.getType.

Doc from org.eclipse.jgit.lib.ObjectLoader.getType.

Get Git in pack object type

Returns:int

Git in pack object type, see org.eclipse.jgit.lib.Constants.

Annotations
@Override
isLargeback to summary
public boolean isLarge()

Overrides org.eclipse.jgit.lib.ObjectLoader.isLarge.

Doc from org.eclipse.jgit.lib.ObjectLoader.isLarge.

Whether this object is too large to obtain as a byte array.

Returns:boolean

true if this object is too large to obtain as a byte array. Objects over a certain threshold should be accessed only by their openStream() to prevent overflowing the JVM heap.

Annotations
@Override
openStreamback to summary
public ObjectStream openStream()

Implements abstract org.eclipse.jgit.lib.ObjectLoader.openStream.

Doc from org.eclipse.jgit.lib.ObjectLoader.openStream.

Obtain an input stream to read this object's data.

Returns:ObjectStream

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.

Annotations
@Override