net.chaosserver.bilbo.data
Class Directory

java.lang.Object
  |
  +--net.chaosserver.bilbo.data.Directory

public class Directory
extends Object

Directory object represents the mappings contained in a single directory.

Holds a collection of FilenameMapping objects that represent the files in the directory that need to be mapped.

Since:
Bilbo 1.0

Field Summary
protected  Collection filenameMappings
          Holds the collection of FilenameMappings in this directory.
protected  String name
          Name of the directory.
protected  Collection subdirectories
          Holds the collection of DirectoryMappings in this directory.
 
Constructor Summary
Directory()
          Default constructor.
 
Method Summary
 void addFilenameMapping(FilenameMapping filenameMapping)
          Adds a new FilenameMapping object to this directory.
 void addSubdirectory(Directory subdirectory)
          Adds a new directory object to this directory.
 FilenameMapping findFilenameMapping(String style, String value)
          Finds a FilenameMapping held in this Directory.
 FilenameMapping findFilenameMappingByValue(String value)
          Finds a filenameMapping help in the directory.
static Directory getDirectory(File mappingFile)
          Unmarshall a directory object from a mapping file.
 Collection getFilenameMappings()
          Getter method for the filename mappings.
 String getName()
          Getter for the name of the directory.
 Collection getSubdirectories()
          Getter method for the subdirectories.
 void removeFilenameMapping(FilenameMapping filenameMapping)
          Removes a filenameMapping fromt the directory.
 void setFilenameMappings(Collection filenameMappings)
          Setter method for the filename mappings.
 void setName(String name)
          Setter for the name of the directory.
 void setSubdirectories(Collection subdirectories)
          Setter method for the subdirectories.
 int size()
          Returns the number of filenameMappings in this directory.
 String toString()
          Converts the object to string representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected String name
Name of the directory.


filenameMappings

protected Collection filenameMappings
Holds the collection of FilenameMappings in this directory.


subdirectories

protected Collection subdirectories
Holds the collection of DirectoryMappings in this directory.

Constructor Detail

Directory

public Directory()
Default constructor.

Method Detail

getDirectory

public static Directory getDirectory(File mappingFile)
                              throws NoMappingFileException,
                                     ReaderWriterException
Unmarshall a directory object from a mapping file.

Parameters:
mappingFile - mapping file to unmarshall
Returns:
directory object held in the file
Throws:
NoMappingFileException - if the mapping file does not exist
ReaderWriterException - if an error occurs attempting to unmarshall the file

setName

public void setName(String name)
Setter for the name of the directory.

Parameters:
name - the name of the directory.

getName

public String getName()
Getter for the name of the directory.

Returns:
the name of the directory

setFilenameMappings

public void setFilenameMappings(Collection filenameMappings)
Setter method for the filename mappings.

Parameters:
filenameMappings - the value of filenameMappings

getFilenameMappings

public Collection getFilenameMappings()
Getter method for the filename mappings.

Returns:
the value of filenameMappings

setSubdirectories

public void setSubdirectories(Collection subdirectories)
Setter method for the subdirectories.

Parameters:
subdirectories - the value of subdirectories

getSubdirectories

public Collection getSubdirectories()
Getter method for the subdirectories.

Returns:
the value of subdirectories

addFilenameMapping

public void addFilenameMapping(FilenameMapping filenameMapping)
Adds a new FilenameMapping object to this directory.

Parameters:
filenameMapping - the new FilenameMapping to add

removeFilenameMapping

public void removeFilenameMapping(FilenameMapping filenameMapping)
                           throws FilenameMappingNotFoundException
Removes a filenameMapping fromt the directory.

Parameters:
filenameMapping - the mapping to remove from the directory
Throws:
FilenameMappingNotFoundException - indicates the mapping passed int is not contained in the directory

addSubdirectory

public void addSubdirectory(Directory subdirectory)
Adds a new directory object to this directory.

Parameters:
subdirectory - the new directory to add

findFilenameMappingByValue

public FilenameMapping findFilenameMappingByValue(String value)
                                           throws FilenameMappingNotFoundException
Finds a filenameMapping help in the directory.

Parameters:
value - the value of the mapping to find
Returns:
the mapping associated with the value passed in
Throws:
FilenameMappingNotFoundException - indicated the mapping cannot be found

findFilenameMapping

public FilenameMapping findFilenameMapping(String style,
                                           String value)
                                    throws FilenameMappingNotFoundException
Finds a FilenameMapping held in this Directory.

Parameters:
style - the style of the filename being searched for
value - the value of the filename being searched for
Returns:
the filenameMapping associated with the sytle and value passed in
Throws:
FilenameMappingNotFoundException - if the mapping cannot be found

size

public int size()
Returns the number of filenameMappings in this directory.

Returns:
number of filenameMappings in this directory.

toString

public String toString()
Converts the object to string representation.

Overrides:
toString in class Object
Returns:
a string representation of the object


Copyright © 20030415