net.sourceforge.jinit
Class Directory

java.lang.Object
  extended by net.sourceforge.jinit.Directory

public class Directory
extends Object

Represents a directory in a file system with sub-directories. In this way a hierarchy of directories can be represented with an easy way to create the directories.

Author:
Trevor Miller

Constructor Summary
Directory(String name)
          Create a new directory with the given name.
 
Method Summary
 void addSubDirectory(Directory directory)
          Add a sub directory to this directory.
 void addSubDirectory(String name)
          Add a sub directory to this directory.
 int count()
          Return the number of sub directories.
 void createIn(File parentDir)
          Create this directory and all its sub-directories within the given directory.
 Directory get(int index)
          Return the sub directory at the given index.
 String getName()
          Return the name of this directory
 Directory getSubDirectory(String name)
          Return the directory instance within this directory that matches the given name.
 void removeSubDirectory(Directory directory)
          Remove a directory from this one.
 void removeSubDirectory(String name)
          Remove a directory from this one.
 Directory search(String name)
          Search for a directory within this directory and all its sub directories.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Directory

public Directory(String name)
Create a new directory with the given name.

Parameters:
name - The name of the directory
Method Detail

count

public int count()
Return the number of sub directories.

Returns:
Number of sub directories

get

public Directory get(int index)
Return the sub directory at the given index.

Parameters:
index - The position of the sub directory
Returns:
Directory at given position

createIn

public void createIn(File parentDir)
Create this directory and all its sub-directories within the given directory.

Parameters:
parentDir - The directory to create this one in

addSubDirectory

public void addSubDirectory(Directory directory)
Add a sub directory to this directory.

Parameters:
directory - The directory to add

addSubDirectory

public void addSubDirectory(String name)
Add a sub directory to this directory. This is essentially the same as addSubDirectory(new Directory(name));

Parameters:
name - The name of the directory to add

removeSubDirectory

public void removeSubDirectory(Directory directory)
Remove a directory from this one.

Parameters:
directory - The directory to remove

removeSubDirectory

public void removeSubDirectory(String name)
Remove a directory from this one.

Parameters:
name - The name of the directory to remove

getSubDirectory

public Directory getSubDirectory(String name)
Return the directory instance within this directory that matches the given name. If no such directory exists, null is returned.

Parameters:
name - The name of the directory to return
Returns:
The directory or null if not found

getName

public String getName()
Return the name of this directory

Returns:
The name of this directory

search

public Directory search(String name)
Search for a directory within this directory and all its sub directories. If no directory is found, null is returned.

Parameters:
name - The name of the directory to search for.
Returns:
The directory matching the given name


Copyright © 2005 JInit Project. All Rights Reserved.