org.apache.tools.ant.taskdefs.optional.ssh

Class Directory

public class Directory extends Object

A helper object for Scp representing a directory in a file system.
Constructor Summary
Directory(File directory)
Constructor for a Directory.
Directory(File directory, Directory parent)
Constructor for a Directory.
Method Summary
voidaddDirectory(Directory directory)
Add a directory to the child directories.
voidaddFile(File file)
Add a file to the list of files.
IteratordirectoryIterator()
Get an iterator over the child Directories.
booleanequals(Object obj)
The equality method.
IteratorfilesIterator()
Get an iterator over the files.
intfileSize()
Get the number of files in the files attribute.
DirectorygetChild(File dir)
Get a child directory of this directory.
FilegetDirectory()
Get the directory file.
DirectorygetParent()
Get the parent Directory.
String[]getPath()
Get the path components of this directory.
static String[]getPath(String thePath)
Convert a file path to an array of path components.
inthashCode()
The hashcode method.
booleanisRoot()
Is this a root Directory?

Constructor Detail

Directory

public Directory(File directory)
Constructor for a Directory.

Parameters: directory a directory.

Directory

public Directory(File directory, Directory parent)
Constructor for a Directory.

Parameters: directory a directory parent a parent Directory

Method Detail

addDirectory

public void addDirectory(Directory directory)
Add a directory to the child directories.

Parameters: directory a Directory

addFile

public void addFile(File file)
Add a file to the list of files.

Parameters: file a file to add

directoryIterator

public Iterator directoryIterator()
Get an iterator over the child Directories.

Returns: an iterator

equals

public boolean equals(Object obj)
The equality method. This checks if the directory field is the same.

Parameters: obj the object to compare to

Returns: true if this object has an equal directory field as the other object

filesIterator

public Iterator filesIterator()
Get an iterator over the files.

Returns: an iterator

fileSize

public int fileSize()
Get the number of files in the files attribute.

Returns: the number of files

getChild

public Directory getChild(File dir)
Get a child directory of this directory.

Parameters: dir the directory to look for

Returns: the child directory, or null if not found

getDirectory

public File getDirectory()
Get the directory file.

Returns: the directory file

getParent

public Directory getParent()
Get the parent Directory.

Returns: the parent Directory.

getPath

public String[] getPath()
Get the path components of this directory.

Returns: the path components as an array of strings.

getPath

public static String[] getPath(String thePath)
Convert a file path to an array of path components. This uses File.sepatator to split the file path string.

Parameters: thePath the file path string to convert

Returns: an array of path components

hashCode

public int hashCode()
The hashcode method.

Returns: the hash code of the directory field

isRoot

public boolean isRoot()
Is this a root Directory?

Returns: true if there is no parent Directory