|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jgit.treewalk.AbstractTreeIterator
org.eclipse.jgit.dircache.DirCacheIterator
org.eclipse.jgit.dircache.DirCacheBuildIterator
public class DirCacheBuildIterator
Iterate and update a DirCache
as part of a TreeWalk
.
Like DirCacheIterator
this iterator allows a DirCache to be used in
parallel with other sorts of iterators in a TreeWalk. However any entry which
appears in the source DirCache and which is skipped by the TreeFilter is
automatically copied into DirCacheBuilder
, thus retaining it in the
newly updated index.
This iterator is suitable for update processes, or even a simple delete algorithm. For example deleting a path:
final DirCache dirc = db.lockDirCache(); final DirCacheBuilder edit = dirc.builder(); final TreeWalk walk = new TreeWalk(db); walk.reset(); walk.setRecursive(true); walk.setFilter(PathFilter.create("name/to/remove")); walk.addTree(new DirCacheBuildIterator(edit)); while (walk.next()) ; // do nothing on a match as we want to remove matches edit.commit();
Field Summary |
---|
Fields inherited from class org.eclipse.jgit.dircache.DirCacheIterator |
---|
cache, currentEntry, currentSubtree, ptr |
Fields inherited from class org.eclipse.jgit.treewalk.AbstractTreeIterator |
---|
DEFAULT_PATH_SIZE, mode, path, pathLen, pathOffset, zeroid |
Constructor Summary | |
---|---|
DirCacheBuildIterator(DirCacheBuilder dcb)
Create a new iterator for an already loaded DirCache instance. |
Method Summary | |
---|---|
AbstractTreeIterator |
createSubtreeIterator(ObjectReader reader)
Create a new iterator for the current entry's subtree. |
void |
skip()
Advance to the next tree entry, populating this iterator with its data. |
void |
stopWalk()
Indicates to the iterator that no more entries will be read. |
Methods inherited from class org.eclipse.jgit.dircache.DirCacheIterator |
---|
back, createEmptyTreeIterator, eof, first, getDirCacheEntry, hasId, idBuffer, idOffset, next, reset |
Methods inherited from class org.eclipse.jgit.treewalk.AbstractTreeIterator |
---|
createSubtreeIterator, ensurePathCapacity, getEntryFileMode, getEntryObjectId, getEntryObjectId, getEntryPathBuffer, getEntryPathHashCode, getEntryPathLength, getEntryPathString, getEntryRawMode, getName, getNameLength, getNameOffset, growPath, idEqual, pathCompare, pathCompare, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DirCacheBuildIterator(DirCacheBuilder dcb)
The iterator implementation may copy part of the cache's data during construction, so the cache must be read in prior to creating the iterator.
dcb
- the cache builder for the cache to walk. The cache must be
already loaded into memory.Method Detail |
---|
public AbstractTreeIterator createSubtreeIterator(ObjectReader reader) throws IncorrectObjectTypeException, IOException
AbstractTreeIterator
The parent reference of the iterator must be this
,
otherwise the caller would not be able to exit out of the subtree
iterator correctly and return to continue walking this
.
createSubtreeIterator
in class DirCacheIterator
reader
- reader to load the tree data from.
IncorrectObjectTypeException
- the current entry is not actually a tree and cannot be parsed
as though it were a tree.
IOException
- a loose object or pack file could not be read.public void skip() throws CorruptObjectException
AbstractTreeIterator
This method behaves like seek(1)
but is called by
TreeWalk
only if a TreeFilter
was used and ruled out the
current entry from the results. In such cases this tree iterator may
perform special behavior.
skip
in class AbstractTreeIterator
CorruptObjectException
- the tree is invalid.public void stopWalk()
AbstractTreeIterator
This is only invoked by TreeWalk when the iteration is aborted early due
to a StopWalkException
being thrown from
within a TreeFilter.
stopWalk
in class AbstractTreeIterator
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |