Class JSPWikiMarkupParser

java.lang.Object
org.apache.wiki.parser.MarkupParser
org.apache.wiki.parser.JSPWikiMarkupParser

public class JSPWikiMarkupParser
extends MarkupParser
Parses JSPWiki-style markup into a WikiDocument DOM tree. This class is the heart and soul of JSPWiki : make sure you test properly anything that is added, or else it breaks down horribly.
Since:
2.4
  • Field Details

  • Constructor Details

    • JSPWikiMarkupParser

      public JSPWikiMarkupParser​(Context context, java.io.Reader in)
      Creates a markup parser.
      Parameters:
      context - The WikiContext which controls the parsing
      in - Where the data is read from.
  • Method Details

    • callMutatorChain

      protected java.lang.String callMutatorChain​(java.util.Collection<StringTransmutator> list, java.lang.String text)
      Calls a transmutator chain.
      Parameters:
      list - Chain to call
      text - Text that should be passed to the mutate() method of each of the mutators in the chain.
      Returns:
      The result of the mutation.
    • callHeadingListenerChain

      protected void callHeadingListenerChain​(Heading param)
      Calls the heading listeners.
      Parameters:
      param - A Heading object.
    • createAnchor

      protected org.jdom2.Element createAnchor​(int type, java.lang.String link, java.lang.String text, java.lang.String section)
      Creates a JDOM anchor element. Can be overridden to change the URL creation, if you really know what you are doing.
      Parameters:
      type - One of the types above
      link - URL to which to link to
      text - Link text
      section - If a particular section identifier is required.
      Returns:
      An A element.
      Since:
      2.4.78
    • makeHeading

      public org.jdom2.Element makeHeading​(int level, java.lang.String title, Heading hd)
      Returns XHTML for the heading.
      Parameters:
      level - The level of the heading. @see Heading
      title - the title for the heading
      hd - a List to which heading should be added
      Returns:
      An Element containing the heading
    • parseToken

      protected int parseToken​(int ch) throws java.io.IOException
      Return CHARACTER, if you think this was a plain character; ELEMENT, if you think this was a wiki markup element, and IGNORE, if you think we should ignore this altogether.

      To add your own MarkupParser, you can override this method, but it is recommended that you call super.parseToken() as well to gain advantage of JSPWiki's own markup. You can call it at the start of your own parseToken() or end - it does not matter.

      Parameters:
      ch - The character under investigation
      Returns:
      ELEMENT, CHARACTER or IGNORE.
      Throws:
      java.io.IOException - If parsing fails.
    • parse

      public WikiDocument parse() throws java.io.IOException
      Parses the entire document from the Reader given in the constructor or set by MarkupParser.setInputReader(Reader).
      Specified by:
      parse in class MarkupParser
      Returns:
      A WikiDocument, ready to be passed to the renderer.
      Throws:
      java.io.IOException - If parsing cannot be accomplished.