org.schmant.support
Class FutureFile

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

public class FutureFile
extends FutureEntity

This object is a FutureEntity for future entities that are files. 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
FutureFile(DirectoryView base, RelativeLocation loc)
          Create a new future file with a relative location against a base directory.
FutureFile(DirectoryView parentDir, String name)
          Create a new future file with a name and a parent directory.
FutureFile(EFile f)
          Create a future file representing an existing file entity.
FutureFile(File f)
          Create a future file representing the referenced file of a File object.
 
Method Summary
 DirectoryView getDirectory()
          Get the directory referenced by this future entity, possibly creating it if it does not already exist.
 EFile getEntity()
          Get the file, creating it if necessary.
 EFile getEntityOrNull()
          Get the file, returning null if it does not exist.
 File getFileObject()
          Get a File object referencing the file.
 boolean isExistingDirectory()
          This method returns false.
 boolean isExistingFile()
          This method returns true if this future file references an existing file.
 String toString()
           
 
Methods inherited from class org.schmant.support.FutureEntity
exists, getBaseDirectory, getFile, 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

FutureFile

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

This may reference a file that already exists.

Parameters:
parentDir - The parent directory.
name -

FutureFile

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

This may reference a file that already exists.

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

FutureFile

public FutureFile(EFile f)
Create a future file representing an existing file entity.

Parameters:
f - The file.

FutureFile

public FutureFile(File f)
Create a future file representing the referenced file of a File object. The file may already exist.

Parameters:
f - The file.
Method Detail

getEntity

public EFile getEntity()
                throws NotAFileException
Get the file, creating it if necessary.

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

getEntityOrNull

public EFile getEntityOrNull()
                      throws NotAFileException
Get the file, returning null if it does not exist.

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

isExistingDirectory

public boolean isExistingDirectory()
                            throws NotAFileException
This method returns false.

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

isExistingFile

public boolean isExistingFile()
                       throws NotAFileException
This method returns true if this future file references an existing file.

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 file.

getFileObject

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

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

getDirectory

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

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

toString

public String toString()
Overrides:
toString in class FutureEntity