Package com.thoughtworks.qdox.library
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
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.thoughtworks.qdox.library.AbstractClassLibrary
AbstractClassLibrary.ClassLibraryFilter
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate JavaClassContext
private boolean
private boolean
private static final String
private String
private ErrorHandler
-
Constructor Summary
ConstructorsConstructorDescriptionSourceLibrary
(AbstractClassLibrary parent) Create a new instance of SourceLibrary and chain it to the parent -
Method Summary
Modifier and TypeMethodDescriptionAdd aFile
containing java code to this libraryaddSource
(InputStream stream) Add anInputStream
containing java code to this libraryAdd aReader
containing java code to this libraryprivate JavaSource
Add aURL
containing java code to this libraryprotected boolean
containsClassReference
(String name) This method is used to detect if there's a match with this classname.final String
final ErrorHandler
Get all classes, including those from parent SourceLibrariesGet all packages, including those from parent SourceLibrariesGet all sources, including those from parent SourceLibrariesfinal boolean
final boolean
private Builder
(package private) Builder
parse
(InputStream stream, URL url) (package private) Builder
private void
private void
protected final void
registerJavaSource
(JavaSource source) protected JavaClass
resolveJavaClass
(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 JavaPackage
resolveJavaPackage
(String name) final void
setDebugLexer
(boolean debugLexer) Use the Lexer in debug modefinal void
setDebugParser
(boolean debugParser) Use the Parser in debug modefinal void
setEncoding
(String encoding) Sets the encoding to use when parsing a URL or InputStreamReaderfinal void
setErrorHandler
(ErrorHandler errorHandler) Methods inherited from class com.thoughtworks.qdox.library.AbstractClassLibrary
getJavaClass, getJavaClass, getJavaClasses, getJavaModules, getJavaPackage, getJavaPackages, getJavaSources, getModelBuilder, getModelBuilder, getModelBuilderFactory, getModelWriterFactory, hasClassReference, setModelBuilderFactory, setModelWriterFactory
-
Field Details
-
context
-
debugLexer
private boolean debugLexer -
debugParser
private boolean debugParser -
DEFAULT_ENCODING
-
encoding
-
errorHandler
-
-
Constructor Details
-
SourceLibrary
Create a new instance of SourceLibrary and chain it to the parent- Parameters:
parent
- the parent classLibrary
-
-
Method Details
-
addSource
Add aReader
containing java code to this library- Parameters:
reader
- aReader
which should contain java code- Returns:
- The constructed
JavaSource
object of this reader - Throws:
ParseException
- if this content couldn't be parsed to a JavaModel
-
addSource
-
addSource
Add anInputStream
containing java code to this library- Parameters:
stream
- anInputStream
which should contain java code- Returns:
- The constructed
JavaSource
object of this stream - Throws:
ParseException
- if this content couldn't be parsed to a JavaModelIOException
- if an IOException occurs
-
addSource
Add aURL
containing java code to this library- Parameters:
url
- aURL
which should contain java code- Returns:
- The constructed
JavaSource
object of this url - Throws:
ParseException
- if this content couldn't be parsed to a JavaModelIOException
- if an IOException occurs
-
addSource
Add aFile
containing java code to this library- Parameters:
file
- aFile
which should contain java code- Returns:
- The constructed
JavaSource
object of this file - Throws:
ParseException
- if this content couldn't be parsed to a JavaModelIOException
- if an IOException occurs
-
parse
- Throws:
ParseException
-
parse
-
parse
- Throws:
ParseException
-
resolveJavaClass
Description copied from class:AbstractClassLibrary
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.- Specified by:
resolveJavaClass
in classAbstractClassLibrary
- Parameters:
name
- the fully qualified name- Returns:
- the resolved JavaClass, otherwise
null
-
resolveJavaPackage
- Specified by:
resolveJavaPackage
in classAbstractClassLibrary
-
registerJavaSource
- Parameters:
source
- the source, might benull
-
registerJavaPackage
-
registerJavaClass
-
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:
getJavaClasses
in interfaceClassLibrary
- Overrides:
getJavaClasses
in classAbstractClassLibrary
- Returns:
- all JavaClasses of this ClassLibrary
-
getJavaPackages
Get all packages, including those from parent SourceLibraries- Specified by:
getJavaPackages
in interfaceClassLibrary
- Overrides:
getJavaPackages
in classAbstractClassLibrary
- Returns:
- all JavaPackages of this ClassLibrary
-
getJavaSources
Get all sources, including those from parent SourceLibraries- Specified by:
getJavaSources
in interfaceClassLibrary
- Overrides:
getJavaSources
in classAbstractClassLibrary
- Returns:
- all JavaSources as a List, never
null
-
containsClassReference
Description copied from class:AbstractClassLibrary
This 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:
containsClassReference
in classAbstractClassLibrary
- Parameters:
name
- the fully qualified name of the class- Returns:
- true if this ClassLibrary has a reference to this class.
-