|
||||||||||
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.treewalk.WorkingTreeIterator
public abstract class WorkingTreeIterator
Walks a working directory tree as part of a TreeWalk
.
Most applications will want to use the standard implementation of this
iterator, FileTreeIterator
, as that does all IO through the standard
java.io
package. Plugins for a Java based IDE may however wish
to create their own implementations of this class to allow traversal of the
IDE's project space, as well as benefit from any caching the IDE may have.
FileTreeIterator
Nested Class Summary | |
---|---|
protected static class |
WorkingTreeIterator.Entry
A single entry within a working directory tree. |
static class |
WorkingTreeIterator.MetadataDiff
The result of a metadata-comparison between the current entry and a DirCacheEntry |
Field Summary | |
---|---|
protected static WorkingTreeIterator.Entry[] |
EOF
An empty entry array, suitable for init(Entry[]) . |
protected Repository |
repository
Repository that is the root level being iterated over |
Fields inherited from class org.eclipse.jgit.treewalk.AbstractTreeIterator |
---|
DEFAULT_PATH_SIZE, mode, path, pathLen, pathOffset, zeroid |
Constructor Summary | |
---|---|
protected |
WorkingTreeIterator(String prefix,
WorkingTreeOptions options)
Create a new iterator with no parent and a prefix. |
protected |
WorkingTreeIterator(WorkingTreeIterator p)
Create an iterator for a subtree of an existing iterator. |
protected |
WorkingTreeIterator(WorkingTreeOptions options)
Create a new iterator with no parent. |
Method Summary | |
---|---|
void |
back(int delta)
Move to prior entry, populating this iterator with the entry data. |
WorkingTreeIterator.MetadataDiff |
compareMetadata(DirCacheEntry entry)
Compare the metadata (mode, length, modification-timestamp) of the current entry and a DirCacheEntry |
protected WorkingTreeIterator.Entry |
current()
Obtain the current entry from this iterator. |
boolean |
eof()
Is this tree iterator at its EOF point (no more entries)? |
boolean |
first()
Is this tree iterator positioned on its first entry? |
long |
getEntryContentLength()
Get the filtered input length of this entry |
long |
getEntryLastModified()
Get the last modified time of this entry. |
long |
getEntryLength()
Get the raw byte length of this entry. |
FileMode |
getIndexFileMode(DirCacheIterator indexIter)
Get the file mode to use for the current entry when it is to be updated in the index. |
WorkingTreeOptions |
getOptions()
Returns the working tree options used by this iterator. |
boolean |
hasId()
|
byte[] |
idBuffer()
Get the byte array buffer object IDs must be copied out of. |
int |
idOffset()
Get the position within AbstractTreeIterator.idBuffer() of this entry's ObjectId. |
protected byte[] |
idSubmodule(File directory,
WorkingTreeIterator.Entry e)
Get submodule id using the repository at the location of the entry relative to the directory. |
protected byte[] |
idSubmodule(WorkingTreeIterator.Entry e)
Get submodule id for given entry. |
protected void |
init(WorkingTreeIterator.Entry[] list)
Constructor helper. |
protected void |
initRootIterator(Repository repo)
Initialize this iterator for the root level of a repository. |
boolean |
isEntryIgnored()
Determine if the current entry path is ignored by an ignore rule. |
protected boolean |
isEntryIgnored(int pLen)
Determine if the entry path is ignored by an ignore rule. |
boolean |
isModeDifferent(int rawMode)
Is the file mode of the current entry different than the given raw mode? |
boolean |
isModified(DirCacheEntry entry,
boolean forceContentCheck)
Checks whether this entry differs from a given entry from the DirCache . |
void |
next(int delta)
Move to next entry, populating this iterator with the entry data. |
InputStream |
openEntryStream()
Obtain an input stream to read the file content. |
void |
reset()
Position this iterator on the first entry. |
void |
setDirCacheIterator(TreeWalk walk,
int treeId)
Define the matching DirCacheIterator , to optimize ObjectIds. |
Methods inherited from class org.eclipse.jgit.treewalk.AbstractTreeIterator |
---|
createEmptyTreeIterator, createSubtreeIterator, createSubtreeIterator, ensurePathCapacity, getEntryFileMode, getEntryObjectId, getEntryObjectId, getEntryPathBuffer, getEntryPathHashCode, getEntryPathLength, getEntryPathString, getEntryRawMode, getName, getNameLength, getNameOffset, growPath, idEqual, pathCompare, pathCompare, skip, stopWalk, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final WorkingTreeIterator.Entry[] EOF
init(Entry[])
.
protected Repository repository
Constructor Detail |
---|
protected WorkingTreeIterator(WorkingTreeOptions options)
options
- working tree options to be usedprotected WorkingTreeIterator(String prefix, WorkingTreeOptions options)
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.
prefix
- 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 '/'.options
- working tree options to be usedprotected WorkingTreeIterator(WorkingTreeIterator p)
p
- parent tree iterator.Method Detail |
---|
protected void initRootIterator(Repository repo)
This method should only be invoked after calling init(Entry[])
,
and only for the root iterator.
repo
- the repository.public void setDirCacheIterator(TreeWalk walk, int treeId)
DirCacheIterator
, to optimize ObjectIds.
Once the DirCacheIterator has been set this iterator must only be
advanced by the TreeWalk that is supplied, as it assumes that itself and
the corresponding DirCacheIterator are positioned on the same file path
whenever idBuffer()
is invoked.
walk
- the walk that will be advancing this iterator.treeId
- index of the matching DirCacheIterator
.public boolean hasId()
hasId
in class AbstractTreeIterator
public byte[] idBuffer()
AbstractTreeIterator
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.
idBuffer
in class AbstractTreeIterator
AbstractTreeIterator.getEntryObjectId()
protected byte[] idSubmodule(WorkingTreeIterator.Entry e)
e
-
protected byte[] idSubmodule(File directory, WorkingTreeIterator.Entry e)
directory
- e
-
public WorkingTreeOptions getOptions()
public int idOffset()
AbstractTreeIterator
AbstractTreeIterator.idBuffer()
of this entry's ObjectId.
idOffset
in class AbstractTreeIterator
AbstractTreeIterator.idBuffer()
where the
ObjectId must be copied out of.public void reset()
AbstractTreeIterator
back(1)
until
first()
is true. This is most likely not the most efficient
method of repositioning the iterator to its first entry, so subclasses
are strongly encouraged to override the method.
reset
in class AbstractTreeIterator
public boolean first()
AbstractTreeIterator
An iterator is positioned on the first entry if back(1)
would be an invalid request as there is no entry before the current one.
An empty iterator (one with no entries) will be
first() && eof()
.
first
in class AbstractTreeIterator
public boolean eof()
AbstractTreeIterator
An iterator is at EOF if there is no current entry.
eof
in class AbstractTreeIterator
public void next(int delta) throws CorruptObjectException
AbstractTreeIterator
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:
AbstractTreeIterator.mode
AbstractTreeIterator.path
(from AbstractTreeIterator.pathOffset
to AbstractTreeIterator.pathLen
)AbstractTreeIterator.pathLen
AbstractTreeIterator.idBuffer()
and AbstractTreeIterator.idOffset()
when demanded.
next
in class AbstractTreeIterator
delta
- number of entries to move the iterator by. Must be a positive,
non-zero integer.
CorruptObjectException
- the tree is invalid.public void back(int delta) throws CorruptObjectException
AbstractTreeIterator
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:
AbstractTreeIterator.mode
AbstractTreeIterator.path
(from AbstractTreeIterator.pathOffset
to AbstractTreeIterator.pathLen
)AbstractTreeIterator.pathLen
AbstractTreeIterator.idBuffer()
and AbstractTreeIterator.idOffset()
when demanded.
back
in class AbstractTreeIterator
delta
- number of entries to move the iterator by. Must be a positive,
non-zero integer.
CorruptObjectException
- the tree is invalid.public long getEntryLength()
public long getEntryContentLength() throws IOException
IOException
public long getEntryLastModified()
public InputStream openEntryStream() throws IOException
Efficient implementations are not required. The caller will usually obtain the stream only once per entry, if at all.
The input stream should not use buffering if the implementation can avoid it. The caller will buffer as necessary to perform efficient block IO operations.
The caller will close the stream once complete.
IOException
- the file could not be opened for reading.public boolean isEntryIgnored() throws IOException
IOException
- a relevant ignore rule file exists but cannot be read.protected boolean isEntryIgnored(int pLen) throws IOException
pLen
- the length of the path in the path buffer.
IOException
- a relevant ignore rule file exists but cannot be read.protected void init(WorkingTreeIterator.Entry[] list)
list
- files in the subtree of the work tree this iterator operates
onprotected WorkingTreeIterator.Entry current()
public boolean isModeDifferent(int rawMode)
rawMode
-
public WorkingTreeIterator.MetadataDiff compareMetadata(DirCacheEntry entry)
DirCacheEntry
entry
- the DirCacheEntry
to compare with
WorkingTreeIterator.MetadataDiff
which tells whether and how the entries
metadata differpublic boolean isModified(DirCacheEntry entry, boolean forceContentCheck)
DirCache
.
File status information is used and if status is same we consider the
file identical to the state in the working directory. Native git uses
more stat fields than we have accessible in Java.
entry
- the entry from the dircache we want to compare againstforceContentCheck
- True if the actual file content should be checked if
modification time differs.
public FileMode getIndexFileMode(DirCacheIterator indexIter)
indexIter
- DirCacheIterator
positioned at the same entry as this
iterator or null if no DirCacheIterator
is available
at this iterator's current entry
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |