Class AptParser

All Implemented Interfaces:
MacroExecutor, Markup, TextMarkup, AptMarkup, Parser

@Singleton @Named("apt") public class AptParser extends AbstractTextParser implements AptMarkup
The APT parser.
Based on the APTconvert project.
Since:
1.0
  • Field Details

  • Constructor Details

  • Method Details

    • parse

      public void parse(Reader source, Sink sink) throws ParseException
      Description copied from interface: Parser
      Parses the given source model and emits Doxia events into the given sink. Shortcut for Parser.parse(Reader, Sink, String) with last argument being null.
      Specified by:
      parse in interface Parser
      Overrides:
      parse in class AbstractParser
      Parameters:
      source - not null reader that provides the source document.
      sink - A sink that consumes the Doxia events.
      Throws:
      ParseException - if the model could not be parsed.
    • parse

      public void parse(Reader source, Sink sink, String reference) throws ParseException
      Description copied from interface: Parser
      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.
      sink - A sink that consumes the Doxia events.
      reference - a string identifying the source (for file based documents the source file path)
      Throws:
      ParseException - if the model could not be parsed.
    • getSourceName

      Returns the name of the Apt source document.
      Returns:
      the source name.
    • getSourceLineNumber

      public int getSourceLineNumber()
      Returns the current line number of the Apt source document.
      Returns:
      the line number.
    • nextLine

      protected void nextLine() throws AptParseException
      Parse the next line of the Apt source document.
      Throws:
      AptParseException - if something goes wrong.
    • doTraverseText

      protected void doTraverseText(String text, int begin, int end, Sink sink) throws AptParseException
      Parse the given text.
      Parameters:
      text - the text to parse.
      begin - offset.
      end - offset.
      sink - the sink to receive the events.
      Throws:
      AptParseException - if something goes wrong.
    • charAt

      protected static char charAt(String string, int length, int i)
      Returns the character at position i of the given string.
      Parameters:
      string - the string.
      length - length.
      i - offset.
      Returns:
      the character, or '\0' if i > length.
    • skipSpace

      protected static int skipSpace(String string, int length, int i)
      Skip spaces.
      Parameters:
      string - string.
      length - length.
      i - offset.
      Returns:
      int.
    • replaceAll

      protected static String replaceAll(String string, String oldSub, String newSub)
      Replace part of a string.
      Parameters:
      string - the string
      oldSub - the substring to replace
      newSub - the replacement string
      Returns:
      String
    • init

      protected void init()
      Initialize the parser. This is called first by AbstractParser.parse(java.io.Reader, org.apache.maven.doxia.sink.Sink) and can be used to set the parser into a clear state so it can be re-used.
      Overrides:
      init in class AbstractParser