Top Description Inners Fields Constructors Methods
com.github.javaparser.utils

public Class SourceZip

extends Object
Class Inheritance
Imports
com.github.javaparser.JavaParser, .ParseResult, .ParserConfiguration, com.github.javaparser.ast.CompilationUnit, java.io.IOException, java.nio.file.Path, .Paths, java.util.ArrayList, .Collections, .List, java.util.zip.ZipEntry, .ZipFile

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 and Inner Type Summary

Modifier and TypeClass and Description
public static interface
SourceZip.Callback

An interface to define a callback for each file that's parsed.

Field Summary

Modifier and TypeField and Description
private ParserConfiguration
private final Path

Constructor Summary

AccessConstructor and Description
public
SourceZip(Path
The absolute path of ZIP file to parse.
zipPath
)

Create a new ZIP parser.

public
SourceZip(Path
The absolute path of ZIP file to parse.
zipPath
,
ParserConfiguration
The configuration to initiate the default parser with.
configuration
)

Create a new ZIP parser.

Method Summary

Modifier and TypeMethod and Description
public ParserConfiguration
public Path

Returns:

The absolute path of this ZIP file.
getZipPath
()

Get the path of the ZIP file to be parsed.

public List<Pair<Path, ParseResult<CompilationUnit>>>

Returns:

A list of path-compilation unit pairs.
parse
()

Tries to parse all '.java' files in the ZIP located at this SourceZip's path and returns the parse results in a list.

public SourceZip

Returns:

A list of path-compilation unit pairs.
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.

public SourceZip
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

parserConfigurationback to summary
private ParserConfiguration parserConfiguration
zipPathback to summary
private final Path zipPath

Constructor Detail

SourceZipback to summary
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:Path

The absolute path of ZIP file to parse.

SourceZipback to summary
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:Path

The absolute path of ZIP file to parse.

configuration:ParserConfiguration

The configuration to initiate the default parser with.

Method Detail

getParserConfigurationback to summary
public ParserConfiguration getParserConfiguration()
getZipPathback to summary
public Path getZipPath()

Get the path of the ZIP file to be parsed.

Returns:Path

The absolute path of this ZIP file.

parseback to summary
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:List<Pair<Path, ParseResult<CompilationUnit>>>

A list of path-compilation unit pairs.

Exceptions
IOException:
If an error occurs while trying to parse the given source.
parseback to summary
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:SourceZip

A list of path-compilation unit pairs.

Exceptions
IOException:
If an error occurs while trying to parse the given source.
setParserConfigurationback to summary
public SourceZip setParserConfiguration(ParserConfiguration parserConfiguration)
com.github.javaparser.utils back to summary

public Interface SourceZip.Callback

Annotations
@FunctionalInterface

An interface to define a callback for each file that's parsed.

Method Summary

Modifier and TypeMethod and Description
public void
process(Path
The relative path of the entry in the ZIP file that was parsed.
relativeZipEntryPath
,
ParseResult<CompilationUnit>
The parse result of file located at absolutePath.
result
)

Process the given parse result.

Method Detail

processback to summary
public void process(Path relativeZipEntryPath, ParseResult<CompilationUnit> result)

Process the given parse result.

Parameters
relativeZipEntryPath:Path

The relative path of the entry in the ZIP file that was parsed.

result:ParseResult<CompilationUnit>

The parse result of file located at absolutePath.