Top Description Fields Constructors Methods
org.eclipse.jgit.dircache

public Class DirCacheBuildIterator

extends DirCacheIterator
Class Inheritance
Imports
java.io.IOException, org.eclipse.jgit.errors.CorruptObjectException, .IncorrectObjectTypeException, org.eclipse.jgit.lib.Constants, .ObjectReader, org.eclipse.jgit.treewalk.AbstractTreeIterator

Iterate and update a org.eclipse.jgit.dircache.DirCache as part of a TreeWalk.

Like org.eclipse.jgit.dircache.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 org.eclipse.jgit.dircache.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

Modifier and TypeField and Description
private final DirCacheBuilder
Inherited from org.eclipse.jgit.dircache.DirCacheIterator:
cachecurrentEntrycurrentSubtreeptr

Constructor Summary

AccessConstructor and Description
public
DirCacheBuildIterator(DirCacheBuilder
the cache builder for the cache to walk. The cache must be already loaded into memory.
dcb
)

Create a new iterator for an already loaded DirCache instance.

pack-priv

Method Summary

Modifier and TypeMethod and Description
public AbstractTreeIterator
createSubtreeIterator(ObjectReader
reader to load the tree data from.
reader
)

Overrides org.eclipse.jgit.dircache.DirCacheIterator.createSubtreeIterator.

Create a new iterator for the current entry's subtree.

protected boolean
public void
skip()

Overrides org.eclipse.jgit.treewalk.AbstractTreeIterator.skip.

Advance to the next tree entry, populating this iterator with its data.

public void
stopWalk()

Overrides org.eclipse.jgit.treewalk.AbstractTreeIterator.stopWalk.

Indicates to the iterator that no more entries will be read.

Inherited from org.eclipse.jgit.dircache.DirCacheIterator:
backcreateEmptyTreeIteratoreoffirstgetDirCacheEntrygetEntryAttributesNodehasIdidBufferidOffsetnextreset

Field Detail

builderback to summary
private final DirCacheBuilder builder

Constructor Detail

DirCacheBuildIteratorback to summary
public DirCacheBuildIterator(DirCacheBuilder dcb)

Create a new iterator for an already loaded DirCache instance.

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.

Parameters
dcb:DirCacheBuilder

the cache builder for the cache to walk. The cache must be already loaded into memory.

DirCacheBuildIteratorback to summary
pack-priv DirCacheBuildIterator(final DirCacheBuildIterator p, final DirCacheTree dct)

Method Detail

createSubtreeIteratorback to summary
public AbstractTreeIterator createSubtreeIterator(ObjectReader reader) throws IncorrectObjectTypeException, IOException

Overrides org.eclipse.jgit.dircache.DirCacheIterator.createSubtreeIterator.

Doc from org.eclipse.jgit.treewalk.AbstractTreeIterator.createSubtreeIterator.

Create a new iterator for the current entry's subtree.

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.

Parameters
reader:ObjectReader

reader to load the tree data from.

Returns:AbstractTreeIterator

a new parser that walks over the current subtree.

Annotations
@Override
Exceptions
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.
needsStopWalkback to summary
protected boolean needsStopWalk()

Overrides org.eclipse.jgit.treewalk.AbstractTreeIterator.needsStopWalk.

Doc from org.eclipse.jgit.treewalk.AbstractTreeIterator.needsStopWalk.

Whether the iterator implements stopWalk().

Returns:boolean

true if the iterator implements stopWalk().

Annotations
@Override
skipback to summary
public void skip() throws CorruptObjectException

Overrides org.eclipse.jgit.treewalk.AbstractTreeIterator.skip.

Doc from org.eclipse.jgit.treewalk.AbstractTreeIterator.skip.

Advance to the next tree entry, populating this iterator with its data.

This method behaves like seek(1) but is called by org.eclipse.jgit.treewalk.TreeWalk only if a org.eclipse.jgit.treewalk.filter.TreeFilter was used and ruled out the current entry from the results. In such cases this tree iterator may perform special behavior.

Annotations
@Override
Exceptions
CorruptObjectException:
the tree is invalid.
stopWalkback to summary
public void stopWalk()

Overrides org.eclipse.jgit.treewalk.AbstractTreeIterator.stopWalk.

Doc from org.eclipse.jgit.treewalk.AbstractTreeIterator.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 org.eclipse.jgit.errors.StopWalkException being thrown from within a TreeFilter.

Annotations
@Override