java.lang.Cloneable
, java.lang.Iterable<Resource>
, ResourceCollection
public class Path extends DataType implements java.lang.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 implementation 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.
Modifier and Type | Class | Description |
---|---|---|
class |
Path.PathElement |
Helper class, holds the nested
<pathelement> values. |
Modifier and Type | Field | Description |
---|---|---|
static Path |
systemBootClasspath |
The system bootclasspath as a Path object.
|
static Path |
systemClasspath |
The system classpath as a Path object
|
description, location, project
Constructor | Description |
---|---|
Path(Project project) |
Construct an empty
Path . |
Path(Project p,
java.lang.String path) |
Invoked by IntrospectionHelper for
setXXX(Path p)
attribute setters. |
Modifier and Type | Method | Description |
---|---|---|
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.
|
java.lang.Object |
clone() |
Clone this Path.
|
Path |
concatSystemBootClasspath(java.lang.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(java.lang.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(java.util.Stack<java.lang.Object> 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.
|
java.util.Iterator<Resource> |
iterator() |
Fulfill the ResourceCollection contract.
|
java.lang.String[] |
list() |
Returns all path elements defined by this and nested path objects.
|
void |
setCache(boolean b) |
Whether to cache the current path.
|
void |
setLocation(java.io.File location) |
Adds a element definition to the path.
|
void |
setPath(java.lang.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.
|
java.lang.String |
toString() |
Returns a textual representation of the path, which can be used as
CLASSPATH or PATH environment variable definition.
|
static java.lang.String |
translateFile(java.lang.String source) |
Returns its argument with all file separator characters
replaced so that they match the local OS conventions.
|
protected static boolean |
translateFileSep(java.lang.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 java.lang.String[] |
translatePath(Project project,
java.lang.String source) |
Splits a PATH (with : or ; as separators) into its parts.
|
checkAttributesAllowed, checkChildrenAllowed, circularReference, dieOnCircularReference, dieOnCircularReference, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getDataTypeName, getRefid, invokeCircularReferenceCheck, isChecked, isReference, noChildrenAllowed, pushAndInvokeCircularReferenceCheck, setChecked, tooManyAttributes
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getDescription, getLocation, getProject, log, log, setDescription, setLocation, setProject
isEmpty, stream
public static Path systemClasspath
public static final Path systemBootClasspath
public Path(Project p, java.lang.String path)
setXXX(Path p)
attribute setters.p
- the Project
for this path.path
- the String
path definition.public Path(Project project)
Path
.project
- the Project
for this path.public void setLocation(java.io.File location) throws BuildException
location
- the location of the element to add (must not be
null
nor empty.BuildException
- on errorpublic void setPath(java.lang.String path) throws BuildException
path
- the String
path definition.BuildException
- on errorpublic void setRefid(Reference r) throws BuildException
You must not set another attribute or nest elements inside this element if you make it a reference.
setRefid
in class DataType
r
- the reference to another PathBuildException
- on errorpublic Path.PathElement createPathElement() throws BuildException
<pathelement>
element.PathElement
to be configuredBuildException
- on errorpublic void addFileset(FileSet fs) throws BuildException
<fileset>
element.fs
- a FileSet
to be added to the pathBuildException
- on errorpublic void addFilelist(FileList fl) throws BuildException
<filelist>
element.fl
- a FileList
to be added to the pathBuildException
- on errorpublic void addDirset(DirSet dset) throws BuildException
<dirset>
element.dset
- a DirSet
to be added to the pathBuildException
- on errorpublic void add(Path path) throws BuildException
path
- a Path
to be added to the pathBuildException
- on errorpublic void add(ResourceCollection c)
ResourceCollection
.c
- the ResourceCollection to add.public Path createPath() throws BuildException
<path>
element.Path
to be configuredBuildException
- on errorpublic void append(Path other)
other
- a Path
to be added to the pathpublic void addExisting(Path source)
source
- - source path whose components are examined for existencepublic void addExisting(Path source, boolean tryUserDir)
source
- the source pathtryUserDir
- if true try the user directory if the file is not presentpublic void setCache(boolean b)
b
- booleanpublic java.lang.String[] list()
public java.lang.String toString()
public static java.lang.String[] translatePath(Project project, java.lang.String source)
project
- the project to usesource
- a String
valuepublic static java.lang.String translateFile(java.lang.String source)
source
- the path to convertprotected static boolean translateFileSep(java.lang.StringBuffer buffer, int pos)
buffer
- a buffer containing a stringpos
- the position in the string buffer to convertpublic int size()
size
in interface ResourceCollection
public java.lang.Object clone()
protected void dieOnCircularReference(java.util.Stack<java.lang.Object> stk, Project p) throws BuildException
dieOnCircularReference
in class DataType
stk
- the stack of data types to use (recursively).p
- the project to use to dereference the references.BuildException
- on error.public Path concatSystemClasspath()
public Path concatSystemClasspath(java.lang.String defValue)
defValue
- the order ("first", "last", "only")public Path concatSystemBootClasspath(java.lang.String defValue)
defValue
- the order ("first", "last", "only")public void addJavaRuntime()
public void addExtdirs(Path extdirs)
extdirs
- - Path to append files topublic final java.util.Iterator<Resource> iterator()
iterator
in interface java.lang.Iterable<Resource>
public boolean isFilesystemOnly()
isFilesystemOnly
in interface ResourceCollection
protected ResourceCollection assertFilesystemOnly(ResourceCollection rc)
rc
- the ResourceCollection to check.BuildException
- if rc
is not filesystem-only.protected boolean delegateIteratorToList()
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.true
if iterator()
should delegate to list()
.