public final class JavaPath extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
JavaPath.ClsSrc
Determines whether a class file or a source file is meant.
|
(package private) static interface |
JavaPath.FileWrapper
Wrapps a file directly found within a directory
or within a zip-archive which also includes jar-archives.
|
(package private) static class |
JavaPath.OrdFileWrapper
Represents an ordinary file
JavaPath.OrdFileWrapper.file on a file system. |
(package private) static class |
JavaPath.ZipEntryWrapper
Represents a file
JavaPath.ZipEntryWrapper.entry
which is an entry in a zip-file JavaPath.ZipEntryWrapper.zipFile. |
| Modifier and Type | Field and Description |
|---|---|
private static char |
CLASS_SEP
Java's class separator
. |
private static char |
FILE_SEP
The entry of property
file.separator as a char. |
private static String |
INNER_CLASS_SEP
Java's class separator
$
separating inner classes from their enclosing classes. |
private static String |
JAR_END
File ending
.jar identifying jar-files. |
private static int |
LEN_BUFFER
The length of a buffer to read at once.
|
private static String |
PATH_SEP
The entry of property
path.separator. |
private List<File> |
roots
The list of entries of this path.
|
private static String |
ZIP_END
File ending
.zip identifying zip-files. |
| Constructor and Description |
|---|
JavaPath(String path)
Creates a new
JavaPath instance. |
| Modifier and Type | Method and Description |
|---|---|
String |
absFile2cls(File absFile,
JavaPath.ClsSrc clsSrc) |
private String |
cls2locFile(String clsName,
JavaPath.ClsSrc clsSrc)
Converts a class name into the into the corresponding name
of a local source file or class file.
|
File |
getFile(String localFilename) |
File |
getFile(String clsName,
JavaPath.ClsSrc clsSrc)
Converts a class name into the corresponding source file or class file
if possible.
|
InputStream |
getInputStream(String clsName) |
String |
getLocFileName(File absFile) |
String |
locFile2cls(String locFileName,
JavaPath.ClsSrc clsSrc) |
private JavaPath.FileWrapper |
locFile2Wrapper(String localFilename)
Converts a local file name into the wrapper
of the file found on the path.
|
static void |
main(String[] args) |
String |
toString() |
private static final char FILE_SEP
file.separator as a char.private static final String PATH_SEP
path.separator.private static final char CLASS_SEP
.
separating classes from their packages
and also packages from their subpackages.private static final String INNER_CLASS_SEP
$
separating inner classes from their enclosing classes.private static final String ZIP_END
.zip identifying zip-files.private static final String JAR_END
.jar identifying jar-files.private static final int LEN_BUFFER
public JavaPath(String path)
JavaPath instance.
Essentially, roots is initialized.path - a path as a String value.
note that the entries of the path must not be the empty string.IllegalArgumentException - if two path separators immediately follow on one another
or if they stand at the beginning or at the end
of path.private String cls2locFile(String clsName, JavaPath.ClsSrc clsSrc)
clsName - the name of the class as a String value.clsSrc - a ClsSrc which determines
whether to convert the class name
into a class file or into a source file.roots is not read.public File getFile(String clsName, JavaPath.ClsSrc clsSrc)
clsName - the name of the class as a String value.clsSrc - a ClsSrc which determines
whether to convert the class name
into a class file or into a source file.File
corresponding with the given classname if there is one;
otherwise returns null.
Note that if the file is found within a zip- or jar-file,
a temporal file is created.
In any case, the file returned exists
unless null is returned.public InputStream getInputStream(String clsName) throws IOException
IOExceptionprivate JavaPath.FileWrapper locFile2Wrapper(String localFilename)
localFilename - the name of a local file as a String value.FileWrapper representing the first file
found on the path with the appropriate name.
If the file is found in a directory of the path,
an JavaPath.OrdFileWrapper is returned,
if it is found within a zip- or jar-file,
a JavaPath.ZipEntryWrapper is returned.public String locFile2cls(String locFileName, JavaPath.ClsSrc clsSrc)
public String absFile2cls(File absFile, JavaPath.ClsSrc clsSrc)
public static void main(String[] args)
Copyright © 2012–2018 Simuline Organization (l2r). All rights reserved.