Class SourceZip

java.lang.Object
com.github.javaparser.utils.SourceZip

public class SourceZip extends Object
A collection of Java source files and its sub-directories located in a ZIP or JAR file on the file system. Files can be parsed with a callback.
  • Constructor Details

    • SourceZip

      public SourceZip(Path zipPath)
      Create a new ZIP parser. An instance of JavaParser with the default ParserConfiguration will be used to parse the ZIP.
      Parameters:
      zipPath - The absolute path of ZIP file to parse.
    • SourceZip

      public SourceZip(Path zipPath, ParserConfiguration configuration)
      Create a new ZIP parser. An instance of JavaParser with the given configuration will be used to parse the ZIP.
      Parameters:
      zipPath - The absolute path of ZIP file to parse.
      configuration - The configuration to initiate the default parser with.
  • Method Details

    • parse

      public List<Pair<Path,​ParseResult<CompilationUnit>>> parse() throws IOException
      Tries to parse all '.java' files in the ZIP located at this SourceZip's path and returns the parse results in a list.
      Returns:
      A list of path-compilation unit pairs.
      Throws:
      IOException - If an error occurs while trying to parse the given source.
    • parse

      public SourceZip parse(SourceZip.Callback callback) throws IOException
      Tries to parse all '.java' files in the ZIP located at this SourceZip's path and returns the parse results in a list.
      Returns:
      A list of path-compilation unit pairs.
      Throws:
      IOException - If an error occurs while trying to parse the given source.
    • getZipPath

      public Path getZipPath()
      Get the path of the ZIP file to be parsed.
      Returns:
      The absolute path of this ZIP file.
    • getParserConfiguration

      public ParserConfiguration getParserConfiguration()
    • setParserConfiguration

      public SourceZip setParserConfiguration(ParserConfiguration parserConfiguration)