org.pf.file
Class Classpath

java.lang.Object
  extended by org.pf.file.Classpath

public class Classpath
extends java.lang.Object

Represents a classpath definition whereas the elements are already parsed an validated.
Since version 1.2 elements are also collected from patterns with wildcards (e.g. "base.jar:lib/*.jar:xalan.jar")

Version:
1.2
Author:
Manfred Duchrow

Constructor Summary
Classpath()
          Initialize the new instance with the classpath from System property "java.class.path" or from the Class-Path value in the manifest file of the sole JAR file if the program was started with option -jar.
Classpath(java.util.Collection classpathElements)
          Initialize the new instance with the given elements.
Classpath(java.lang.String classpath)
          Initialize the new instance with a classpath definition.
Classpath(java.lang.String[] classpathElements)
          Initialize the new instance with the given elements.
Classpath(java.lang.String classpath, java.lang.String separator)
          Initialize the new instance with a classpath definition where the separator is the one given as parameter.
 
Method Summary
 ClasspathElement[] allElements()
          Returns all classpath elements.
 ClasspathElement[] elementsContaining(java.lang.String filename)
          Returns all elements that contain a file with the specified name.
 ClasspathElement firstElementContaining(java.lang.String filename)
          Returns the first element that contains a file with the specified name or null if the file cannot be found.
 ClasspathElement[] invalidElements()
          Returns the classpath elements that are invalid.
 void removeDuplicates()
          Removes all duplicates of classpath elements that are already in the classpath.
 java.lang.String toString()
          Returns the string representation of this classpath using the current platform's path separator.
 java.lang.String toString(java.lang.String separator)
          Returns the string representation of this classpath using the given path separator.
 ClasspathElement[] validElements()
          Returns the classpath elements that are valid.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Classpath

public Classpath()
Initialize the new instance with the classpath from System property "java.class.path" or from the Class-Path value in the manifest file of the sole JAR file if the program was started with option -jar.


Classpath

public Classpath(java.lang.String classpath)
Initialize the new instance with a classpath definition.

Parameters:
classpath - A classpath definition with the current platform's path separator

Classpath

public Classpath(java.lang.String classpath,
                 java.lang.String separator)
Initialize the new instance with a classpath definition where the separator is the one given as parameter.

Parameters:
classpath - A classpath definition with the specified path separator
separator - The separator thst is used to separate the elements

Classpath

public Classpath(java.lang.String[] classpathElements)
Initialize the new instance with the given elements.

Parameters:
classpathElements - An array with the elements of the classpath

Classpath

public Classpath(java.util.Collection classpathElements)
Initialize the new instance with the given elements.

Parameters:
classpathElements - A collection of String elements that build the classpath
Method Detail

allElements

public ClasspathElement[] allElements()
Returns all classpath elements.


validElements

public ClasspathElement[] validElements()
Returns the classpath elements that are valid.


invalidElements

public ClasspathElement[] invalidElements()
Returns the classpath elements that are invalid.


elementsContaining

public ClasspathElement[] elementsContaining(java.lang.String filename)
Returns all elements that contain a file with the specified name.


firstElementContaining

public ClasspathElement firstElementContaining(java.lang.String filename)
Returns the first element that contains a file with the specified name or null if the file cannot be found.


removeDuplicates

public void removeDuplicates()
Removes all duplicates of classpath elements that are already in the classpath.


toString

public java.lang.String toString()
Returns the string representation of this classpath using the current platform's path separator.

Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(java.lang.String separator)
Returns the string representation of this classpath using the given path separator.

Parameters:
separator - The separator to separate the elements