javatools.io
Class DirectoryGetter

java.lang.Object
  |
  +--javatools.io.DirectoryGetter
Direct Known Subclasses:
DirectoryScanner

public class DirectoryGetter
extends java.lang.Object

It is a class that can get all files and subdirectories of a given directory.


Field Summary
protected  java.io.File dirRef
          Represents the directory itself.
protected  java.io.File[] fileList
          Represents the list of contained files.
protected  java.io.File[] subdirList
          Represents the list of subdirectories.
 
Constructor Summary
DirectoryGetter()
          Creates new DirectoryGetter
DirectoryGetter(java.io.File dirFile)
          Creates a new DirectoryGetter.
DirectoryGetter(java.lang.String path)
          Creates a new DirectoryGetter.
 
Method Summary
 java.io.File getFile()
          Returns the directory itself.
 java.io.File[] getFiles()
          Returns an array of contained files.
 DirectoryGetter[] getSubdirGetters()
          Returns an array of DirectoryGetter for each subdirectory.
 java.io.File[] getSubdirs()
          Returns an array of subdirectories.
protected  void scanDir()
          Scans the directory to retrieve files and subdirectories.
 void setDirectoryFile(java.io.File dirFile)
          Sets the directory file.
 void setDirectoryPath(java.lang.String path)
          Sets the directory path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

subdirList

protected java.io.File[] subdirList
Represents the list of subdirectories.


fileList

protected java.io.File[] fileList
Represents the list of contained files.


dirRef

protected java.io.File dirRef
Represents the directory itself.

Constructor Detail

DirectoryGetter

public DirectoryGetter()
Creates new DirectoryGetter


DirectoryGetter

public DirectoryGetter(java.io.File dirFile)
Creates a new DirectoryGetter.

Parameters:
dirFile - It represents the directory to scan.

DirectoryGetter

public DirectoryGetter(java.lang.String path)
Creates a new DirectoryGetter.

Parameters:
path - The path of the directory.
Method Detail

getFile

public java.io.File getFile()
Returns the directory itself.

Returns:
The File object representing the directory.

getSubdirs

public java.io.File[] getSubdirs()
                          throws java.io.IOException
Returns an array of subdirectories.

Returns:
The array of subdirectories.
Throws:
java.io.IOException - If something goes wrong.

getFiles

public java.io.File[] getFiles()
                        throws java.io.IOException
Returns an array of contained files.

Returns:
The array of contained files.
Throws:
java.io.IOException - If something goes wrong.

getSubdirGetters

public DirectoryGetter[] getSubdirGetters()
                                   throws java.io.IOException
Returns an array of DirectoryGetter for each subdirectory. It should be used to make recursive scanning.

Returns:
The array of DirectoryGetter, one for each subdirectory.
Throws:
java.io.IOException - If something goes wrong.

setDirectoryFile

public void setDirectoryFile(java.io.File dirFile)
Sets the directory file.

Parameters:
dirFile - The file representing the scanning directory.

setDirectoryPath

public void setDirectoryPath(java.lang.String path)
Sets the directory path.

Parameters:
path - The path of the directory.

scanDir

protected void scanDir()
                throws java.io.IOException
Scans the directory to retrieve files and subdirectories.

Throws:
java.io.IOException - If something goes wrong.