Class AbstractParser

  • All Implemented Interfaces:
    org.apache.maven.doxia.logging.LogEnabled, Parser
    Direct Known Subclasses:
    AbstractTextParser, AbstractXmlParser

    public abstract class AbstractParser
    extends java.lang.Object
    implements Parser
    An abstract base class that defines some convenience methods for parsers. Provides a macro mechanism to give dynamic functionalities for the parsing.
    Since:
    1.0
    Author:
    Jason van Zyl
    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractParser()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      protected static java.lang.String doxiaVersion()
      The current Doxia version.
      void enableLogging​(org.apache.maven.doxia.logging.Log log)
      void executeMacro​(java.lang.String macroId, MacroRequest request, org.apache.maven.doxia.sink.Sink sink)
      Execute a macro on the given sink.
      protected java.io.File getBasedir()
      Deprecated.
      this does not work in multi-module builds, see DOXIA-373
      protected org.apache.maven.doxia.logging.Log getLog()
      Returns the current logger for this parser.
      protected MacroManager getMacroManager()
      Gets the current MacroManager.
      int getType()
      The parser type value could be Parser.UNKNOWN_TYPE, Parser.TXT_TYPE or Parser.XML_TYPE.
      protected void init()
      Initialize the parser.
      boolean isEmitComments()
      isEmitComments.
      protected boolean isSecondParsing()
      Indicates if we are currently parsing a second time.
      void parse​(java.io.Reader source, org.apache.maven.doxia.sink.Sink sink, java.lang.String reference)
      Parses the given source model and emits Doxia events into the given sink.
      void parse​(java.lang.String string, org.apache.maven.doxia.sink.Sink sink)
      Convenience method to parse an arbitrary string and emit events into the given sink.
      void setEmitComments​(boolean emitComments)
      When comments are found in source markup, emit comment Doxia events or just ignore?
      void setSecondParsing​(boolean second)
      Set secondParsing to true, if we need a second parsing.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.apache.maven.doxia.parser.Parser

        parse
    • Constructor Detail

      • AbstractParser

        public AbstractParser()
    • Method Detail

      • setEmitComments

        public void setEmitComments​(boolean emitComments)
        When comments are found in source markup, emit comment Doxia events or just ignore?
        Specified by:
        setEmitComments in interface Parser
        Parameters:
        emitComments - true (default value) to emit comment Doxia events
      • isEmitComments

        public boolean isEmitComments()

        isEmitComments.

        Specified by:
        isEmitComments in interface Parser
        Returns:
        a boolean.
      • getBasedir

        protected java.io.File getBasedir()
        Deprecated.
        this does not work in multi-module builds, see DOXIA-373
        Returns the current base directory.
        Returns:
        The base directory.
      • parse

        public void parse​(java.lang.String string,
                          org.apache.maven.doxia.sink.Sink sink)
                   throws ParseException
        Convenience method to parse an arbitrary string and emit events into the given sink.
        Parameters:
        string - A string that provides the source input.
        sink - A sink that consumes the Doxia events.
        Throws:
        ParseException - if the string could not be parsed.
        Since:
        1.1
      • parse

        public void parse​(java.io.Reader source,
                          org.apache.maven.doxia.sink.Sink sink,
                          java.lang.String reference)
                   throws ParseException
        Parses the given source model and emits Doxia events into the given sink.
        Specified by:
        parse in interface Parser
        Parameters:
        source - not null reader that provides the source document. You could use newReader methods from ReaderFactory.
        sink - A sink that consumes the Doxia events.
        reference - the reference
        Throws:
        ParseException - if the model could not be parsed.
      • setSecondParsing

        public void setSecondParsing​(boolean second)
        Set secondParsing to true, if we need a second parsing.
        Parameters:
        second - True for second parsing.
      • isSecondParsing

        protected boolean isSecondParsing()
        Indicates if we are currently parsing a second time.
        Returns:
        true if we are currently parsing a second time.
        Since:
        1.1
      • enableLogging

        public void enableLogging​(org.apache.maven.doxia.logging.Log log)
        Specified by:
        enableLogging in interface org.apache.maven.doxia.logging.LogEnabled
      • getLog

        protected org.apache.maven.doxia.logging.Log getLog()
        Returns the current logger for this parser. If no logger has been configured yet, a new SystemStreamLog is returned.
        Returns:
        Log
        Since:
        1.1
      • doxiaVersion

        protected static java.lang.String doxiaVersion()
        The current Doxia version.
        Returns:
        the current Doxia version as a String.
        Since:
        1.2