Package com.github.javaparser.utils
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
SourceZip.Callback
An interface to define a callback for each file that's parsed.
-
Constructor Summary
Constructors Constructor Description SourceZip(Path zipPath)
Create a new ZIP parser.SourceZip(Path zipPath, ParserConfiguration configuration)
Create a new ZIP parser.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ParserConfiguration
getParserConfiguration()
Path
getZipPath()
Get the path of the ZIP file to be parsed.List<Pair<Path,ParseResult<CompilationUnit>>>
parse()
Tries to parse all '.java' files in the ZIP located at this SourceZip's path and returns the parse results in a list.SourceZip
parse(SourceZip.Callback callback)
Tries to parse all '.java' files in the ZIP located at this SourceZip's path and returns the parse results in a list.SourceZip
setParserConfiguration(ParserConfiguration parserConfiguration)
-
-
-
Constructor Detail
-
SourceZip
public SourceZip(Path zipPath)
Create a new ZIP parser. An instance ofJavaParser
with the defaultParserConfiguration
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 ofJavaParser
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 Detail
-
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)
-
-