Package classycle

# Class Parser

java.lang.Object
classycle.Parser

public class Parser extends 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

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`ARCHIVE_PATH_DELIMITER`

## Method Summary

Modifier and Type
Method
Description
`static AtomicVertex[]`
`readClassFiles(String[] classFiles)`
Reads and parses class files and creates a direct graph.
`static AtomicVertex[]`
`readClassFiles(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 Details

### ARCHIVE_PATH_DELIMITER

public static final String ARCHIVE_PATH_DELIMITER

See Also:
  - Constant Field Values

## Method Details

### readClassFiles

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

Throws:
  `IOException`

### readClassFiles

public static AtomicVertex[] readClassFiles(String[] classFiles, StringPattern pattern, StringPattern reflectionPattern, boolean mergeInnerClasses) throws 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:
  `IOException`