org.apache.tools.ant.types
public class Path extends DataType implements Cloneable, ResourceCollection
<sometask>
<somepath>
<pathelement location="/path/to/file.jar" />
<pathelement
path="/path/to/file2.jar:/path/to/class2;/path/to/class3" />
<pathelement location="/path/to/file3.jar" />
<pathelement location="/path/to/file4.jar" />
</somepath>
</sometask>
The object implemention sometask
must provide a method called
createSomepath
which returns an instance of Path
.
Nested path definitions are handled by the Path object and must be labeled
pathelement
.
The path element takes a parameter path
which will be parsed
and split into single elements. It will usually be used
to define a path from an environment variable.
Nested Class Summary | |
---|---|
class | Path.PathElement
Helper class, holds the nested <pathelement> values. |
Field Summary | |
---|---|
static Path | systemBootClasspath
The system bootclasspath as a Path object.
|
static Path | systemClasspath The system classpath as a Path object |
Constructor Summary | |
---|---|
Path(Project p, String path)
Invoked by IntrospectionHelper for setXXX(Path p)
attribute setters. | |
Path(Project project)
Construct an empty Path . |
Method Summary | |
---|---|
void | add(Path path)
Adds a nested path |
void | add(ResourceCollection c)
Add a nested ResourceCollection . |
void | addDirset(DirSet dset)
Adds a nested <dirset> element. |
void | addExisting(Path source)
Adds the components on the given path which exist to this
Path. |
void | addExisting(Path source, boolean tryUserDir)
Same as addExisting, but support classpath behavior if tryUserDir
is true. |
void | addExtdirs(Path extdirs)
Emulation of extdirs feature in java >= 1.2.
|
void | addFilelist(FileList fl)
Adds a nested <filelist> element. |
void | addFileset(FileSet fs)
Adds a nested <fileset> element. |
void | addJavaRuntime()
Add the Java Runtime classes to this Path instance. |
void | append(Path other)
Append the contents of the other Path instance to this. |
protected ResourceCollection | assertFilesystemOnly(ResourceCollection rc)
Verify the specified ResourceCollection is filesystem-only. |
Object | clone()
Clone this Path. |
Path | concatSystemBootClasspath(String defValue)
Concatenates the system boot class path in the order specified
by the ${build.sysclasspath} property - using the supplied
value if ${build.sysclasspath} has not been set. |
Path | concatSystemClasspath()
Concatenates the system class path in the order specified by
the ${build.sysclasspath} property - using "last" as
default value. |
Path | concatSystemClasspath(String defValue)
Concatenates the system class path in the order specified by
the ${build.sysclasspath} property - using the supplied value
if ${build.sysclasspath} has not been set. |
Path | createPath()
Creates a nested <path> element. |
Path.PathElement | createPathElement()
Creates the nested <pathelement> element. |
protected boolean | delegateIteratorToList()
Helps determine whether to preserve BC by calling list() on subclasses.
|
protected void | dieOnCircularReference(Stack stk, Project p)
Overrides the version of DataType to recurse on all DataType
child elements that may have been added. |
boolean | isFilesystemOnly()
Fulfill the ResourceCollection contract. |
Iterator | iterator()
Fulfill the ResourceCollection contract. |
String[] | list()
Returns all path elements defined by this and nested path objects. |
void | setLocation(File location)
Adds a element definition to the path. |
void | setPath(String path)
Parses a path definition and creates single PathElements. |
void | setRefid(Reference r)
Makes this instance in effect a reference to another Path instance.
|
int | size()
Fulfill the ResourceCollection contract. |
String | toString()
Returns a textual representation of the path, which can be used as
CLASSPATH or PATH environment variable definition. |
static String | translateFile(String source)
Returns its argument with all file separator characters
replaced so that they match the local OS conventions. |
protected static boolean | translateFileSep(StringBuffer buffer, int pos)
Translates occurrences at a position of / or \ to correct separator of the
current platform and returns whether it had to do a
replacement. |
static String[] | translatePath(Project project, String source)
Splits a PATH (with : or ; as separators) into its parts. |
Since: Ant 1.6.2
setXXX(Path p)
attribute setters.Parameters: p the Project
for this path. path the String
path definition.
Path
.Parameters: project the Project
for this path.
Parameters: path a Path
to be added to the path
Throws: BuildException on error
Since: Ant 1.6
ResourceCollection
.Parameters: c the ResourceCollection to add.
Since: Ant 1.7
<dirset>
element.Parameters: dset a DirSet
to be added to the path
Throws: BuildException on error
Parameters: source - source path whose components are examined for existence
Parameters: source the source path tryUserDir if true try the user directory if the file is not present
Parameters: extdirs - Path to append files to
<filelist>
element.Parameters: fl a FileList
to be added to the path
Throws: BuildException on error
<fileset>
element.Parameters: fs a FileSet
to be added to the path
Throws: BuildException on error
Parameters: other a Path
to be added to the path
Parameters: rc the ResourceCollection to check.
Returns: the passed in ResourceCollection.
Throws: BuildException if rc
is not filesystem-only.
Returns: Path with shallowly cloned Resource children.
Parameters: defValue the order ("first", "last", "only")
Returns: the concatenated path
Returns: the concatenated path
Parameters: defValue the order ("first", "last", "only")
Returns: the concatenated path
<path>
element.Returns: a Path
to be configured
Throws: BuildException on error
<pathelement>
element.Returns: the PathElement
to be configured
Throws: BuildException on error
list()
on subclasses.
The default behavior of this method is to return true
for any subclass
that implements list()
; this can, of course, be avoided by overriding
this method to return false
. It is not expected that the result of this
method should change over time, thus it is called only once.Returns: true
if iterator()
should delegate to list()
.
Parameters: stk the stack of data types to use (recursively). p the project to use to dereference the references.
Throws: BuildException on error.
Returns: whether this is a filesystem-only resource collection.
Returns: a "fail-fast" Iterator.
Returns: list of path elements.
Parameters: location the location of the element to add (must not be
null
nor empty.
Throws: BuildException on error
Parameters: path the String
path definition.
Throws: BuildException on error
You must not set another attribute or nest elements inside this element if you make it a reference.
Parameters: r the reference to another Path
Throws: BuildException on error
Returns: number of elements as int.
Returns: a textual representation of the path.
Parameters: source the path to convert
Returns: the converted path
Parameters: buffer a buffer containing a string pos the position in the string buffer to convert
Returns: true if the character was a / or \
Parameters: project the project to use source a String
value
Returns: an array of strings, one for each path element