Package com.thoughtworks.qdox.library
Class OrderedClassLibraryBuilder
- java.lang.Object
-
- com.thoughtworks.qdox.library.OrderedClassLibraryBuilder
-
- All Implemented Interfaces:
ClassLibraryBuilder
,java.io.Serializable
public class OrderedClassLibraryBuilder extends java.lang.Object implements ClassLibraryBuilder
This library resolves JavaClasses in the order in which class sources are added.- Since:
- 2.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description OrderedClassLibraryBuilder()
Default 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JavaSource
addSource(java.io.File file)
JavaSource
addSource(java.io.InputStream stream)
JavaSource
addSource(java.io.Reader reader)
Add the source content of the reader to the ClassLibrary and return the generated JavaSourceJavaSource
addSource(java.net.URL url)
JavaModule
addSourceFolder(java.io.File sourceFolder)
ClassLibraryBuilder
appendClassLoader(java.lang.ClassLoader classLoader)
Append a classloader and return itselfClassLibraryBuilder
appendDefaultClassLoaders()
Add the defaultClassLoaders and return itseClassLibraryBuilder
appendSource(java.io.File file)
ClassLibraryBuilder
appendSource(java.io.InputStream stream)
ClassLibraryBuilder
appendSource(java.io.Reader reader)
ClassLibraryBuilder
appendSource(java.net.URL url)
ClassLibraryBuilder
appendSourceFolder(java.io.File sourceFolder)
ClassLibrary
getClassLibrary()
Get the library based on the strategy of the implementationprotected SourceLibrary
getSourceLibrary()
protected ClassLoaderLibrary
newClassLoaderLibrary(AbstractClassLibrary parentLibrary)
Ability to override the implementation of ClassLoaderLibraryprotected SourceFolderLibrary
newSourceFolderLibrary(AbstractClassLibrary parentLibrary)
Ability to override the implementation of SourceFolderLibraryprotected SourceLibrary
newSourceLibrary(AbstractClassLibrary parentLibrary)
Ability to override the implementation of SourceLibraryClassLibraryBuilder
setDebugLexer(boolean debugLexer)
Set totrue
to enable debug logging for the lexerClassLibraryBuilder
setDebugParser(boolean debugParser)
Set totrue
to enable debug logging for the parserClassLibraryBuilder
setEncoding(java.lang.String encoding)
ClassLibraryBuilder
setErrorHander(ErrorHandler errorHandler)
Can handle ParseExceptions instead of crashing.ClassLibraryBuilder
setModelBuilderFactory(ModelBuilderFactory modelBuilderFactory)
Define theModelBuilderFactory
which the parsers should use to construct the JavaModel ObjectsClassLibraryBuilder
setModelWriterFactory(ModelWriterFactory modelWriterFactory)
Define theModelWriterFactory
which is used by the classes when calling for the codeBlock.
-
-
-
Constructor Detail
-
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
public 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.- Parameters:
rootClassLibrary
- the parent Classlibrary
-
-
Method Detail
-
appendClassLoader
public ClassLibraryBuilder appendClassLoader(java.lang.ClassLoader classLoader)
Description copied from interface:ClassLibraryBuilder
Append a classloader and return itself- Specified by:
appendClassLoader
in interfaceClassLibraryBuilder
- Parameters:
classLoader
- the classloader to add- Returns:
- this ClassLibraryBuilder instance
-
appendDefaultClassLoaders
public ClassLibraryBuilder appendDefaultClassLoaders()
Description copied from interface:ClassLibraryBuilder
Add the defaultClassLoaders and return itse- Specified by:
appendDefaultClassLoaders
in interfaceClassLibraryBuilder
- Returns:
- this ClassLibraryBuilder instance
-
appendSourceFolder
public ClassLibraryBuilder appendSourceFolder(java.io.File sourceFolder)
- Specified by:
appendSourceFolder
in interfaceClassLibraryBuilder
- Parameters:
sourceFolder
- the source folder- Returns:
- this ClassLibraryBuilder instance
-
appendSource
public ClassLibraryBuilder appendSource(java.io.InputStream stream) throws java.io.IOException
- Specified by:
appendSource
in interfaceClassLibraryBuilder
- Parameters:
stream
- the Java source as stream- Returns:
- this ClassLibraryBuilder instance
- Throws:
java.io.IOException
- if an IOException is thrown, e.g. unsupported encoding
-
appendSource
public ClassLibraryBuilder appendSource(java.io.Reader reader)
- Specified by:
appendSource
in interfaceClassLibraryBuilder
- Parameters:
reader
- the Java source as reader- Returns:
- this ClassLibraryBuilder instance
-
setDebugLexer
public ClassLibraryBuilder setDebugLexer(boolean debugLexer)
Description copied from interface:ClassLibraryBuilder
Set totrue
to enable debug logging for the lexer- Specified by:
setDebugLexer
in interfaceClassLibraryBuilder
- Parameters:
debugLexer
- the debug logging flag- Returns:
- this ClassLibraryBuilder instance
-
setDebugParser
public ClassLibraryBuilder setDebugParser(boolean debugParser)
Description copied from interface:ClassLibraryBuilder
Set totrue
to enable debug logging for the parser- Specified by:
setDebugParser
in interfaceClassLibraryBuilder
- Parameters:
debugParser
- the debug logging flag- Returns:
- this ClassLibraryBuilder instance
-
setEncoding
public ClassLibraryBuilder setEncoding(java.lang.String encoding)
- Specified by:
setEncoding
in interfaceClassLibraryBuilder
- Parameters:
encoding
- set the encoding- Returns:
- this ClassLibraryBuilder instance
-
setErrorHander
public ClassLibraryBuilder setErrorHander(ErrorHandler errorHandler)
Description copied from interface:ClassLibraryBuilder
Can handle ParseExceptions instead of crashing. Has only effect on the appendSource() methods- Specified by:
setErrorHander
in interfaceClassLibraryBuilder
- Parameters:
errorHandler
- the errorHandler- Returns:
- this ClassLibraryBuilder instance
-
setModelBuilderFactory
public ClassLibraryBuilder setModelBuilderFactory(ModelBuilderFactory modelBuilderFactory)
Description copied from interface:ClassLibraryBuilder
Define theModelBuilderFactory
which the parsers should use to construct the JavaModel Objects- Specified by:
setModelBuilderFactory
in interfaceClassLibraryBuilder
- Parameters:
modelBuilderFactory
- the modelBuilderFactory- Returns:
- this ClassLibraryBuilder instance
-
setModelWriterFactory
public ClassLibraryBuilder setModelWriterFactory(ModelWriterFactory modelWriterFactory)
Description copied from interface:ClassLibraryBuilder
Define theModelWriterFactory
which is used by the classes when calling for the codeBlock.- Specified by:
setModelWriterFactory
in interfaceClassLibraryBuilder
- Parameters:
modelWriterFactory
- the modelWriterFactory- Returns:
- this ClassLibraryBuilder instance
-
getClassLibrary
public ClassLibrary getClassLibrary()
Description copied from interface:ClassLibraryBuilder
Get the library based on the strategy of the implementation- Specified by:
getClassLibrary
in interfaceClassLibraryBuilder
- Returns:
- the constructed ClassLibrary
-
appendSource
public ClassLibraryBuilder appendSource(java.net.URL url) throws java.io.IOException
- Specified by:
appendSource
in interfaceClassLibraryBuilder
- Parameters:
url
- the Java source as URL- Returns:
- this ClassLibraryBuilder instance
- Throws:
java.io.IOException
- if an IOException occurs
-
appendSource
public ClassLibraryBuilder appendSource(java.io.File file) throws java.io.IOException
- Specified by:
appendSource
in interfaceClassLibraryBuilder
- Parameters:
file
- the Java source as file- Returns:
- this ClassLibraryBuilder instance
- Throws:
java.io.IOException
- if an IOException occurs
-
addSource
public JavaSource addSource(java.io.InputStream stream) throws java.io.IOException
- Specified by:
addSource
in interfaceClassLibraryBuilder
- Parameters:
stream
- the Java source as stream- Returns:
- the created JavaSource
- Throws:
java.io.IOException
- if an IOException is thrown, e.g. unsupported encoding
-
addSource
public JavaSource addSource(java.io.Reader reader)
Description copied from interface:ClassLibraryBuilder
Add the source content of the reader to the ClassLibrary and return the generated JavaSource- Specified by:
addSource
in interfaceClassLibraryBuilder
- Parameters:
reader
- the Java source as reader- Returns:
- the created JavaSource
-
addSource
public JavaSource addSource(java.net.URL url) throws java.io.IOException
- Specified by:
addSource
in interfaceClassLibraryBuilder
- Parameters:
url
- the Java source as URL- Returns:
- the created JavaSource
- Throws:
java.io.IOException
- if an IOException occurs
-
addSource
public JavaSource addSource(java.io.File file) throws java.io.IOException
- Specified by:
addSource
in interfaceClassLibraryBuilder
- Parameters:
file
- the Java source as file- Returns:
- the created JavaSource
- Throws:
java.io.IOException
- if an IOException occurs
-
addSourceFolder
public JavaModule addSourceFolder(java.io.File sourceFolder)
- Specified by:
addSourceFolder
in interfaceClassLibraryBuilder
- Parameters:
sourceFolder
- the sourcefolder- Returns:
- the module info if the sourcefolder has a module-info.java, otherwise
null
-
getSourceLibrary
protected final SourceLibrary getSourceLibrary()
-
newClassLoaderLibrary
protected ClassLoaderLibrary newClassLoaderLibrary(AbstractClassLibrary parentLibrary)
Ability to override the implementation of ClassLoaderLibrary- Parameters:
parentLibrary
- the parent library- Returns:
- a new ClassLoaderLibrary instance
- Since:
- 2.0
-
newSourceLibrary
protected SourceLibrary newSourceLibrary(AbstractClassLibrary parentLibrary)
Ability to override the implementation of SourceLibrary- Parameters:
parentLibrary
- the parent library- Returns:
- a new SourceLibrary instance
- Since:
- 2.0
-
newSourceFolderLibrary
protected SourceFolderLibrary newSourceFolderLibrary(AbstractClassLibrary parentLibrary)
Ability to override the implementation of SourceFolderLibrary- Parameters:
parentLibrary
- the parent library- Returns:
- a new SourceFolderLibrary instance
- Since:
- 2.0
-
-