com.myJava.file.iterator
Class FileSystemIterator

java.lang.Object
  extended by com.myJava.file.iterator.FileSystemIterator
All Implemented Interfaces:
java.util.Iterator

public class FileSystemIterator
extends java.lang.Object
implements java.util.Iterator

This iterator lists all elements of a source directory. They can be either files or subdirectories. Subdirectories are processed recursively.
The iterator can iterate following the path's components lexicographic order if the "sorted" attribute is set to "true".
It also ensures that all parents of a file returned by the "next" method have been previously returned.

Author:
Olivier PETRUCCI

Areca Build ID : 7299034069467778562

Field Summary
protected  java.io.File baseDirectory
           
protected  FileSystemIterator currentFileSystemSubIterator
           
protected  FileSystemLevel currentLevel
           
protected  long directories
           
protected  long files
           
protected  java.util.Stack fileSystemLevels
           
protected  FileSystemIteratorFilter filter
           
protected  long filtered
           
protected  boolean followSubdirectories
           
protected  boolean followSymLinks
           
protected  boolean forceAllDirectories
           
protected  boolean initialized
           
protected  boolean logProgress
           
protected  TaskMonitor monitor
           
protected  java.io.File nextCachedFile
           
protected  java.util.Stack priorFiles
           
protected  java.util.Set pushedRoots
           
protected  java.io.File root
           
protected  boolean sorted
           
protected  long sourceCount
           
protected  java.util.Iterator sourceIterator
           
protected  boolean warnDanglingLinks
           
 
Constructor Summary
FileSystemIterator(java.io.File baseDirectory, boolean followSymLinks, boolean followSubdirectories, boolean returnEmptyDirectories, boolean sorted)
           
FileSystemIterator(java.io.File root, java.lang.String[] sources, boolean followSymLinks, boolean followSubdirectories, boolean returnEmptyDirectories, boolean sorted)
           
 
Method Summary
 long getDirectories()
           
 long getFiles()
           
 long getFiltered()
          Return the total number of files that have been filtered
 boolean hasNext()
           
 boolean isLogProgress()
           
 java.lang.Object next()
          Same as nextFile()
 java.io.File nextFile()
          Returns the next file
 void remove()
           
 void setFilter(FileSystemIteratorFilter filter)
           
 void setLogProgress(boolean logProgress)
           
 void setMonitor(TaskMonitor monitor)
           
 void setWarnDanglingLinks(boolean warnDanglingLinks)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filter

protected FileSystemIteratorFilter filter

root

protected java.io.File root

baseDirectory

protected java.io.File baseDirectory

followSymLinks

protected boolean followSymLinks

followSubdirectories

protected boolean followSubdirectories

forceAllDirectories

protected boolean forceAllDirectories

sorted

protected boolean sorted

monitor

protected TaskMonitor monitor

logProgress

protected boolean logProgress

warnDanglingLinks

protected boolean warnDanglingLinks

currentLevel

protected FileSystemLevel currentLevel

fileSystemLevels

protected java.util.Stack fileSystemLevels

priorFiles

protected java.util.Stack priorFiles

nextCachedFile

protected java.io.File nextCachedFile

sourceIterator

protected java.util.Iterator sourceIterator

currentFileSystemSubIterator

protected FileSystemIterator currentFileSystemSubIterator

filtered

protected long filtered

files

protected long files

directories

protected long directories

sourceCount

protected long sourceCount

initialized

protected boolean initialized

pushedRoots

protected java.util.Set pushedRoots
Constructor Detail

FileSystemIterator

public FileSystemIterator(java.io.File baseDirectory,
                          boolean followSymLinks,
                          boolean followSubdirectories,
                          boolean returnEmptyDirectories,
                          boolean sorted)

FileSystemIterator

public FileSystemIterator(java.io.File root,
                          java.lang.String[] sources,
                          boolean followSymLinks,
                          boolean followSubdirectories,
                          boolean returnEmptyDirectories,
                          boolean sorted)
Method Detail

setWarnDanglingLinks

public void setWarnDanglingLinks(boolean warnDanglingLinks)

setMonitor

public void setMonitor(TaskMonitor monitor)

setFilter

public void setFilter(FileSystemIteratorFilter filter)

isLogProgress

public boolean isLogProgress()

setLogProgress

public void setLogProgress(boolean logProgress)

getFiltered

public long getFiltered()
Return the total number of files that have been filtered


getFiles

public long getFiles()

getDirectories

public long getDirectories()

next

public java.lang.Object next()
Same as nextFile()

Specified by:
next in interface java.util.Iterator

nextFile

public java.io.File nextFile()
Returns the next file


hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator

remove

public void remove()
Specified by:
remove in interface java.util.Iterator