Package classycle

Class Parser


  • public class Parser
    extends java.lang.Object
    Utility methods for parsing class files and creating directed graphs. The nodes of the graph are classes. The initial vertex of an edge is the class which uses the class specified by the terminal vertex.
    Author:
    Franz-Josef Elmer
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static AtomicVertex[] readClassFiles​(java.lang.String[] classFiles)
      Reads and parses class files and creates a direct graph.
      static AtomicVertex[] readClassFiles​(java.lang.String[] classFiles, StringPattern pattern, StringPattern reflectionPattern, boolean mergeInnerClasses)
      Reads the specified class files and creates a directed graph where each vertex represents a class.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ARCHIVE_PATH_DELIMITER

        public static final java.lang.String ARCHIVE_PATH_DELIMITER
        See Also:
        Constant Field Values
    • Method Detail

      • readClassFiles

        public static AtomicVertex[] readClassFiles​(java.lang.String[] classFiles)
                                             throws java.io.IOException
        Reads and parses class files and creates a direct graph. Short-cut of readClassFiles(classFiles, new TrueStringPattern(), null, false);
        Throws:
        java.io.IOException
      • readClassFiles

        public static AtomicVertex[] readClassFiles​(java.lang.String[] classFiles,
                                                    StringPattern pattern,
                                                    StringPattern reflectionPattern,
                                                    boolean mergeInnerClasses)
                                             throws java.io.IOException
        Reads the specified class files and creates a directed graph where each vertex represents a class. The head vertex of an arc is a class which is used by the tail vertex of the arc. The elements of classFiles are file names (relative to the working directory) which are interpreted depending on its file type as
        • path of a class file (file type .class)
        • path of a class file inside a ZIP file. The path has to contain both paths: the path of the ZIP file first and the path of the class file in the ZIP file second. Both have to be separated by '::'.
        • path of a file of type .zip, .jar, .war, or .ear containing class file
        • path of a folder containing class files or zip/jar/war/ear files
        Folders and zip/jar/war/ear files are searched recursively for class files. If a folder is specified only the top-level zip/jar/war/ear files of that folder are analysed.
        Parameters:
        classFiles - Array of file paths.
        pattern - Pattern fully qualified class names have to match in order to be added to the graph. Otherwise they count as 'external'.
        reflectionPattern - Pattern ordinary string constants of a class file have to fullfill in order to be handled as class references. In addition they have to be syntactically valid fully qualified class names. If null ordinary string constants will not be checked.
        mergeInnerClasses - If true merge inner classes with its outer class
        Returns:
        directed graph.
        Throws:
        java.io.IOException