public class Classpath
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
DEFAULT_SEPARATOR |
Constructor and Description |
---|
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<java.lang.String> 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.
|
Modifier and Type | Method and Description |
---|---|
ClasspathElement[] |
allElements()
Returns all classpath elements.
|
protected void |
appendElement(java.lang.String elementName) |
protected void |
basicAppendElement(java.lang.String elementName) |
protected ClasspathElement[] |
collectElements(boolean valid) |
static Classpath |
create(java.lang.String... classpathElements)
Returns a new Classpath object initialized with the given path elemments.
|
protected ClasspathElement[] |
elementArray(java.util.List<ClasspathElement> elementList) |
ClasspathElement[] |
elementsContaining(java.lang.String filename)
Returns all elements that contain a file with the specified name.
|
protected ClasspathElement[] |
elementsWithFile(java.lang.String filename)
Returns all elements that contain a file with the given name.
|
protected ClasspathElement[] |
elementsWithFile(java.lang.String filename,
boolean onlyFirst)
Returns all elements or the first element that contain(s) a file with the
given name.
|
protected FileUtil |
fileUtil() |
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.
|
protected java.util.List<ClasspathElement> |
getElements() |
protected void |
init(java.lang.String classpath,
java.lang.String separator) |
protected void |
initFromParts(java.lang.String[] parts) |
ClasspathElement[] |
invalidElements()
Returns the classpath elements that are invalid.
|
void |
removeDuplicates()
Removes all duplicates of classpath elements that are already in the
classpath.
|
protected void |
setElements(java.util.List<ClasspathElement> newValue) |
protected StringUtil |
str() |
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.
|
public Classpath()
public Classpath(java.lang.String classpath)
classpath
- A classpath definition with the current platform's path separatorpublic Classpath(java.lang.String classpath, java.lang.String separator)
classpath
- A classpath definition with the specified path separatorseparator
- The separator thst is used to separate the elementspublic Classpath(java.lang.String[] classpathElements)
classpathElements
- An array with the elements of the classpathpublic Classpath(java.util.Collection<java.lang.String> classpathElements)
classpathElements
- A collection of String elements that build the classpath.public static Classpath create(java.lang.String... classpathElements)
classpathElements
- The arbitrary number of elements to be put into the classpath.public ClasspathElement[] allElements()
public ClasspathElement[] validElements()
public ClasspathElement[] invalidElements()
public ClasspathElement[] elementsContaining(java.lang.String filename)
public ClasspathElement firstElementContaining(java.lang.String filename)
public void removeDuplicates()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(java.lang.String separator)
separator
- The separator to separate the elementsprotected void init(java.lang.String classpath, java.lang.String separator)
protected void initFromParts(java.lang.String[] parts)
protected void appendElement(java.lang.String elementName)
protected void basicAppendElement(java.lang.String elementName)
protected ClasspathElement[] elementsWithFile(java.lang.String filename)
protected ClasspathElement[] elementsWithFile(java.lang.String filename, boolean onlyFirst)
protected ClasspathElement[] collectElements(boolean valid)
protected ClasspathElement[] elementArray(java.util.List<ClasspathElement> elementList)
protected java.util.List<ClasspathElement> getElements()
protected void setElements(java.util.List<ClasspathElement> newValue)
protected FileUtil fileUtil()
protected StringUtil str()