ObjectDatabase.
An inserter is not thread-safe. Individual threads should each obtain their own unique inserter instance, or must arrange for locking at a higher level to ensure the inserter is in use by no more than one thread at a time.
Objects written by an inserter may not be immediately visible for reading
after the insert method completes. Callers must invoke either
close() or flush() prior to updating references or
otherwise making the returned ObjectIds visible to other code.
| Modifier and Type | Class and Description |
|---|---|
| public abstract static class | ObjectInserter.
Wraps a delegate ObjectInserter. |
| public static class | ObjectInserter.
An inserter that can be used for formatting and id generation only. |
| Modifier and Type | Field and Description |
|---|---|
| private final SHA1 | |
| private byte[] | tempBuffer
Temporary working buffer for streaming data through. |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| protected byte[] | Returns: a temporary byte array for use by the caller.Obtain a temporary buffer for use by the ObjectInserter or its subclass. |
| public abstract void | close()
Redeclares java. Closes this resource, relinquishing any underlying resources. |
| protected SHA1 | |
| public abstract void | |
| public ObjectId | Returns: the name of the object.type code of the object to store. type, byte[] complete content of the object. data)Compute the name of an object, without inserting it. |
| public ObjectId | Returns: the name of the object.type code of the object to store. type, byte[] complete content of the object. data, int first position within off, int data.number of bytes to copy from len)data.Compute the name of an object, without inserting it. |
| public ObjectId | Returns: the name of the object.type code of the object to store. objectType, long number of bytes to scan from length, InputStream in.stream providing the object content. The caller is responsible
for closing the stream. in)Compute the name of an object, without inserting it. |
| public ObjectId | Returns: the computed ObjectIda formatter)org. object.Compute the ObjectId for the given tree without inserting it. |
| public final ObjectId | Returns: the name of the tree object.the formatter containing the proposed tree's data. formatter)Insert a single tree into the store, returning its unique name. |
| public final ObjectId | Returns: the name of the commit object.the builder containing the proposed commit's data. builder)Insert a single commit into the store, returning its unique name. |
| public final ObjectId | Returns: the name of the tag object.the builder containing the proposed tag's data. builder)Insert a single annotated tag into the store, returning its unique name. |
| public ObjectId | Returns: the name of the object.type code of the object to store. type, byte[] complete content of the object. data)Insert a single object into the store, returning its unique name. |
| public ObjectId | Returns: the name of the object.type code of the object to store. type, byte[] complete content of the object. data, int first position within off, int data.number of bytes to copy from len)data.Insert a single object into the store, returning its unique name. |
| public abstract ObjectId | Returns: the name of the object.type code of the object to store. objectType, long number of bytes to copy from length, InputStream in.stream providing the object content. The caller is responsible
for closing the stream. in)Insert a single object into the store, returning its unique name. |
| public abstract PackParser | Returns: the pack parser.the input stream. The stream is not closed by the parser, and
must instead be closed by the caller once parsing is complete. in)Initialize a parser to read from a pack formatted stream. |
| public abstract ObjectReader | Returns: reader for any object, including an object recently inserted by this inserter since the last flush.Open a reader for objects that may have been written by this inserter. |
| hasher | back to summary |
|---|---|
| private final SHA1 hasher | |
| tempBuffer | back to summary |
|---|---|
| private byte[] tempBuffer Temporary working buffer for streaming data through. | |
| ObjectInserter | back to summary |
|---|---|
| protected ObjectInserter() Create a new inserter for a database. | |
| buffer | back to summary |
|---|---|
| protected byte[] buffer() Obtain a temporary buffer for use by the ObjectInserter or its subclass. This buffer is supplied by the ObjectInserter base class to itself and its subclasses for the purposes of pulling data from a supplied InputStream, passing it through a Deflater, or formatting the canonical format of a small object like a small tree or commit. This buffer IS NOT for translation such as auto-CRLF or content filtering and must not be used for such purposes. The returned buffer is small, around a few KiBs, and the size may change between versions of JGit. Callers using this buffer must always check the length of the returned array to ascertain how much space was provided. There is a single buffer for each ObjectInserter, repeated calls to this method will (usually) always return the same buffer. If the caller needs more than one buffer, or needs a buffer of a larger size, it must manage that buffer on its own. The buffer is usually on first demand for a buffer.
| |
| close | back to summary |
|---|---|
| public abstract void close() Redeclares java. Doc from java. Closes this resource, relinquishing any underlying resources.
This method is invoked automatically on objects managed by the
Release any resources used by this inserter. An inserter that has been released can be used again, but may need to be released after the subsequent usage.
| |
| digest | back to summary |
|---|---|
| protected SHA1 digest() Compute digest to help compute an ObjectId
| |
| flush | back to summary |
|---|---|
| public abstract void flush() throws IOException Make all inserted objects visible. The flush may take some period of time to make the objects available to other threads.
| |
| idFor | back to summary |
|---|---|
| public ObjectId idFor(int type, byte[] data) Compute the name of an object, without inserting it.
| |
| idFor | back to summary |
|---|---|
| public ObjectId idFor(int type, byte[] data, int off, int len) Compute the name of an object, without inserting it.
| |
| idFor | back to summary |
|---|---|
| public ObjectId idFor(int objectType, long length, InputStream in) throws IOException Compute the name of an object, without inserting it.
| |
| idFor | back to summary |
|---|---|
| public ObjectId idFor(TreeFormatter formatter) Compute the ObjectId for the given tree without inserting it.
| |
| insert | back to summary |
|---|---|
| public final ObjectId insert(TreeFormatter formatter) throws IOException Insert a single tree into the store, returning its unique name.
| |
| insert | back to summary |
|---|---|
| public final ObjectId insert(CommitBuilder builder) throws IOException Insert a single commit into the store, returning its unique name.
| |
| insert | back to summary |
|---|---|
| public final ObjectId insert(TagBuilder builder) throws IOException Insert a single annotated tag into the store, returning its unique name.
| |
| insert | back to summary |
|---|---|
| public ObjectId insert(int type, byte[] data) throws IOException Insert a single object into the store, returning its unique name.
| |
| insert | back to summary |
|---|---|
| public ObjectId insert(int type, byte[] data, int off, int len) throws IOException Insert a single object into the store, returning its unique name.
| |
| insert | back to summary |
|---|---|
| public abstract ObjectId insert(int objectType, long length, InputStream in) throws IOException Insert a single object into the store, returning its unique name.
| |
| newPackParser | back to summary |
|---|---|
| public abstract PackParser newPackParser(InputStream in) throws IOException Initialize a parser to read from a pack formatted stream.
| |
| newReader | back to summary |
|---|---|
| public abstract ObjectReader newReader() Open a reader for objects that may have been written by this inserter.
The returned reader allows the calling thread to read back recently
inserted objects without first calling
The returned reader should return this inserter instance from
Behavior is undefined if an insert method is called on the inserter in the
middle of reading from an
| |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected byte[] | buffer()
Overrides org. Obtain a temporary buffer for use by the ObjectInserter or its subclass. |
| public void | close()
Implements abstract org. Implements java. Closes this resource, relinquishing any underlying resources. |
| protected abstract ObjectInserter | Returns: delegate ObjectInserter to handle all processing.Get delegate ObjectInserter to handle all processing |
| public void | flush()
Implements abstract org. Make all inserted objects visible. |
| public ObjectId | idFor(int
type code of the object to store. type, byte[] complete content of the object. data)Overrides org. Compute the name of an object, without inserting it. |
| public ObjectId | idFor(int
type code of the object to store. type, byte[] complete content of the object. data, int first position within off, int data.number of bytes to copy from len)data.Overrides org. Compute the name of an object, without inserting it. |
| public ObjectId | idFor(int
type code of the object to store. objectType, long number of bytes to scan from length, InputStream in.stream providing the object content. The caller is responsible
for closing the stream. in)Overrides org. Compute the name of an object, without inserting it. |
| public ObjectId | idFor(TreeFormatter
a formatter)org. object.Overrides org. Compute the ObjectId for the given tree without inserting it. |
| public ObjectId | insert(int
type code of the object to store. type, byte[] complete content of the object. data)Overrides org. Insert a single object into the store, returning its unique name. |
| public ObjectId | insert(int
type code of the object to store. type, byte[] complete content of the object. data, int first position within off, int data.number of bytes to copy from len)data.Overrides org. Insert a single object into the store, returning its unique name. |
| public ObjectId | insert(int
type code of the object to store. objectType, long number of bytes to copy from length, InputStream in.stream providing the object content. The caller is responsible
for closing the stream. in)Implements abstract org. Insert a single object into the store, returning its unique name. |
| public PackParser | newPackParser(InputStream
the input stream. The stream is not closed by the parser, and
must instead be closed by the caller once parsing is complete. in)Implements abstract org. Initialize a parser to read from a pack formatted stream. |
| public ObjectReader | newReader()
Implements abstract org. Open a reader for objects that may have been written by this inserter. |
| Filter | back to summary |
|---|---|
| public Filter() | |
| buffer | back to summary |
|---|---|
| protected byte[] buffer() Overrides org. Doc from org. Obtain a temporary buffer for use by the ObjectInserter or its subclass. This buffer is supplied by the ObjectInserter base class to itself and its subclasses for the purposes of pulling data from a supplied InputStream, passing it through a Deflater, or formatting the canonical format of a small object like a small tree or commit. This buffer IS NOT for translation such as auto-CRLF or content filtering and must not be used for such purposes. The returned buffer is small, around a few KiBs, and the size may change between versions of JGit. Callers using this buffer must always check the length of the returned array to ascertain how much space was provided. There is a single buffer for each ObjectInserter, repeated calls to this method will (usually) always return the same buffer. If the caller needs more than one buffer, or needs a buffer of a larger size, it must manage that buffer on its own. The buffer is usually on first demand for a buffer.
| |
| close | back to summary |
|---|---|
| public void close() Implements abstract org. Implements java. Doc from org. Closes this resource, relinquishing any underlying resources.
This method is invoked automatically on objects managed by the
Release any resources used by this inserter. An inserter that has been released can be used again, but may need to be released after the subsequent usage.
| |
| delegate | back to summary |
|---|---|
| protected abstract ObjectInserter delegate() Get delegate ObjectInserter to handle all processing
| |
| flush | back to summary |
|---|---|
| public void flush() throws IOException Implements abstract org. Doc from org. Make all inserted objects visible. The flush may take some period of time to make the objects available to other threads.
| |
| idFor | back to summary |
|---|---|
| public ObjectId idFor(int type, byte[] data) Overrides org. Doc from org. Compute the name of an object, without inserting it. | |
| idFor | back to summary |
|---|---|
| public ObjectId idFor(int type, byte[] data, int off, int len) Overrides org. Doc from org. Compute the name of an object, without inserting it. | |
| idFor | back to summary |
|---|---|
| public ObjectId idFor(int objectType, long length, InputStream in) throws IOException Overrides org. Doc from org. Compute the name of an object, without inserting it.
| |
| idFor | back to summary |
|---|---|
| public ObjectId idFor(TreeFormatter formatter) Overrides org. Doc from org. Compute the ObjectId for the given tree without inserting it.
| |
| insert | back to summary |
|---|---|
| public ObjectId insert(int type, byte[] data) throws IOException Overrides org. Doc from org. Insert a single object into the store, returning its unique name.
| |
| insert | back to summary |
|---|---|
| public ObjectId insert(int type, byte[] data, int off, int len) throws IOException Overrides org. Doc from org. Insert a single object into the store, returning its unique name.
| |
| insert | back to summary |
|---|---|
| public ObjectId insert(int objectType, long length, InputStream in) throws IOException Implements abstract org. Doc from org. Insert a single object into the store, returning its unique name.
| |
| newPackParser | back to summary |
|---|---|
| public PackParser newPackParser(InputStream in) throws IOException Implements abstract org. Doc from org. Initialize a parser to read from a pack formatted stream.
| |
| newReader | back to summary |
|---|---|
| public ObjectReader newReader() Implements abstract org. Doc from org. Open a reader for objects that may have been written by this inserter.
The returned reader allows the calling thread to read back recently
inserted objects without first calling
The returned reader should return this inserter instance from
Behavior is undefined if an insert method is called on the inserter in the
middle of reading from an
| |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Implements abstract org. Implements java. Closes this resource, relinquishing any underlying resources. |
| public void | flush()
Implements abstract org. Make all inserted objects visible. |
| public ObjectId | insert(int
type code of the object to store. objectType, long number of bytes to copy from length, InputStream in.stream providing the object content. The caller is responsible
for closing the stream. in)Implements abstract org. Insert a single object into the store, returning its unique name. |
| public PackParser | newPackParser(InputStream
the input stream. The stream is not closed by the parser, and
must instead be closed by the caller once parsing is complete. in)Implements abstract org. Initialize a parser to read from a pack formatted stream. |
| public ObjectReader | newReader()
Implements abstract org. Open a reader for objects that may have been written by this inserter. |
| Formatter | back to summary |
|---|---|
| public Formatter() | |
| close | back to summary |
|---|---|
| public void close() Implements abstract org. Implements java. Doc from org. Closes this resource, relinquishing any underlying resources.
This method is invoked automatically on objects managed by the
Release any resources used by this inserter. An inserter that has been released can be used again, but may need to be released after the subsequent usage.
| |
| flush | back to summary |
|---|---|
| public void flush() throws IOException Implements abstract org. Doc from org. Make all inserted objects visible. The flush may take some period of time to make the objects available to other threads.
| |
| insert | back to summary |
|---|---|
| public ObjectId insert(int objectType, long length, InputStream in) throws IOException Implements abstract org. Doc from org. Insert a single object into the store, returning its unique name.
| |
| newPackParser | back to summary |
|---|---|
| public PackParser newPackParser(InputStream in) throws IOException Implements abstract org. Doc from org. Initialize a parser to read from a pack formatted stream.
| |
| newReader | back to summary |
|---|---|
| public ObjectReader newReader() Implements abstract org. Doc from org. Open a reader for objects that may have been written by this inserter.
The returned reader allows the calling thread to read back recently
inserted objects without first calling
The returned reader should return this inserter instance from
Behavior is undefined if an insert method is called on the inserter in the
middle of reading from an
| |