public abstract static class ObjectInserter.Filter extends ObjectInserter
ObjectInserter.Filter, ObjectInserter.Formatter
Constructor and Description |
---|
Filter() |
Modifier and Type | Method and Description |
---|---|
protected byte[] |
buffer()
Obtain a temporary buffer for use by the ObjectInserter or its subclass.
|
void |
close() |
protected abstract ObjectInserter |
delegate() |
void |
flush()
Make all inserted objects visible.
|
ObjectId |
idFor(int type,
byte[] data)
Compute the name of an object, without inserting it.
|
ObjectId |
idFor(int type,
byte[] data,
int off,
int len)
Compute the name of an object, without inserting it.
|
ObjectId |
idFor(int objectType,
long length,
InputStream in)
Compute the name of an object, without inserting it.
|
ObjectId |
idFor(TreeFormatter formatter)
Compute the ObjectId for the given tree without inserting it.
|
ObjectId |
insert(int type,
byte[] data)
Insert a single object into the store, returning its unique name.
|
ObjectId |
insert(int type,
byte[] data,
int off,
int len)
Insert a single object into the store, returning its unique name.
|
ObjectId |
insert(int objectType,
long length,
InputStream in)
Insert a single object into the store, returning its unique name.
|
PackParser |
newPackParser(InputStream in)
Initialize a parser to read from a pack formatted stream.
|
ObjectReader |
newReader()
Open a reader for objects that may have been written by this inserter.
|
digest, insert, insert, insert
protected abstract ObjectInserter delegate()
protected byte[] buffer()
ObjectInserter
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.
buffer
in class ObjectInserter
public ObjectId idFor(int type, byte[] data)
ObjectInserter
idFor
in class ObjectInserter
type
- type code of the object to store.data
- complete content of the object.public ObjectId idFor(int type, byte[] data, int off, int len)
ObjectInserter
idFor
in class ObjectInserter
type
- type code of the object to store.data
- complete content of the object.off
- first position within data
.len
- number of bytes to copy from data
.public ObjectId idFor(int objectType, long length, InputStream in) throws IOException
ObjectInserter
idFor
in class ObjectInserter
objectType
- type code of the object to store.length
- number of bytes to scan from in
.in
- stream providing the object content. The caller is responsible
for closing the stream.IOException
- the source stream could not be read.public ObjectId idFor(TreeFormatter formatter)
ObjectInserter
idFor
in class ObjectInserter
formatter
- a TreeFormatter
object.public ObjectId insert(int type, byte[] data) throws IOException
ObjectInserter
insert
in class ObjectInserter
type
- type code of the object to store.data
- complete content of the object.IOException
- the object could not be stored.public ObjectId insert(int type, byte[] data, int off, int len) throws IOException
ObjectInserter
insert
in class ObjectInserter
type
- type code of the object to store.data
- complete content of the object.off
- first position within data
.len
- number of bytes to copy from data
.IOException
- the object could not be stored.public ObjectId insert(int objectType, long length, InputStream in) throws IOException
ObjectInserter
insert
in class ObjectInserter
objectType
- type code of the object to store.length
- number of bytes to copy from in
.in
- stream providing the object content. The caller is responsible
for closing the stream.IOException
- the object could not be stored, or the source stream could
not be read.public PackParser newPackParser(InputStream in) throws IOException
ObjectInserter
newPackParser
in class ObjectInserter
in
- the input stream. The stream is not closed by the parser, and
must instead be closed by the caller once parsing is complete.IOException
- the parser instance, which can be configured and then used to
parse objects into the ObjectDatabase.public ObjectReader newReader()
ObjectInserter
The returned reader allows the calling thread to read back recently
inserted objects without first calling flush()
to make them
visible to the repository. The returned reader should only be used from
the same thread as the inserter. Objects written by this inserter may not
be visible to this.newReader().newReader()
.
The returned reader should return this inserter instance from ObjectReader.getCreatedFromInserter()
.
Behavior is undefined if an insert method is called on the inserter in the
middle of reading from an ObjectStream
opened from this reader. For
example, reading the remainder of the object may fail, or newly written
data may even be corrupted. Interleaving whole object reads (including
streaming reads) with inserts is fine, just not interleaving streaming
partial object reads with inserts.
newReader
in class ObjectInserter
public void flush() throws IOException
ObjectInserter
The flush may take some period of time to make the objects available to other threads.
flush
in class ObjectInserter
IOException
- the flush could not be completed; objects inserted thus far
are in an indeterminate state.public void close()
ObjectInserter
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.
close
in interface AutoCloseable
close
in class ObjectInserter
Copyright © 2020 Eclipse JGit Project. All rights reserved.