Class JavaPath


  • public final class JavaPath
    extends Object
    Represents a path to find class and source files on. Created: Wed Jun 14 23:12:06 2006
    Version:
    1.0
    Author:
    Ernst Reissner
    • Field Detail

      • FILE_SEP

        private static final char FILE_SEP
        The entry of property file.separator as a char.
      • PATH_SEP

        private static final String PATH_SEP
        The entry of property path.separator.
      • CLASS_SEP

        private static final char CLASS_SEP
        Java's class separator . separating classes from their packages and also packages from their subpackages.
        See Also:
        Constant Field Values
      • INNER_CLASS_SEP

        private static final String INNER_CLASS_SEP
        Java's class separator $ separating inner classes from their enclosing classes.
        See Also:
        Constant Field Values
      • LEN_BUFFER

        private static final int LEN_BUFFER
        The length of a buffer to read at once.
        See Also:
        Constant Field Values
      • roots

        private final List<File> roots
        The list of entries of this path. This serves as root path for the source files and class files under consideration. CAUTION: Note that besides directories also .zip-files and .jar-files are allowed.
    • Constructor Detail

      • JavaPath

        public JavaPath​(String path)
        Creates a new JavaPath instance. Essentially, roots is initialized.
        Parameters:
        path - a path as a String value. note that the entries of the path must not be the empty string.
        Throws:
        IllegalArgumentException - if two path separators immediately follow on one another or if they stand at the beginning or at the end of path.
    • Method Detail

      • cls2locFile

        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.
        Parameters:
        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.
        Returns:
        the name of the local class or source file of the given class. Note that this is no absolute pathname of course: roots is not read.
      • getFile

        public File getFile​(String clsName,
                            JavaPath.ClsSrc clsSrc)
        Converts a class name into the corresponding source file or class file if possible.
        Parameters:
        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.
        Returns:
        the source or class 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.
      • getFile

        public File getFile​(String localFilename)
      • locFile2Wrapper

        private JavaPath.FileWrapper locFile2Wrapper​(String localFilename)
        Converts a local file name into the wrapper of the file found on the path. Note that also within zip- or jar-file is searched.
        Parameters:
        localFilename - the name of a local file as a String value.
        Returns:
        a 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.
      • getLocFileName

        public String getLocFileName​(File absFile)
      • main

        public static void main​(String[] args)