Class BaseSourceCodeProvider
java.lang.Object
io.github.mmm.code.base.loader.BaseSourceCodeProvider
- All Implemented Interfaces:
SourceCodeProvider, AutoCloseable
- Direct Known Subclasses:
BaseSourceCodeProviderArchive, BaseSourceCodeProviderDirectory
Abstract base implementation of
SourceCodeProvider.- Since:
- 1.0.0
- Author:
- Joerg Hohwiller (hohwille at users.sourceforge.net)
-
Constructor Summary
ConstructorsConstructorDescriptionThe constructor.BaseSourceCodeProvider(String typeExtension) The constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected Stringfilename2TypeSimpleName(String filename) protected abstract Pathprotected abstract booleanisClosed()static BaseSourceCodeProviderstatic BaseSourceCodeProvideropenPackage(String qualifiedName) protected Readerprotected StringqualifiedName2PackagePath(String qualifiedName) protected StringqualifiedName2Path(String qualifiedName) protected StringqualifiedName2TypePath(String qualifiedName) protected voidVerifies that this provider has not yet beenSourceCodeProvider.close()d.scanPackage(String qualifiedName) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface SourceCodeProvider
close
-
Constructor Details
-
BaseSourceCodeProvider
public BaseSourceCodeProvider()The constructor. -
BaseSourceCodeProvider
The constructor.- Parameters:
typeExtension- thetype extension.
-
-
Method Details
-
getTypeExtension
- Returns:
- the extension of a file containing the source-code of a
CodeType. Examples are ".java", ".ts", ".kt", ".cs", etc.
-
openType
- Specified by:
openTypein interfaceSourceCodeProvider- Parameters:
qualifiedName- the qualified name of theCodeTypeto open.- Returns:
- a new
Readerto read the source-code from ornullif the requested type was not found. - Throws:
IOException- on I/O error.- See Also:
-
openPackage
- Specified by:
openPackagein interfaceSourceCodeProvider- Parameters:
qualifiedName- the qualified name of theCodePackageto open.- Returns:
- a new
Readerto read the source-code from ornullif the requested package was not found. - Throws:
IOException- on I/O error.
-
scanPackage
- Specified by:
scanPackagein interfaceSourceCodeProvider- Parameters:
qualifiedName- the qualified name of theCodePackageto scan.- Returns:
- a
Listwith thesimple namesof theCodeTypes in the specified package ornullif scan is not supported.
-
getPath
-
isClosed
protected abstract boolean isClosed()- Returns:
trueifclosewas called,falseotherwise.
-
requireNotClosed
protected void requireNotClosed()Verifies that this provider has not yet beenSourceCodeProvider.close()d. -
openReader
- Parameters:
in- theInputStreamto read.- Returns:
- the
Readerfor the givenInputStream. - Throws:
IOException- on I/O error.
-
qualifiedName2TypePath
-
filename2TypeSimpleName
-
qualifiedName2PackagePath
-
qualifiedName2Path
-
of
- Parameters:
sourceCodeLocation- theFilepointing to the location of the source code. SeeCodeSource.getSourceCodeLocation().- Returns:
- the
BaseSourceCodeProviderornullif the giveFileisnullor does notexist.
-
of
- Parameters:
sourceCodeLocation- theFilepointing to the location of the source code. SeeCodeSource.getSourceCodeLocation().typeExtension- thetype extension.- Returns:
- the
BaseSourceCodeProviderornullif the giveFileisnullor does notexist.
-