Class SourceLibrary

  • All Implemented Interfaces:
    ClassLibrary, java.io.Serializable
    Direct Known Subclasses:
    SourceFolderLibrary

    public class SourceLibrary
    extends AbstractClassLibrary
    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:
    Serialized Form
    • Constructor Detail

      • SourceLibrary

        public SourceLibrary​(AbstractClassLibrary parent)
        Create a new instance of SourceLibrary and chain it to the parent
        Parameters:
        parent - the parent classLibrary
    • Method Detail

      • addSource

        public JavaSource addSource​(java.io.Reader reader)
                             throws ParseException
        Add a Reader containing java code to this library
        Parameters:
        reader - a Reader 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

        public JavaSource addSource​(java.io.InputStream stream)
                             throws ParseException,
                                    java.io.IOException
        Add an InputStream containing java code to this library
        Parameters:
        stream - an InputStream which should contain java code
        Returns:
        The constructed JavaSource object of this stream
        Throws:
        ParseException - if this content couldn't be parsed to a JavaModel
        java.io.IOException - if an IOException occurs
      • addSource

        public JavaSource addSource​(java.net.URL url)
                             throws ParseException,
                                    java.io.IOException
        Add a URL containing java code to this library
        Parameters:
        url - a URL which should contain java code
        Returns:
        The constructed JavaSource object of this url
        Throws:
        ParseException - if this content couldn't be parsed to a JavaModel
        java.io.IOException - if an IOException occurs
      • addSource

        public JavaSource addSource​(java.io.File file)
                             throws ParseException,
                                    java.io.IOException
        Add a File containing java code to this library
        Parameters:
        file - a File which should contain java code
        Returns:
        The constructed JavaSource object of this file
        Throws:
        ParseException - if this content couldn't be parsed to a JavaModel
        java.io.IOException - if an IOException occurs
      • resolveJavaClass

        protected JavaClass resolveJavaClass​(java.lang.String name)
        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 class AbstractClassLibrary
        Parameters:
        name - the fully qualified name
        Returns:
        the resolved JavaClass, otherwise null
      • registerJavaSource

        protected final void registerJavaSource​(JavaSource source)
        Parameters:
        source - the source, might be null
      • 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

        public final void setEncoding​(java.lang.String encoding)
        Sets the encoding to use when parsing a URL or InputStreamReader
        Parameters:
        encoding - the source encoding
      • getEncoding

        public final java.lang.String getEncoding()
      • setErrorHandler

        public final void setErrorHandler​(ErrorHandler errorHandler)
      • getErrorHandler

        public final ErrorHandler getErrorHandler()
      • containsClassReference

        protected boolean containsClassReference​(java.lang.String name)
        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 class AbstractClassLibrary
        Parameters:
        name - the fully qualified name of the class
        Returns:
        true if this ClassLibrary has a reference to this class.