Class ObjectLoader.SmallObject

  extended by org.eclipse.jgit.lib.ObjectLoader
      extended by org.eclipse.jgit.lib.ObjectLoader.SmallObject
Enclosing class:

public static class ObjectLoader.SmallObject
extends ObjectLoader

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.

Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jgit.lib.ObjectLoader
Constructor Summary
ObjectLoader.SmallObject(int type, byte[] data)
          Construct a small object loader.
Method Summary
 byte[] getCachedBytes()
          Obtain a reference to the (possibly cached) bytes of this object.
 long getSize()
 int getType()
 boolean isLarge()
 ObjectStream openStream()
          Obtain an input stream to read this object's data.
Methods inherited from class org.eclipse.jgit.lib.ObjectLoader
copyTo, getBytes, getBytes, getCachedBytes
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public ObjectLoader.SmallObject(int type,
                                byte[] data)
Construct a small object loader.

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


public int getType()
Specified by:
getType in class ObjectLoader
Git in pack object type, see Constants.


public long getSize()
Specified by:
getSize in class ObjectLoader
size of object in bytes


public boolean isLarge()
isLarge in class ObjectLoader
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.


public byte[] getCachedBytes()
Description copied from class: ObjectLoader
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.

Specified by:
getCachedBytes in class ObjectLoader
the cached bytes of this object. Do not modify it.


public ObjectStream openStream()
Description copied from class: ObjectLoader
Obtain an input stream to read this object's data.

Specified by:
openStream in class ObjectLoader
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.

Copyright © 2013. All Rights Reserved.