A new iterator instance should be positioned on the first entry, or at eof. Data for the first entry (if not at eof) should be available immediately.
Implementors must walk a tree in the Git sort order, which has the following odd sorting:
In the second item, A is the name of a subtree and
c is a file within that subtree. The other two items are files
in the root level tree.
CanonicalTreeParser
| Modifier and Type | Field and Description |
|---|---|
| protected AttributesNode | attributesNode
Parsed rules of .gitattributes file if it exists. |
| protected static final int | DEFAULT_PATH_SIZE
Default size for the |
| pack-priv AbstractTreeIterator | matches
The iterator this current entry is path equal to. |
| pack-priv int | matchShift
Number of entries we moved forward to force a D/F conflict match. |
| protected int | mode
Mode bits for the current entry. |
| public final AbstractTreeIterator | parent
Iterator for the parent tree; null if we are the root iterator. |
| protected byte[] | path
Path buffer for the current entry. |
| protected int | pathLen
Total length of the current entry's complete path from the root. |
| protected final int | pathOffset
Position within |
| protected static final byte[] | zeroid
A dummy object id buffer that matches the zero ObjectId. |
| Access | Constructor and Description |
|---|---|
| protected | |
| protected | AbstractTreeIterator(String
position of this iterator in the repository tree. The value
may be null or the empty string to indicate the prefix is the
root of the repository. A trailing slash ('/') is
automatically appended if the prefix does not end in '/'. prefix)Create a new iterator with no parent and a prefix. |
| protected | AbstractTreeIterator(byte[]
position of this iterator in the repository tree. The value
may be null or the empty array to indicate the prefix is the
root of the repository. A trailing slash ('/') is
automatically appended if the prefix does not end in '/'. prefix)Create a new iterator with no parent and a prefix. |
| protected | AbstractTreeIterator(AbstractTreeIterator
parent tree iterator. p)Create an iterator for a subtree of an existing iterator. |
| protected | AbstractTreeIterator(final AbstractTreeIterator
parent tree iterator. p, final byte[] path array to be used by the child iterator. This path must
contain the path from the top of the walk to the first child
and must end with a '/'. childPath, final int position within childPathOffset)childPath where the child can
insert its data. The value at
childPath[childPathOffset-1] must be '/'.Create an iterator for a subtree of an existing iterator. |
| Modifier and Type | Method and Description |
|---|---|
| private static int | |
| public abstract void | back(int
number of entries to move the iterator by. Must be a positive,
non-zero integer. delta)Move to prior entry, populating this iterator with the entry data. |
| public EmptyTreeIterator | Returns: a new empty tree iterator.Create a new iterator as though the current entry were a subtree. |
| public abstract AbstractTreeIterator | Returns: a new parser that walks over the current subtree.reader to load the tree data from. reader)Create a new iterator for the current entry's subtree. |
| public AbstractTreeIterator | Returns: a new parser that walks over the current subtree.reader to load the tree data from. reader, final MutableObjectId temporary ObjectId buffer for use by this method. idBuffer)Create a new iterator for the current entry's subtree. |
| protected void | ensurePathCapacity(int
the amount of bytes to hold capacity, int the amount of live bytes in path buffer len)Ensure that path is capable to hold at least |
| public abstract boolean | Returns: true if we have walked all entries and have none left.Is this tree iterator at its EOF point (no more entries)? |
| public boolean | |
| public boolean | Returns: true if the file exists in this tree; false otherwise.file name to find (will not find a directory). name)Seek the iterator on a file, if present. |
| public abstract boolean | Returns: true if the iterator is positioned on the first entry.Is this tree iterator positioned on its first entry? |
| public FileMode | Returns: the file mode of the current entry.Get the file mode of the current entry. |
| public ObjectId | Returns: an object id for the current entry.Get the object id of the current entry. |
| public void | getEntryObjectId(MutableObjectId
buffer to copy the object id into. out)Obtain the ObjectId for the current entry. |
| public byte[] | Returns: the internal buffer holding the current path.Get the current entry path buffer. |
| public int | Returns: path hash code; any integer may be returned.Get the current entry's path hash code. |
| public int | Returns: length of the path ingetEntryPathBuffer().Get length of the path in |
| public String | Returns: path of the current entry, as a string.Get path of the current entry, as a string. |
| public int | Returns: the file mode of the current entry as bits.Get the file mode of the current entry as bits. |
| public void | getName(byte[]
the buffer to get the name into, it is assumed that buffer can
hold the name buffer, int the offset of the name in the buffer offset)Get the name component of the current entry path into the provided buffer. |
| public int | Returns: the length of the name component of the path for the current entry.Get the length of the name component of the path for the current entry. |
| public int | Returns: start of name component part withingetEntryPathBuffer()JGit internal API for use by
|
| protected void | growPath(int
number of live bytes in the path buffer. This many bytes will
be moved into the larger buffer. len)Grow the path buffer larger. |
| public abstract boolean | |
| public abstract byte[] | Returns: byte array the implementation stores object IDs within.Get the byte array buffer object IDs must be copied out of. |
| public boolean | Returns: true if both iterators have the same object id; false otherwise.the other iterator to test against. otherIterator)Check if the current entry of both iterators has the same id.
This method is faster than |
| public abstract int | Returns: offset into the array returned byidBuffer() where the
ObjectId must be copied out of.Get the position within |
| public boolean | Returns: whether or not this Iterator is iterating through the working treeWhether or not this Iterator is iterating through the working tree. |
| protected boolean | |
| public abstract void | next(int
number of entries to move the iterator by. Must be a positive,
non-zero integer. delta)Move to next entry, populating this iterator with the entry data. |
| public int | Returns: -1 if this entry sorts first; 0 if the entries are equal; 1 if p's entry sorts first.the other iterator to compare the path against. p)Compare the path of this current entry to another iterator's entry. |
| pack-priv int | |
| public int | Returns: -1 if this entry sorts first; 0 if the entries are equal; 1 if p's entry sorts first.the raw path buffer. buf, int position to start reading the raw buffer. pos, int one past the end of the raw buffer (length is end - pos). end, int the mode of the path. pathMode)Compare the path of this current entry to a raw buffer. |
| private int | |
| public void | |
| private void | setPathCapacity(int
the new size capacity, int the amount of bytes to copy len)Set path buffer capacity to the specified size |
| public void | |
| public void | |
| public String |
| attributesNode | back to summary |
|---|---|
| protected AttributesNode attributesNode Parsed rules of .gitattributes file if it exists.
| |
| DEFAULT_PATH_SIZE | back to summary |
|---|---|
| protected static final int DEFAULT_PATH_SIZE Default size for the | |
| matches | back to summary |
|---|---|
| pack-priv AbstractTreeIterator matches The iterator this current entry is path equal to. | |
| matchShift | back to summary |
|---|---|
| pack-priv int matchShift Number of entries we moved forward to force a D/F conflict match.
| |
| mode | back to summary |
|---|---|
| protected int mode Mode bits for the current entry. A numerical value from FileMode is usually faster for an iterator to obtain from its data source so this is the preferred representation.
| |
| parent | back to summary |
|---|---|
| public final AbstractTreeIterator parent Iterator for the parent tree; null if we are the root iterator.
Used by
| |
| path | back to summary |
|---|---|
| protected byte[] path Path buffer for the current entry. This buffer is pre-allocated at the start of walking and is shared from parent iterators down into their subtree iterators. The sharing allows the current entry to always be a full path from the root, while each subtree only needs to populate the part that is under their control. | |
| pathLen | back to summary |
|---|---|
| protected int pathLen Total length of the current entry's complete path from the root.
This is the number of bytes within | |
| pathOffset | back to summary |
|---|---|
| protected final int pathOffset Position within
This is the first offset in | |
| zeroid | back to summary |
|---|---|
| protected static final byte[] zeroid A dummy object id buffer that matches the zero ObjectId. | |
| AbstractTreeIterator | back to summary |
|---|---|
| protected AbstractTreeIterator() Create a new iterator with no parent. | |
| AbstractTreeIterator | back to summary |
|---|---|
| protected AbstractTreeIterator(String prefix) Create a new iterator with no parent and a prefix. The prefix path supplied is inserted in front of all paths generated by this iterator. It is intended to be used when an iterator is being created for a subsection of an overall repository and needs to be combined with other iterators that are created to run over the entire repository namespace.
| |
| AbstractTreeIterator | back to summary |
|---|---|
| protected AbstractTreeIterator(byte[] prefix) Create a new iterator with no parent and a prefix. The prefix path supplied is inserted in front of all paths generated by this iterator. It is intended to be used when an iterator is being created for a subsection of an overall repository and needs to be combined with other iterators that are created to run over the entire repository namespace.
| |
| AbstractTreeIterator | back to summary |
|---|---|
| protected AbstractTreeIterator(AbstractTreeIterator p) Create an iterator for a subtree of an existing iterator.
| |
| AbstractTreeIterator | back to summary |
|---|---|
| protected AbstractTreeIterator(final AbstractTreeIterator p, final byte[] childPath, final int childPathOffset) Create an iterator for a subtree of an existing iterator. The caller is responsible for setting up the path of the child iterator.
| |
| alreadyMatch | back to summary |
|---|---|
| private static int alreadyMatch(AbstractTreeIterator a, AbstractTreeIterator b) | |
| back | back to summary |
|---|---|
| public abstract void back(int delta) throws CorruptObjectException Move to prior entry, populating this iterator with the entry data. The delta indicates how many moves backward should occur.The most common delta is 1 to move to the prior entry. Implementations must populate the following members:
idBuffer() and idOffset()
when demanded.
| |
| createEmptyTreeIterator | back to summary |
|---|---|
| public EmptyTreeIterator createEmptyTreeIterator() Create a new iterator as though the current entry were a subtree.
| |
| createSubtreeIterator | back to summary |
|---|---|
| public abstract AbstractTreeIterator createSubtreeIterator(ObjectReader reader) throws IncorrectObjectTypeException, IOException Create a new iterator for the current entry's subtree.
The parent reference of the iterator must be
| |
| createSubtreeIterator | back to summary |
|---|---|
| public AbstractTreeIterator createSubtreeIterator(final ObjectReader reader, final MutableObjectId idBuffer) throws IncorrectObjectTypeException, IOException Create a new iterator for the current entry's subtree.
The parent reference of the iterator must be
| |
| ensurePathCapacity | back to summary |
|---|---|
| protected void ensurePathCapacity(int capacity, int len) Ensure that path is capable to hold at least
| |
| eof | back to summary |
|---|---|
| public abstract boolean eof() Is this tree iterator at its EOF point (no more entries)? An iterator is at EOF if there is no current entry.
| |
| findFile | back to summary |
|---|---|
| public boolean findFile(String name) throws CorruptObjectException Seek the iterator on a file, if present.
| |
| findFile | back to summary |
|---|---|
| public boolean findFile(byte[] name) throws CorruptObjectException Seek the iterator on a file, if present.
| |
| first | back to summary |
|---|---|
| public abstract boolean first() Is this tree iterator positioned on its first entry?
An iterator is positioned on the first entry if
An empty iterator (one with no entries) will be
| |
| getEntryFileMode | back to summary |
|---|---|
| public FileMode getEntryFileMode() Get the file mode of the current entry.
| |
| getEntryObjectId | back to summary |
|---|---|
| public ObjectId getEntryObjectId() Get the object id of the current entry.
| |
| getEntryObjectId | back to summary |
|---|---|
| public void getEntryObjectId(MutableObjectId out) Obtain the ObjectId for the current entry.
| |
| getEntryPathBuffer | back to summary |
|---|---|
| public byte[] getEntryPathBuffer() Get the current entry path buffer.
Note that the returned byte[] has to be used together with
| |
| getEntryPathHashCode | back to summary |
|---|---|
| public int getEntryPathHashCode() Get the current entry's path hash code. This method computes a hash code on the fly for this path, the hash is suitable to cluster objects that may have similar paths together.
| |
| getEntryPathLength | back to summary |
|---|---|
| public int getEntryPathLength() Get length of the path in
| |
| getEntryPathString | back to summary |
|---|---|
| public String getEntryPathString() Get path of the current entry, as a string.
| |
| getEntryRawMode | back to summary |
|---|---|
| public int getEntryRawMode() Get the file mode of the current entry as bits.
| |
| getName | back to summary |
|---|---|
| public void getName(byte[] buffer, int offset) Get the name component of the current entry path into the provided buffer.
| |
| getNameLength | back to summary |
|---|---|
| public int getNameLength() Get the length of the name component of the path for the current entry.
| |
| getNameOffset | back to summary |
|---|---|
| public int getNameOffset() JGit internal API for use by
| |
| growPath | back to summary |
|---|---|
| protected void growPath(int len) Grow the path buffer larger.
| |
| hasId | back to summary |
|---|---|
| public abstract boolean hasId() Whether the entry has a valid ObjectId.
| |
| idBuffer | back to summary |
|---|---|
| public abstract byte[] idBuffer() Get the byte array buffer object IDs must be copied out of. The id buffer contains the bytes necessary to construct an ObjectId for the current entry of this iterator. The buffer can be the same buffer for all entries, or it can be a unique buffer per-entry. Implementations are encouraged to expose their private buffer whenever possible to reduce garbage generation and copying costs.
| |
| idEqual | back to summary |
|---|---|
| public boolean idEqual(AbstractTreeIterator otherIterator) Check if the current entry of both iterators has the same id.
This method is faster than
| |
| idOffset | back to summary |
|---|---|
| public abstract int idOffset() Get the position within
| |
| isWorkTree | back to summary |
|---|---|
| public boolean isWorkTree() Whether or not this Iterator is iterating through the working tree.
| |
| needsStopWalk | back to summary |
|---|---|
| protected boolean needsStopWalk() Whether the iterator implements
| |
| next | back to summary |
|---|---|
| public abstract void next(int delta) throws CorruptObjectException Move to next entry, populating this iterator with the entry data. The delta indicates how many moves forward should occur. The most common delta is 1 to move to the next entry. Implementations must populate the following members:
idBuffer() and idOffset()
when demanded.
| |
| pathCompare | back to summary |
|---|---|
| public int pathCompare(AbstractTreeIterator p) Compare the path of this current entry to another iterator's entry.
| |
| pathCompare | back to summary |
|---|---|
| pack-priv int pathCompare(AbstractTreeIterator p, int pMode) | |
| pathCompare | back to summary |
|---|---|
| public int pathCompare(byte[] buf, int pos, int end, int pathMode) Compare the path of this current entry to a raw buffer.
| |
| pathCompare | back to summary |
|---|---|
| private int pathCompare(byte[] b, int bPos, int bEnd, int bMode, int aPos) | |
| reset | back to summary |
|---|---|
| public void reset() throws CorruptObjectException Position this iterator on the first entry.
The default implementation of this method uses
| |
| setPathCapacity | back to summary |
|---|---|
| private void setPathCapacity(int capacity, int len) Set path buffer capacity to the specified size
| |
| skip | back to summary |
|---|---|
| public void skip() throws CorruptObjectException Advance to the next tree entry, populating this iterator with its data.
This method behaves like
| |
| stopWalk | back to summary |
|---|---|
| public void stopWalk() Indicates to the iterator that no more entries will be read.
This is only invoked by TreeWalk when the iteration is aborted early due
to a | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non-
| |