Package org.apache.wiki.parser
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 Summary
Fields Modifier and Type Field Description protected static intATTACHMENTprotected static intCHARACTERThe token is a plain character.protected static intEDITprotected static intELEMENTThe token is a wikimarkup element.protected static intEMPTYprotected static intEXTERNALprotected static intIGNOREThe token is to be ignored.protected static intIMAGEprotected static intIMAGELINKprotected static intIMAGEWIKILINKprotected static intINTERWIKIprotected static intLOCALprotected static intLOCALREFprotected static intREAD-
Fields inherited from class org.apache.wiki.parser.MarkupParser
CLASS_ATTACHMENT, CLASS_EDITPAGE, CLASS_EXTERNAL, CLASS_FOOTNOTE, CLASS_FOOTNOTE_REF, CLASS_INTERWIKI, CLASS_TYPES, CLASS_WIKIPAGE, HASHLINK, m_attachmentLinkMutatorChain, m_context, m_engine, m_externalLinkMutatorChain, m_headingListenerChain, m_in, m_inlineImagePatterns, m_inlineImages, m_linkMutators, m_linkParsingOperations, m_localLinkMutatorChain, m_parseAccessRules, OUTLINK, OUTLINK_IMAGE, PROP_ALLOWHTML, PROP_CAMELCASELINKS, PROP_PLAINURIS, PROP_RUNPLUGINS, PROP_USEATTACHMENTIMAGE, PROP_USEOUTLINKIMAGE, PROP_USERELNOFOLLOW, PUSHBACK_BUFFER_SIZE
-
-
Constructor Summary
Constructors Constructor Description JSPWikiMarkupParser(Context context, java.io.Reader in)Creates a markup parser.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcallHeadingListenerChain(Heading param)Calls the heading listeners.protected java.lang.StringcallMutatorChain(java.util.Collection<StringTransmutator> list, java.lang.String text)Calls a transmutator chain.protected org.jdom2.ElementcreateAnchor(int type, java.lang.String link, java.lang.String text, java.lang.String section)Creates a JDOM anchor element.org.jdom2.ElementmakeHeading(int level, java.lang.String title, Heading hd)Returns XHTML for the heading.WikiDocumentparse()Parses the entire document from the Reader given in the constructor or set byMarkupParser.setInputReader(Reader).protected intparseToken(int ch)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.-
Methods inherited from class org.apache.wiki.parser.MarkupParser
addAttachmentLinkHook, addExternalLinkHook, addHeadingListener, addLinkTransmutator, addLocalLinkHook, cleanLink, disableAccessRules, enableImageInlining, getInlineImagePatterns, getPosition, initInlineImagePatterns, isImageInlining, isParseAccessRules, makeError, nextToken, pushBack, setInputReader, wikifyLink
-
-
-
-
Field Detail
-
READ
protected static final int READ
- See Also:
- Constant Field Values
-
EDIT
protected static final int EDIT
- See Also:
- Constant Field Values
-
EMPTY
protected static final int EMPTY
- See Also:
- Constant Field Values
-
LOCAL
protected static final int LOCAL
- See Also:
- Constant Field Values
-
LOCALREF
protected static final int LOCALREF
- See Also:
- Constant Field Values
-
IMAGE
protected static final int IMAGE
- See Also:
- Constant Field Values
-
EXTERNAL
protected static final int EXTERNAL
- See Also:
- Constant Field Values
-
INTERWIKI
protected static final int INTERWIKI
- See Also:
- Constant Field Values
-
IMAGELINK
protected static final int IMAGELINK
- See Also:
- Constant Field Values
-
IMAGEWIKILINK
protected static final int IMAGEWIKILINK
- See Also:
- Constant Field Values
-
ATTACHMENT
protected static final int ATTACHMENT
- See Also:
- Constant Field Values
-
CHARACTER
protected static final int CHARACTER
The token is a plain character.- See Also:
- Constant Field Values
-
ELEMENT
protected static final int ELEMENT
The token is a wikimarkup element.- See Also:
- Constant Field Values
-
IGNORE
protected static final int IGNORE
The token is to be ignored.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JSPWikiMarkupParser
public JSPWikiMarkupParser(Context context, java.io.Reader in)
Creates a markup parser.- Parameters:
context- The WikiContext which controls the parsingin- Where the data is read from.
-
-
Method Detail
-
callMutatorChain
protected java.lang.String callMutatorChain(java.util.Collection<StringTransmutator> list, java.lang.String text)
Calls a transmutator chain.- Parameters:
list- Chain to calltext- 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 abovelink- URL to which to link totext- Link textsection- 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 Headingtitle- the title for the headinghd- 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.
-
parse
public WikiDocument parse() throws java.io.IOException
Parses the entire document from the Reader given in the constructor or set byMarkupParser.setInputReader(Reader).- Specified by:
parsein classMarkupParser- Returns:
- A WikiDocument, ready to be passed to the renderer.
- Throws:
java.io.IOException- If parsing cannot be accomplished.
-
-