Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.tools.ant.types
Class Path  view Path download Path.java

java.lang.Object
  extended byorg.apache.tools.ant.ProjectComponent
      extended byorg.apache.tools.ant.types.DataType
          extended byorg.apache.tools.ant.types.Path
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
PolyTest.MyPath

public class Path
extends DataType
implements java.lang.Cloneable

This object represents a path as used by CLASSPATH or PATH environment variable.

<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
private  java.util.Vector elements
           
static Path systemBootClasspath
          The system bootclassspath as a Path object.
static Path systemClasspath
          The system classspath as a Path object
 
Fields inherited from class org.apache.tools.ant.types.DataType
checked, description, ref
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
Path(org.apache.tools.ant.Project project)
           
Path(org.apache.tools.ant.Project p, java.lang.String path)
          Invoked by IntrospectionHelper for setXXX(Path p) attribute setters.
 
Method Summary
 void add(Path path)
          Adds a nested path
 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.
private static void addUnlessPresent(java.util.Vector v, java.io.File dir, java.lang.String[] s)
          Adds absolute path names of listed files in the given directory to the Vector if they are not already included.
private static void addUnlessPresent(java.util.Vector v, java.lang.String s)
          Adds a String to the Vector if it isn't already included.
 void append(Path other)
          Append the contents of the other Path instance to this.
 java.lang.Object clone()
          Return a Path that holds the same elements as this instance.
 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  void dieOnCircularReference(java.util.Stack stk, org.apache.tools.ant.Project p)
          Overrides the version of DataType to recurse on all DataType child elements that may have been added.
 java.lang.String[] list()
          Returns all path elements defined by this and nested path objects.
private static java.lang.String resolveFile(org.apache.tools.ant.Project project, java.lang.String relativeName)
          Resolve a filename with Project's help - if we know one that is.
 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()
          How many parts does this Path instance consist of.
 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 all occurrences of / or \ to correct separator of the current platform and returns whether it had to do any replacements.
static java.lang.String[] translatePath(org.apache.tools.ant.Project project, java.lang.String source)
          Splits a PATH (with : or ; as separators) into its parts.
 
Methods inherited from class org.apache.tools.ant.types.DataType
checkAttributesAllowed, checkChildrenAllowed, circularReference, getCheckedRef, getDescription, getRefid, isChecked, isReference, noChildrenAllowed, setChecked, setDescription, tooManyAttributes
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, log, log, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

elements

private java.util.Vector elements

systemClasspath

public static Path systemClasspath
The system classspath as a Path object


systemBootClasspath

public static Path systemBootClasspath
The system bootclassspath as a Path object.

Since:
Ant 1.6.2
Constructor Detail

Path

public Path(org.apache.tools.ant.Project p,
            java.lang.String path)
Invoked by IntrospectionHelper for setXXX(Path p) attribute setters.


Path

public Path(org.apache.tools.ant.Project project)
Method Detail

setLocation

public void setLocation(java.io.File location)
                 throws org.apache.tools.ant.BuildException
Adds a element definition to the path.


setPath

public void setPath(java.lang.String path)
             throws org.apache.tools.ant.BuildException
Parses a path definition and creates single PathElements.


setRefid

public void setRefid(Reference r)
              throws org.apache.tools.ant.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.

Overrides:
setRefid in class DataType

createPathElement

public Path.PathElement createPathElement()
                                   throws org.apache.tools.ant.BuildException
Creates the nested <pathelement> element.


addFileset

public void addFileset(FileSet fs)
                throws org.apache.tools.ant.BuildException
Adds a nested <fileset> element.


addFilelist

public void addFilelist(FileList fl)
                 throws org.apache.tools.ant.BuildException
Adds a nested <filelist> element.


addDirset

public void addDirset(DirSet dset)
               throws org.apache.tools.ant.BuildException
Adds a nested <dirset> element.


add

public void add(Path path)
         throws org.apache.tools.ant.BuildException
Adds a nested path

Since:
Ant 1.6

createPath

public Path createPath()
                throws org.apache.tools.ant.BuildException
Creates a nested <path> element.


append

public void append(Path other)
Append the contents of the other Path instance to this.


addExisting

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.


addExisting

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


list

public java.lang.String[] list()
Returns all path elements defined by this and nested path objects.


toString

public java.lang.String toString()
Returns a textual representation of the path, which can be used as CLASSPATH or PATH environment variable definition.


translatePath

public static java.lang.String[] translatePath(org.apache.tools.ant.Project project,
                                               java.lang.String source)
Splits a PATH (with : or ; as separators) into its parts.


translateFile

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


translateFileSep

protected static boolean translateFileSep(java.lang.StringBuffer buffer,
                                          int pos)
Translates all occurrences of / or \ to correct separator of the current platform and returns whether it had to do any replacements.


size

public int size()
How many parts does this Path instance consist of.


clone

public java.lang.Object clone()
Return a Path that holds the same elements as this instance.


dieOnCircularReference

protected void dieOnCircularReference(java.util.Stack stk,
                                      org.apache.tools.ant.Project p)
                               throws org.apache.tools.ant.BuildException
Overrides the version of DataType to recurse on all DataType child elements that may have been added.

Overrides:
dieOnCircularReference in class DataType

resolveFile

private static java.lang.String resolveFile(org.apache.tools.ant.Project project,
                                            java.lang.String relativeName)
Resolve a filename with Project's help - if we know one that is.

Assume the filename is absolute if project is null.


addUnlessPresent

private static void addUnlessPresent(java.util.Vector v,
                                     java.lang.String s)
Adds a String to the Vector if it isn't already included.


addUnlessPresent

private static void addUnlessPresent(java.util.Vector v,
                                     java.io.File dir,
                                     java.lang.String[] s)
Adds absolute path names of listed files in the given directory to the Vector if they are not already included.


concatSystemClasspath

public Path concatSystemClasspath()
Concatenates the system class path in the order specified by the ${build.sysclasspath} property - using "last" as default value.


concatSystemClasspath

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


addJavaRuntime

public void addJavaRuntime()
Add the Java Runtime classes to this Path instance.


addExtdirs

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.