Interface ClassLibraryBuilder

  • All Superinterfaces:
    java.io.Serializable
    All Known Implementing Classes:
    OrderedClassLibraryBuilder, SortedClassLibraryBuilder

    public interface ClassLibraryBuilder
    extends java.io.Serializable
    This builder helps to construct a library. All kinds of sourcetypes are supported and it's up to the implementation how to bind these types. For instance: The SortedClassLibraryBuilder bundles all classloaders, all sourcefolders and all sources. The OrderedClassLibraryBuilder on the other hand keeps track of the order in which sourcetypes are added.
    Since:
    2.0
    • Method Detail

      • appendClassLoader

        ClassLibraryBuilder appendClassLoader​(java.lang.ClassLoader classLoader)
        Append a classloader and return itself
        Parameters:
        classLoader - the classloader to add
        Returns:
        this ClassLibraryBuilder instance
      • appendDefaultClassLoaders

        ClassLibraryBuilder appendDefaultClassLoaders()
        Add the defaultClassLoaders and return itse
        Returns:
        this ClassLibraryBuilder instance
      • appendSourceFolder

        ClassLibraryBuilder appendSourceFolder​(java.io.File sourceFolder)
        Parameters:
        sourceFolder - the source folder
        Returns:
        this ClassLibraryBuilder instance
      • appendSource

        ClassLibraryBuilder appendSource​(java.io.InputStream stream)
                                  throws java.io.IOException
        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

        ClassLibraryBuilder appendSource​(java.io.Reader reader)
        Parameters:
        reader - the Java source as reader
        Returns:
        this ClassLibraryBuilder instance
      • appendSource

        ClassLibraryBuilder appendSource​(java.net.URL url)
                                  throws java.io.IOException
        Parameters:
        url - the Java source as URL
        Returns:
        this ClassLibraryBuilder instance
        Throws:
        java.io.IOException - if an IOException occurs
      • appendSource

        ClassLibraryBuilder appendSource​(java.io.File file)
                                  throws java.io.IOException
        Parameters:
        file - the Java source as file
        Returns:
        this ClassLibraryBuilder instance
        Throws:
        java.io.IOException - if an IOException occurs
      • addSource

        JavaSource addSource​(java.io.InputStream stream)
                      throws java.io.IOException
        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

        JavaSource addSource​(java.io.Reader reader)
        Add the source content of the reader to the ClassLibrary and return the generated JavaSource
        Parameters:
        reader - the Java source as reader
        Returns:
        the created JavaSource
      • addSource

        JavaSource addSource​(java.net.URL url)
                      throws java.io.IOException
        Parameters:
        url - the Java source as URL
        Returns:
        the created JavaSource
        Throws:
        java.io.IOException - if an IOException occurs
      • addSource

        JavaSource addSource​(java.io.File file)
                      throws java.io.IOException
        Parameters:
        file - the Java source as file
        Returns:
        the created JavaSource
        Throws:
        java.io.IOException - if an IOException occurs
      • setDebugLexer

        ClassLibraryBuilder setDebugLexer​(boolean debugLexer)
        Set to true to enable debug logging for the lexer
        Parameters:
        debugLexer - the debug logging flag
        Returns:
        this ClassLibraryBuilder instance
      • setDebugParser

        ClassLibraryBuilder setDebugParser​(boolean debugParser)
        Set to true to enable debug logging for the parser
        Parameters:
        debugParser - the debug logging flag
        Returns:
        this ClassLibraryBuilder instance
      • setEncoding

        ClassLibraryBuilder setEncoding​(java.lang.String encoding)
        Parameters:
        encoding - set the encoding
        Returns:
        this ClassLibraryBuilder instance
      • setModelBuilderFactory

        ClassLibraryBuilder setModelBuilderFactory​(ModelBuilderFactory factory)
        Define the ModelBuilderFactory which the parsers should use to construct the JavaModel Objects
        Parameters:
        factory - the modelBuilderFactory
        Returns:
        this ClassLibraryBuilder instance
      • setModelWriterFactory

        ClassLibraryBuilder setModelWriterFactory​(ModelWriterFactory factory)
        Define the ModelWriterFactory which is used by the classes when calling for the codeBlock.
        Parameters:
        factory - the modelWriterFactory
        Returns:
        this ClassLibraryBuilder instance
      • getClassLibrary

        ClassLibrary getClassLibrary()
        Get the library based on the strategy of the implementation
        Returns:
        the constructed ClassLibrary
      • setErrorHander

        ClassLibraryBuilder setErrorHander​(ErrorHandler errorHandler)
        Can handle ParseExceptions instead of crashing. Has only effect on the appendSource() methods
        Parameters:
        errorHandler - the errorHandler
        Returns:
        this ClassLibraryBuilder instance
      • addSourceFolder

        JavaModule addSourceFolder​(java.io.File sourceFolder)
        Parameters:
        sourceFolder - the sourcefolder
        Returns:
        the module info if the sourcefolder has a module-info.java, otherwise null
        Since:
        2.0