public abstract class ObjectLoader extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ObjectLoader.Filter
Wraps a delegate ObjectLoader.
|
static class |
ObjectLoader.SmallObject
Simple loader around the cached byte array.
|
Constructor and Description |
---|
ObjectLoader() |
Modifier and Type | Method and Description |
---|---|
void |
copyTo(OutputStream out)
Copy this object to the output stream.
|
byte[] |
getBytes()
Obtain a copy of the bytes of this object.
|
byte[] |
getBytes(int sizeLimit)
Obtain a copy of the bytes of this object.
|
abstract byte[] |
getCachedBytes()
Obtain a reference to the (possibly cached) bytes of this object.
|
byte[] |
getCachedBytes(int sizeLimit)
Obtain a reference to the (possibly cached) bytes of this object.
|
abstract long |
getSize()
Get size of object in bytes
|
abstract int |
getType()
Get Git in pack object type
|
boolean |
isLarge()
Whether this object is too large to obtain as a byte array.
|
abstract ObjectStream |
openStream()
Obtain an input stream to read this object's data.
|
public abstract int getType()
Constants
.public abstract long getSize()
public boolean isLarge()
openStream()
to prevent overflowing the JVM heap.public final byte[] getBytes() throws LargeObjectException
Unlike getCachedBytes()
this method returns an array that might
be modified by the caller.
LargeObjectException
- if the object won't fit into a byte array, because
isLarge()
returns true. Callers should use
openStream()
instead to access the contents.public final byte[] getBytes(int sizeLimit) throws LargeObjectException, MissingObjectException, IOException
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.sizeLimit
- maximum number of bytes to return. If the object is larger
than this limit,
LargeObjectException
will be
thrown.LargeObjectException
- if the object is bigger than sizeLimit
, or if
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.public abstract byte[] getCachedBytes() throws LargeObjectException
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.
LargeObjectException
- if the object won't fit into a byte array, because
isLarge()
returns true. Callers should use
openStream()
instead to access the contents.public byte[] getCachedBytes(int sizeLimit) throws LargeObjectException, MissingObjectException, IOException
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.sizeLimit
- maximum number of bytes to return. If the object size is
larger than this limit and isLarge()
is true,
LargeObjectException
will be
thrown.LargeObjectException
- if the object is bigger than sizeLimit
, or if
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.public abstract ObjectStream openStream() throws MissingObjectException, IOException
MissingObjectException
- the object no longer exists.IOException
- the object store cannot be accessed.public void copyTo(OutputStream out) throws MissingObjectException, IOException
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.
out
- stream to receive the complete copy of this object's data.
Caller is responsible for flushing or closing this stream
after this method returns.MissingObjectException
- the object no longer exists.IOException
- the object store cannot be accessed, or the stream cannot be
written to.Copyright © 2017 Eclipse JGit Project. All rights reserved.