Save This Page
Home » apache-ant-1.8.1 » org.apache.tools » ant » types » [javadoc | source]
org.apache.tools.ant.types
public class: Path [javadoc | source]
java.lang.Object
   org.apache.tools.ant.ProjectComponent
      org.apache.tools.ant.types.DataType
         org.apache.tools.ant.types.Path

All Implemented Interfaces:
    ResourceCollection, Cloneable

Direct Known Subclasses:
    MyPath

This object represents a path as used by CLASSPATH or PATH environment variable. A path might also be described as a collection of unique filesystem resources.

<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:
public class  Path.PathElement  Helper class, holds the nested <pathelement> values. 
Field Summary
public static  Path systemClasspath    The system classpath as a Path object 
public static  Path systemBootClasspath    The system bootclasspath as a Path object.
    since: Ant - 1.6.2
 
Fields inherited from org.apache.tools.ant.types.DataType:
ref,  checked
Fields inherited from org.apache.tools.ant.ProjectComponent:
project,  location,  description
Constructor:
 public Path(Project project) 
    Construct an empty Path.
    Parameters:
    project - the Project for this path.
 public Path(Project p,
    String path) 
    Invoked by IntrospectionHelper for setXXX(Path p) attribute setters.
    Parameters:
    p - the Project for this path.
    path - the String path definition.
Method from org.apache.tools.ant.types.Path Summary:
add,   add,   addDirset,   addExisting,   addExisting,   addExtdirs,   addFilelist,   addFileset,   addJavaRuntime,   append,   assertFilesystemOnly,   clone,   concatSystemBootClasspath,   concatSystemClasspath,   concatSystemClasspath,   createPath,   createPathElement,   delegateIteratorToList,   dieOnCircularReference,   isFilesystemOnly,   iterator,   list,   setCache,   setLocation,   setPath,   setRefid,   size,   toString,   translateFile,   translateFileSep,   translatePath
Methods from org.apache.tools.ant.types.DataType:
checkAttributesAllowed,   checkChildrenAllowed,   circularReference,   clone,   dieOnCircularReference,   dieOnCircularReference,   dieOnCircularReference,   getCheckedRef,   getCheckedRef,   getCheckedRef,   getCheckedRef,   getDataTypeName,   getRefid,   invokeCircularReferenceCheck,   isChecked,   isReference,   noChildrenAllowed,   pushAndInvokeCircularReferenceCheck,   setChecked,   setRefid,   toString,   tooManyAttributes
Methods from org.apache.tools.ant.ProjectComponent:
clone,   getDescription,   getLocation,   getProject,   log,   log,   setDescription,   setLocation,   setProject
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.tools.ant.types.Path Detail:
 public  void add(Path path) throws BuildException 
    Adds a nested path
 public  void add(ResourceCollection c) 
    Add a nested ResourceCollection.
 public  void addDirset(DirSet dset) throws BuildException 
    Adds a nested <dirset> element.
 public  void addExisting(Path source) 
    Adds the components on the given path which exist to this Path. Components that don't exist aren't added.
 public  void addExisting(Path source,
    boolean tryUserDir) 
    Same as addExisting, but support classpath behavior if tryUserDir is true. Classpaths are relative to user dir, not the project base. That used to break jspc test
 public  void addExtdirs(Path extdirs) 
    Emulation of extdirs feature in java >= 1.2. This method adds all files in the given directories (but not in sub-directories!) to the classpath, so that you don't have to specify them all one by one.
 public  void addFilelist(FileList fl) throws BuildException 
    Adds a nested <filelist> element.
 public  void addFileset(FileSet fs) throws BuildException 
    Adds a nested <fileset> element.
 public  void addJavaRuntime() 
    Add the Java Runtime classes to this Path instance.
 public  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.
 public Object clone() 
    Clone this Path.
 public 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.
 public Path concatSystemClasspath() 
    Concatenates the system class path in the order specified by the ${build.sysclasspath} property - using "last" as default value.
 public 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.
 public Path createPath() throws BuildException 
    Creates a nested <path> element.
 public PathElement createPathElement() throws BuildException 
    Creates the nested <pathelement> element.
 protected boolean delegateIteratorToList() 
    Helps determine whether to preserve BC by calling 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.
 protected synchronized  void dieOnCircularReference(Stack stk,
    Project p) throws BuildException 
    Overrides the version of DataType to recurse on all DataType child elements that may have been added.
 public synchronized boolean isFilesystemOnly() 
    Fulfill the ResourceCollection contract.
 public final synchronized Iterator iterator() 
    Fulfill the ResourceCollection contract. The Iterator returned will throw ConcurrentModificationExceptions if ResourceCollections are added to this container while the Iterator is in use.
 public String[] list() 
    Returns all path elements defined by this and nested path objects.
 public  void setCache(boolean b) 
    Whether to cache the current path.
 public  void setLocation(File location) throws BuildException 
    Adds a element definition to the path.
 public  void setPath(String path) throws BuildException 
    Parses a path definition and creates single PathElements.
 public  void setRefid(Reference r) throws BuildException 
    Makes this instance in effect a reference to another Path instance.

    You must not set another attribute or nest elements inside this element if you make it a reference.

 public synchronized int size() 
    Fulfill the ResourceCollection contract.
 public String toString() 
    Returns a textual representation of the path, which can be used as CLASSPATH or PATH environment variable definition.
 public 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.
 public static String[] translatePath(Project project,
    String source) 
    Splits a PATH (with : or ; as separators) into its parts.