Class SourceLibrary
java.lang.Object
com.thoughtworks.qdox.library.AbstractClassLibrary
com.thoughtworks.qdox.library.SourceLibrary
- All Implemented Interfaces:
ClassLibrary, Serializable
- Direct Known Subclasses:
SourceFolderLibrary
This Library will immediately parse the source and keeps its reference to a private context.
Once the superclass explicitly asks for an instance if will be moved to the context f the supoerclass.
If there's a request to get a certain JavaModel Object from a SourceLibrary, it will check all ancestor SourceLibraries as well.
- Since:
- 2.0
- Author:
- Robert Scholte
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSourceLibrary(AbstractClassLibrary parent) Create a new instance of SourceLibrary and chain it to the parent -
Method Summary
Modifier and TypeMethodDescriptionAdd aFilecontaining java code to this libraryaddSource(InputStream stream) Add anInputStreamcontaining java code to this libraryAdd aReadercontaining java code to this libraryAdd aURLcontaining java code to this libraryprotected booleancontainsClassReference(String name) This method is used to detect if there's a match with this classname.final Stringfinal ErrorHandlerGet all classes, including those from parent SourceLibrariesGet all packages, including those from parent SourceLibrariesGet all sources, including those from parent SourceLibrariesfinal booleanfinal booleanprotected final voidregisterJavaSource(JavaSource source) protected JavaClassresolveJavaClass(String name) The implementation should check it's sources to see if it can build a JavaClass Model If not, just return null; Once found it will be mapped, so there's no need to keep a reference to this object.protected JavaPackageresolveJavaPackage(String name) final voidsetDebugLexer(boolean debugLexer) Use the Lexer in debug modefinal voidsetDebugParser(boolean debugParser) Use the Parser in debug modefinal voidsetEncoding(String encoding) Sets the encoding to use when parsing a URL or InputStreamReaderfinal voidsetErrorHandler(ErrorHandler errorHandler) Methods inherited from class AbstractClassLibrary
getJavaClass, getJavaClass, getJavaClasses, getJavaModules, getJavaPackage, getJavaPackages, getJavaSources, getModelBuilder, getModelBuilder, getModelBuilderFactory, getModelWriterFactory, hasClassReference, setModelBuilderFactory, setModelWriterFactory
-
Constructor Details
-
SourceLibrary
Create a new instance of SourceLibrary and chain it to the parent- Parameters:
parent- the parent classLibrary
-
-
Method Details
-
addSource
Add aReadercontaining java code to this library- Parameters:
reader- aReaderwhich should contain java code- Returns:
- The constructed
JavaSourceobject of this reader - Throws:
ParseException- if this content couldn't be parsed to a JavaModel
-
addSource
Add anInputStreamcontaining java code to this library- Parameters:
stream- anInputStreamwhich should contain java code- Returns:
- The constructed
JavaSourceobject of this stream - Throws:
ParseException- if this content couldn't be parsed to a JavaModelIOException- if an IOException occurs
-
addSource
Add aURLcontaining java code to this library- Parameters:
url- aURLwhich should contain java code- Returns:
- The constructed
JavaSourceobject of this url - Throws:
ParseException- if this content couldn't be parsed to a JavaModelIOException- if an IOException occurs
-
addSource
Add aFilecontaining java code to this library- Parameters:
file- aFilewhich should contain java code- Returns:
- The constructed
JavaSourceobject of this file - Throws:
ParseException- if this content couldn't be parsed to a JavaModelIOException- if an IOException occurs
-
resolveJavaClass
Description copied from class:AbstractClassLibraryThe implementation should check it's sources to see if it can build a JavaClass Model If not, just return null; Once found it will be mapped, so there's no need to keep a reference to this object.- Specified by:
resolveJavaClassin classAbstractClassLibrary- Parameters:
name- the fully qualified name- Returns:
- the resolved JavaClass, otherwise
null
-
resolveJavaPackage
- Specified by:
resolveJavaPackagein classAbstractClassLibrary
-
registerJavaSource
- Parameters:
source- the source, might benull
-
setDebugLexer
public final void setDebugLexer(boolean debugLexer) Use the Lexer in debug mode- Parameters:
debugLexer- the debug logging flag
-
isDebugLexer
public final boolean isDebugLexer() -
setDebugParser
public final void setDebugParser(boolean debugParser) Use the Parser in debug mode- Parameters:
debugParser- the debug logging flag
-
isDebugParser
public final boolean isDebugParser() -
setEncoding
Sets the encoding to use when parsing a URL or InputStreamReader- Parameters:
encoding- the source encoding
-
getEncoding
-
setErrorHandler
-
getErrorHandler
-
getJavaClasses
Get all classes, including those from parent SourceLibraries- Specified by:
getJavaClassesin interfaceClassLibrary- Overrides:
getJavaClassesin classAbstractClassLibrary- Returns:
- all JavaClasses of this ClassLibrary
-
getJavaPackages
Get all packages, including those from parent SourceLibraries- Specified by:
getJavaPackagesin interfaceClassLibrary- Overrides:
getJavaPackagesin classAbstractClassLibrary- Returns:
- all JavaPackages of this ClassLibrary
-
getJavaSources
Get all sources, including those from parent SourceLibraries- Specified by:
getJavaSourcesin interfaceClassLibrary- Overrides:
getJavaSourcesin classAbstractClassLibrary- Returns:
- all JavaSources as a List, never
null
-
containsClassReference
Description copied from class:AbstractClassLibraryThis method is used to detect if there's a match with this classname. The name could be constructed based on imports and inner class paths.- Specified by:
containsClassReferencein classAbstractClassLibrary- Parameters:
name- the fully qualified name of the class- Returns:
- true if this ClassLibrary has a reference to this class.
-