Package io.github.mkoncek.classpathless
Class JavaSourceReader
java.lang.Object
io.github.mkoncek.classpathless.JavaSourceReader
Dummy simple class to extract information from an
InputStream
representing a Java source file.
Reads by lines removing comments until the first "{" symbol (start
of class / interface / enum / ...) declaration. Then removes all the content
until the first "@" (annotation). Then searches for the package pattern
in the leftover string.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BufferedReaderprivate static final Patternstatic final Pattern -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Collection<String> readImports(String source) Read the package name.static StringreadSourcePackage(String source) Read the package name.
-
Field Details
-
packagePattern
-
importPattern
-
br
-
-
Constructor Details
-
JavaSourceReader
-
-
Method Details
-
readSourcePackage
Read the package name.- Returns:
- Package name or null if none was found.
- Throws:
IOException- If an IO error occurs.
-
readSourcePackage
Read the package name.- Parameters:
source- The source code- Returns:
- Package name or null if none was found.
- Throws:
IOException- If an IO error occurs.
-
readImports
- Throws:
IOException
-