org.eclipse.jgit.treewalk
Class FileTreeIterator

java.lang.Object
  extended by org.eclipse.jgit.treewalk.AbstractTreeIterator
      extended by org.eclipse.jgit.treewalk.WorkingTreeIterator
          extended by org.eclipse.jgit.treewalk.FileTreeIterator

public class FileTreeIterator
extends WorkingTreeIterator

Working directory iterator for standard Java IO.

This iterator uses the standard java.io package to read the specified working directory as part of a TreeWalk.


Nested Class Summary
static class FileTreeIterator.FileEntry
          Wrapper for a standard Java IO file
 
Nested classes/interfaces inherited from class org.eclipse.jgit.treewalk.WorkingTreeIterator
WorkingTreeIterator.Entry, WorkingTreeIterator.MetadataDiff
 
Field Summary
protected  File directory
          the starting directory.
protected  FS fs
          the file system abstraction which will be necessary to perform certain file system operations.
 
Fields inherited from class org.eclipse.jgit.treewalk.WorkingTreeIterator
EOF, repository
 
Fields inherited from class org.eclipse.jgit.treewalk.AbstractTreeIterator
DEFAULT_PATH_SIZE, mode, path, pathLen, pathOffset, zeroid
 
Constructor Summary
  FileTreeIterator(File root, FS fs, WorkingTreeOptions options)
          Create a new iterator to traverse the given directory and its children.
protected FileTreeIterator(FileTreeIterator p, File root, FS fs)
          Create a new iterator to traverse a subdirectory.
  FileTreeIterator(Repository repo)
          Create a new iterator to traverse the work tree and its children.
 
Method Summary
 AbstractTreeIterator createSubtreeIterator(ObjectReader reader)
          Create a new iterator for the current entry's subtree.
 File getDirectory()
           
 File getEntryFile()
           
protected  byte[] idSubmodule(WorkingTreeIterator.Entry e)
          Get submodule id for given entry.
 
Methods inherited from class org.eclipse.jgit.treewalk.WorkingTreeIterator
back, compareMetadata, current, eof, first, getEntryContentLength, getEntryLastModified, getEntryLength, getIndexFileMode, getOptions, hasId, idBuffer, idOffset, idSubmodule, init, initRootIterator, isEntryIgnored, isEntryIgnored, isModeDifferent, isModified, next, openEntryStream, reset, setDirCacheIterator
 
Methods inherited from class org.eclipse.jgit.treewalk.AbstractTreeIterator
createEmptyTreeIterator, createSubtreeIterator, ensurePathCapacity, getEntryFileMode, getEntryObjectId, getEntryObjectId, getEntryPathBuffer, getEntryPathHashCode, getEntryPathLength, getEntryPathString, getEntryRawMode, getName, getNameLength, getNameOffset, growPath, idEqual, pathCompare, pathCompare, skip, stopWalk
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

directory

protected final File directory
the starting directory. This directory should correspond to the root of the repository.


fs

protected final FS fs
the file system abstraction which will be necessary to perform certain file system operations.

Constructor Detail

FileTreeIterator

public FileTreeIterator(Repository repo)
Create a new iterator to traverse the work tree and its children.

Parameters:
repo - the repository whose working tree will be scanned.

FileTreeIterator

public FileTreeIterator(File root,
                        FS fs,
                        WorkingTreeOptions options)
Create a new iterator to traverse the given directory and its children.

Parameters:
root - the starting directory. This directory should correspond to the root of the repository.
fs - the file system abstraction which will be necessary to perform certain file system operations.
options - working tree options to be used

FileTreeIterator

protected FileTreeIterator(FileTreeIterator p,
                           File root,
                           FS fs)
Create a new iterator to traverse a subdirectory.

Parameters:
p - the parent iterator we were created from.
fs - the file system abstraction which will be necessary to perform certain file system operations.
root - the subdirectory. This should be a directory contained within the parent directory.
Method Detail

createSubtreeIterator

public AbstractTreeIterator createSubtreeIterator(ObjectReader reader)
                                           throws IncorrectObjectTypeException,
                                                  IOException
Description copied from class: AbstractTreeIterator
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.

Specified by:
createSubtreeIterator in class AbstractTreeIterator
Parameters:
reader - reader to load the tree data from.
Returns:
a new parser that walks over the current subtree.
Throws:
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.

getDirectory

public File getDirectory()
Returns:
The root directory of this iterator

getEntryFile

public File getEntryFile()
Returns:
The location of the working file. This is the same as new File(getDirectory(), getEntryPath()) but may be faster by reusing an internal File instance.

idSubmodule

protected byte[] idSubmodule(WorkingTreeIterator.Entry e)
Description copied from class: WorkingTreeIterator
Get submodule id for given entry.

Overrides:
idSubmodule in class WorkingTreeIterator
Returns:
non-null submodule id


Copyright © 2012. All Rights Reserved.