org.apache.tools.ant.taskdefs

Class Available

public class Available extends Task implements Condition

Will set the given property if the requested resource is available at runtime. This task may also be used as a condition by the condition task.

Since: Ant 1.1

UNKNOWN: category="control"

Nested Class Summary
static classAvailable.FileDir
EnumeratedAttribute covering the file types to be checked for, either file or dir.
Method Summary
PathcreateClasspath()
Classpath to be used when searching for classes and resources.
PathcreateFilepath()
Path to search for file resources.
booleaneval()
Evaluate the availability of a resource.
voidexecute()
Entry point when operating as a task.
voidsetClassname(String classname)
Set a classname of a class which must be available to set the given property.
voidsetClasspath(Path classpath)
Set the classpath to be used when searching for classes and resources.
voidsetClasspathRef(Reference r)
Set the classpath by reference.
voidsetFile(File file)
Set the file which must be present in the file system to set the given property.
voidsetFilepath(Path filepath)
Set the path to use when looking for a file.
voidsetIgnoresystemclasses(boolean ignore)
Set whether the search for classes should ignore the runtime classes and just use the given classpath.
voidsetProperty(String property)
Set the name of the property which will be set if the particular resource is available.
voidsetResource(String resource)
Set the name of a Java resource which is required to set the property.
voidsetType(String type)
voidsetType(Available.FileDir type)
Set what type of file is required - either directory or file.
voidsetValue(String value)
Set the value to be given to the property if the desired resource is available.

Method Detail

createClasspath

public Path createClasspath()
Classpath to be used when searching for classes and resources.

Returns: an empty Path instance to be configured by Ant.

createFilepath

public Path createFilepath()
Path to search for file resources.

Returns: a new Path instance which Ant will configure with a file search path.

eval

public boolean eval()
Evaluate the availability of a resource.

Returns: boolean is the resource is available.

Throws: BuildException if the condition is not configured correctly

execute

public void execute()
Entry point when operating as a task.

Throws: BuildException if the task is not configured correctly.

setClassname

public void setClassname(String classname)
Set a classname of a class which must be available to set the given property.

Parameters: classname the name of the class required.

setClasspath

public void setClasspath(Path classpath)
Set the classpath to be used when searching for classes and resources.

Parameters: classpath an Ant Path object containing the search path.

setClasspathRef

public void setClasspathRef(Reference r)
Set the classpath by reference.

Parameters: r a Reference to a Path instance to be used as the classpath value.

setFile

public void setFile(File file)
Set the file which must be present in the file system to set the given property.

Parameters: file the name of the file which is required.

setFilepath

public void setFilepath(Path filepath)
Set the path to use when looking for a file.

Parameters: filepath a Path instance containing the search path for files.

setIgnoresystemclasses

public void setIgnoresystemclasses(boolean ignore)
Set whether the search for classes should ignore the runtime classes and just use the given classpath.

Parameters: ignore true if system classes are to be ignored.

setProperty

public void setProperty(String property)
Set the name of the property which will be set if the particular resource is available.

Parameters: property the name of the property to set.

setResource

public void setResource(String resource)
Set the name of a Java resource which is required to set the property.

Parameters: resource the name of a resource which is required to be available.

setType

public void setType(String type)

Deprecated: setType(String) is deprecated and is replaced with setType(Available.FileDir) to make Ant's Introspection mechanism do the work and also to encapsulate operations on the type in its own class.

Parameters: type the type of resource

setType

public void setType(Available.FileDir type)
Set what type of file is required - either directory or file.

Parameters: type an instance of the FileDir enumeratedAttribute indicating whether the file required is to be a directory or a plain file.

setValue

public void setValue(String value)
Set the value to be given to the property if the desired resource is available.

Parameters: value the value to be given.

Copyright