org.schmant.support
Class FutureDirectory

java.lang.Object
  extended by org.schmant.support.AbstractArgumentChecker
      extended by org.schmant.support.FutureEntity
          extended by org.schmant.support.FutureDirectory

public class FutureDirectory
extends FutureEntity

This object is a FutureEntity for future entities that are directories. Using it in build scripts gives a more readable script and a little bit of error checking.

This object should be used mostly by build scripts. Consumers of future entity objects, such as tasks, should use FutureEntity objects.

Since:
0.8
Author:
Karl Gustafsson

Constructor Summary
FutureDirectory(DirectoryView dir)
          Create a future directory representing an existing directory entity.
FutureDirectory(DirectoryView base, RelativeLocation loc)
          Create a new future directory with a relative location against a base directory.
FutureDirectory(DirectoryView parentDir, String name)
          Create a new future directory with a name and a parent directory.
FutureDirectory(File dir)
          Create a future directory representing the referenced directory of a File object.
 
Method Summary
 DirectoryView getEntity()
          Get the directory, creating it if necessary.
 DirectoryView getEntityOrNull()
          Get the directory, returning null if it does not exist.
 EFile getFile()
          Get the file referenced by this future entity, possibly creating it if it does not already exist.
 File getFileObject()
          Get a File object referencing the directory.
 boolean isExistingDirectory()
          Is this future directory referencing an existing directory.
 boolean isExistingFile()
          This method returns false.
 String toString()
           
 
Methods inherited from class org.schmant.support.FutureEntity
exists, getBaseDirectory, getDirectory, getLocation, getName, getParent, getParentOrNull, getRelativeLocation
 
Methods inherited from class org.schmant.support.AbstractArgumentChecker
check, check, check, check
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FutureDirectory

public FutureDirectory(DirectoryView parentDir,
                       String name)
Create a new future directory with a name and a parent directory.

This may reference a directory that already exists.

Parameters:
parentDir - The parent directory.
name -

FutureDirectory

public FutureDirectory(DirectoryView base,
                       RelativeLocation loc)
Create a new future directory with a relative location against a base directory.

This may reference a directory that already exists.

Parameters:
base - The base directory.
loc - The relative location of the directory against the base directory.

FutureDirectory

public FutureDirectory(DirectoryView dir)
Create a future directory representing an existing directory entity.

Parameters:
dir - The directory.

FutureDirectory

public FutureDirectory(File dir)
Create a future directory representing the referenced directory of a File object. The directory may already exist.

Parameters:
dir - The directory.
Method Detail

getEntity

public DirectoryView getEntity()
                        throws NotADirectoryException
Get the directory, creating it if necessary.

Overrides:
getEntity in class FutureEntity
Returns:
The entity.
Throws:
NotADirectoryException - If the entity at the referenced location is not a directory.

getEntityOrNull

public DirectoryView getEntityOrNull()
                              throws NotADirectoryException
Get the directory, returning null if it does not exist.

Overrides:
getEntityOrNull in class FutureEntity
Returns:
The entity, or null.
Throws:
NotADirectoryException - If the entity at the referenced location is not a directory.

isExistingDirectory

public boolean isExistingDirectory()
                            throws NotADirectoryException
Is this future directory referencing an existing directory.

Overrides:
isExistingDirectory in class FutureEntity
Returns:
true if this object references an existing directory.
Throws:
NotADirectoryException - If the entity at the referenced location is not a directory.

isExistingFile

public boolean isExistingFile()
                       throws NotADirectoryException
This method returns false.

Overrides:
isExistingFile in class FutureEntity
Returns:
true if this future entity references an already existing file.
Throws:
NotAFileException - If the entity at the referenced location is not a directory.
NotADirectoryException

getFileObject

public File getFileObject()
                   throws NotADirectoryException
Get a File object referencing the directory. The directory may or may not exist.

Overrides:
getFileObject in class FutureEntity
Returns:
A File referencing the future entity's location.
Throws:
NotADirectoryException - If the entity at the referenced location is not a directory.

getFile

public EFile getFile()
              throws UnsupportedOperationException
Description copied from class: FutureEntity
Get the file referenced by this future entity, possibly creating it if it does not already exist.

Overrides:
getFile in class FutureEntity
Returns:
The file referenced by this future entity.
Throws:
UnsupportedOperationException - Always!
See Also:
FutureEntity.getDirectory()

toString

public String toString()
Overrides:
toString in class FutureEntity