Package com.thoughtworks.qdox.library
Class OrderedClassLibraryBuilder
java.lang.Object
com.thoughtworks.qdox.library.OrderedClassLibraryBuilder
- All Implemented Interfaces:
ClassLibraryBuilder,Serializable
This library resolves JavaClasses in the order in which class sources are added.
- Since:
- 2.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AbstractClassLibraryprivate booleanprivate booleanprivate Stringprivate ErrorHandlerprivate ModelBuilderFactoryprivate ModelWriterFactory -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor which sets the root classLibrary to ClassNameLibrary.OrderedClassLibraryBuilder(AbstractClassLibrary rootClassLibrary) Constructor for which you can set the root ClassLibrary If you set this to null, all classes should be available on the classpath. -
Method Summary
Modifier and TypeMethodDescriptionaddSource(InputStream stream) Add the source content of the reader to the ClassLibrary and return the generated JavaSourceaddSourceFolder(File sourceFolder) appendClassLoader(ClassLoader classLoader) Append a classloader and return itselfAdd the defaultClassLoaders and return itseappendSource(File file) appendSource(InputStream stream) appendSource(Reader reader) appendSource(URL url) appendSourceFolder(File sourceFolder) Get the library based on the strategy of the implementationprivate SourceFolderLibraryprotected final SourceLibraryprotected ClassLoaderLibrarynewClassLoaderLibrary(AbstractClassLibrary parentLibrary) Ability to override the implementation of ClassLoaderLibraryprotected SourceFolderLibrarynewSourceFolderLibrary(AbstractClassLibrary parentLibrary) Ability to override the implementation of SourceFolderLibraryprotected SourceLibrarynewSourceLibrary(AbstractClassLibrary parentLibrary) Ability to override the implementation of SourceLibraryprivate voidprepareSourceLibrary(SourceLibrary sourceLibrary) setDebugLexer(boolean debugLexer) Set totrueto enable debug logging for the lexersetDebugParser(boolean debugParser) Set totrueto enable debug logging for the parsersetEncoding(String encoding) setErrorHander(ErrorHandler errorHandler) Can handle ParseExceptions instead of crashing.setModelBuilderFactory(ModelBuilderFactory modelBuilderFactory) Define theModelBuilderFactorywhich the parsers should use to construct the JavaModel ObjectssetModelWriterFactory(ModelWriterFactory modelWriterFactory) Define theModelWriterFactorywhich is used by the classes when calling for the codeBlock.
-
Field Details
-
classLibrary
-
debugLexer
private boolean debugLexer -
debugParser
private boolean debugParser -
encoding
-
errorHandler
-
modelBuilderFactory
-
modelWriterFactory
-
-
Constructor Details
-
OrderedClassLibraryBuilder
public OrderedClassLibraryBuilder()Default constructor which sets the root classLibrary to ClassNameLibrary. This way every class will be resolved, even if it's not on the classpath. -
OrderedClassLibraryBuilder
Constructor for which you can set the root ClassLibrary If you set this to null, all classes should be available on the classpath.- Parameters:
rootClassLibrary- the parent Classlibrary
-
-
Method Details
-
appendClassLoader
Description copied from interface:ClassLibraryBuilderAppend a classloader and return itself- Specified by:
appendClassLoaderin interfaceClassLibraryBuilder- Parameters:
classLoader- the classloader to add- Returns:
- this ClassLibraryBuilder instance
-
appendDefaultClassLoaders
Description copied from interface:ClassLibraryBuilderAdd the defaultClassLoaders and return itse- Specified by:
appendDefaultClassLoadersin interfaceClassLibraryBuilder- Returns:
- this ClassLibraryBuilder instance
-
appendSourceFolder
- Specified by:
appendSourceFolderin interfaceClassLibraryBuilder- Parameters:
sourceFolder- the source folder- Returns:
- this ClassLibraryBuilder instance
-
appendSource
- Specified by:
appendSourcein interfaceClassLibraryBuilder- Parameters:
stream- the Java source as stream- Returns:
- this ClassLibraryBuilder instance
- Throws:
IOException- if an IOException is thrown, e.g. unsupported encoding
-
appendSource
- Specified by:
appendSourcein interfaceClassLibraryBuilder- Parameters:
reader- the Java source as reader- Returns:
- this ClassLibraryBuilder instance
-
setDebugLexer
Description copied from interface:ClassLibraryBuilderSet totrueto enable debug logging for the lexer- Specified by:
setDebugLexerin interfaceClassLibraryBuilder- Parameters:
debugLexer- the debug logging flag- Returns:
- this ClassLibraryBuilder instance
-
setDebugParser
Description copied from interface:ClassLibraryBuilderSet totrueto enable debug logging for the parser- Specified by:
setDebugParserin interfaceClassLibraryBuilder- Parameters:
debugParser- the debug logging flag- Returns:
- this ClassLibraryBuilder instance
-
setEncoding
- Specified by:
setEncodingin interfaceClassLibraryBuilder- Parameters:
encoding- set the encoding- Returns:
- this ClassLibraryBuilder instance
-
setErrorHander
Description copied from interface:ClassLibraryBuilderCan handle ParseExceptions instead of crashing. Has only effect on the appendSource() methods- Specified by:
setErrorHanderin interfaceClassLibraryBuilder- Parameters:
errorHandler- the errorHandler- Returns:
- this ClassLibraryBuilder instance
-
setModelBuilderFactory
Description copied from interface:ClassLibraryBuilderDefine theModelBuilderFactorywhich the parsers should use to construct the JavaModel Objects- Specified by:
setModelBuilderFactoryin interfaceClassLibraryBuilder- Parameters:
modelBuilderFactory- the modelBuilderFactory- Returns:
- this ClassLibraryBuilder instance
-
setModelWriterFactory
Description copied from interface:ClassLibraryBuilderDefine theModelWriterFactorywhich is used by the classes when calling for the codeBlock.- Specified by:
setModelWriterFactoryin interfaceClassLibraryBuilder- Parameters:
modelWriterFactory- the modelWriterFactory- Returns:
- this ClassLibraryBuilder instance
-
getClassLibrary
Description copied from interface:ClassLibraryBuilderGet the library based on the strategy of the implementation- Specified by:
getClassLibraryin interfaceClassLibraryBuilder- Returns:
- the constructed ClassLibrary
-
appendSource
- Specified by:
appendSourcein interfaceClassLibraryBuilder- Parameters:
url- the Java source as URL- Returns:
- this ClassLibraryBuilder instance
- Throws:
IOException- if an IOException occurs
-
appendSource
- Specified by:
appendSourcein interfaceClassLibraryBuilder- Parameters:
file- the Java source as file- Returns:
- this ClassLibraryBuilder instance
- Throws:
IOException- if an IOException occurs
-
addSource
- Specified by:
addSourcein interfaceClassLibraryBuilder- Parameters:
stream- the Java source as stream- Returns:
- the created JavaSource
- Throws:
IOException- if an IOException is thrown, e.g. unsupported encoding
-
addSource
Description copied from interface:ClassLibraryBuilderAdd the source content of the reader to the ClassLibrary and return the generated JavaSource- Specified by:
addSourcein interfaceClassLibraryBuilder- Parameters:
reader- the Java source as reader- Returns:
- the created JavaSource
-
addSource
- Specified by:
addSourcein interfaceClassLibraryBuilder- Parameters:
url- the Java source as URL- Returns:
- the created JavaSource
- Throws:
IOException- if an IOException occurs
-
addSource
- Specified by:
addSourcein interfaceClassLibraryBuilder- Parameters:
file- the Java source as file- Returns:
- the created JavaSource
- Throws:
IOException- if an IOException occurs
-
addSourceFolder
- Specified by:
addSourceFolderin interfaceClassLibraryBuilder- Parameters:
sourceFolder- the sourcefolder- Returns:
- the module info if the sourcefolder has a module-info.java, otherwise
null
-
prepareSourceLibrary
-
getSourceLibrary
-
getSourceFolderLibrary
-
newClassLoaderLibrary
Ability to override the implementation of ClassLoaderLibrary- Parameters:
parentLibrary- the parent library- Returns:
- a new ClassLoaderLibrary instance
- Since:
- 2.0
-
newSourceLibrary
Ability to override the implementation of SourceLibrary- Parameters:
parentLibrary- the parent library- Returns:
- a new SourceLibrary instance
- Since:
- 2.0
-
newSourceFolderLibrary
Ability to override the implementation of SourceFolderLibrary- Parameters:
parentLibrary- the parent library- Returns:
- a new SourceFolderLibrary instance
- Since:
- 2.0
-