Class TextParser
- java.lang.Object
-
- org.apache.maven.doxia.module.twiki.parser.TextParser
-
public class TextParser extends java.lang.ObjectParse almost plain text in search of WikiWords, links, ...- Version:
- $Id$
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.regex.PatternANCHOR_PATTERNanchor nameprivate static java.util.regex.PatternFORCEDLINK_PATTERNpattern to detect ForcedLinks links [[reference asd]]private static java.util.regex.PatternHTML_TAG_PATTERNHTML tag patternprivate static java.util.regex.PatternIMAGE_PATTERNimage pattern specificationprivate static java.util.regex.PatternIMAGE_TAG_PATTERNimage tag pattern specification (used for images at relative URLs)private booleannoautolinkresolves noautolink tagprivate static java.util.regex.PatternSPECIFICLINK_PATTERNpattern to detect SpecificLinks links [[reference][text]]private static java.util.regex.PatternURL_PATTERNurl wordprivate static java.util.regex.PatternWIKIWORD_PATTERNpattern to detect WikiWordsprivate WikiWordLinkResolverwikiWordLinkResolverresolves wikiWordLinks
-
Constructor Summary
Constructors Constructor Description TextParser(WikiWordLinkResolver resolver)Creates the TextParser.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private BlockcreateLink(java.lang.String link, java.lang.String showText)Decides between a WikiWordBlock or a a LinkBlockprivate booleanendLikeWord(java.util.regex.Matcher m, java.lang.String line)private booleanisAWord(java.util.regex.Matcher m, java.lang.String line)private booleanisSpace(char c)java.util.List<Block>parse(java.lang.String line)parse.private voidparseAnchor(java.lang.String line, java.util.List<Block> ret, java.util.regex.Matcher anchorMatcher)Parses the anchorprivate voidparseForcedLink(java.lang.String line, java.util.List<Block> ret, java.util.regex.Matcher forcedLinkMatcher)Parses the linkprivate voidparseImage(java.lang.String line, java.util.List<Block> ret, java.util.regex.Matcher imageTagMatcher)Parses the image tagprivate voidparseLink(java.lang.String line, java.util.List<Block> ret, java.util.regex.Matcher linkMatcher)Parses a linkprivate voidparseUrl(java.lang.String line, java.util.List<Block> ret, java.util.regex.Matcher urlMatcher)Parses the urlprivate voidparseWiki(java.lang.String line, java.util.List<Block> ret, java.util.regex.Matcher wikiMatcher)Parses a wiki wordprivate voidparseXHTML(java.lang.String line, java.util.List<Block> ret, java.util.regex.Matcher xhtmlMatcher)Parses xhtml.private booleanstartLikeWord(java.util.regex.Matcher m, java.lang.String line)
-
-
-
Field Detail
-
WIKIWORD_PATTERN
private static final java.util.regex.Pattern WIKIWORD_PATTERN
pattern to detect WikiWords
-
SPECIFICLINK_PATTERN
private static final java.util.regex.Pattern SPECIFICLINK_PATTERN
pattern to detect SpecificLinks links [[reference][text]]
-
FORCEDLINK_PATTERN
private static final java.util.regex.Pattern FORCEDLINK_PATTERN
pattern to detect ForcedLinks links [[reference asd]]
-
ANCHOR_PATTERN
private static final java.util.regex.Pattern ANCHOR_PATTERN
anchor name
-
URL_PATTERN
private static final java.util.regex.Pattern URL_PATTERN
url word
-
IMAGE_PATTERN
private static final java.util.regex.Pattern IMAGE_PATTERN
image pattern specification
-
IMAGE_TAG_PATTERN
private static final java.util.regex.Pattern IMAGE_TAG_PATTERN
image tag pattern specification (used for images at relative URLs)
-
HTML_TAG_PATTERN
private static final java.util.regex.Pattern HTML_TAG_PATTERN
HTML tag pattern
-
wikiWordLinkResolver
private final WikiWordLinkResolver wikiWordLinkResolver
resolves wikiWordLinks
-
noautolink
private boolean noautolink
resolves noautolink tag
-
-
Constructor Detail
-
TextParser
public TextParser(WikiWordLinkResolver resolver)
Creates the TextParser.- Parameters:
resolver- resolver for wikiWord links
-
-
Method Detail
-
parse
public final java.util.List<Block> parse(java.lang.String line)
parse.
- Parameters:
line- line to parse- Returns:
- a list of block that represents the input
-
parseImage
private void parseImage(java.lang.String line, java.util.List<Block> ret, java.util.regex.Matcher imageTagMatcher)Parses the image tag- Parameters:
line- the line to parseret- where the results liveimageTagMatcher- image tag matcher
-
parseUrl
private void parseUrl(java.lang.String line, java.util.List<Block> ret, java.util.regex.Matcher urlMatcher)Parses the url- Parameters:
line- the line to parseret- where the results liveurlMatcher- url matcher
-
parseAnchor
private void parseAnchor(java.lang.String line, java.util.List<Block> ret, java.util.regex.Matcher anchorMatcher)Parses the anchor- Parameters:
line- the line to parseret- where the results liveanchorMatcher- anchor matcher
-
parseForcedLink
private void parseForcedLink(java.lang.String line, java.util.List<Block> ret, java.util.regex.Matcher forcedLinkMatcher)Parses the link- Parameters:
line- line to parseret- where the results liveforcedLinkMatcher- forced link matcher
-
createLink
private Block createLink(java.lang.String link, java.lang.String showText)
Decides between a WikiWordBlock or a a LinkBlock- Parameters:
link- the link textshowText- the show text.- Returns:
- either a WikiWordBlock or a LinkBlock
-
parseWiki
private void parseWiki(java.lang.String line, java.util.List<Block> ret, java.util.regex.Matcher wikiMatcher)Parses a wiki word- Parameters:
line- the line to parseret- where the results livewikiMatcher- wiki matcher
-
parseLink
private void parseLink(java.lang.String line, java.util.List<Block> ret, java.util.regex.Matcher linkMatcher)Parses a link- Parameters:
line- the line to parseret- where the results livelinkMatcher- link matcher
-
parseXHTML
private void parseXHTML(java.lang.String line, java.util.List<Block> ret, java.util.regex.Matcher xhtmlMatcher)Parses xhtml.- Parameters:
line- the line to parseret- where the results livexhtmlMatcher- xhtml matcher
-
isAWord
private boolean isAWord(java.util.regex.Matcher m, java.lang.String line)- Parameters:
m- matcher to testline- line to test- Returns:
trueif the match on m represent a word (must be a space before the word or must be the beginning of the line)
-
startLikeWord
private boolean startLikeWord(java.util.regex.Matcher m, java.lang.String line)- Parameters:
m- matcher to testline- line to test- Returns:
- true if it is the beginning of a word
-
endLikeWord
private boolean endLikeWord(java.util.regex.Matcher m, java.lang.String line)- Parameters:
m- matcher to testline- line to test- Returns:
- true if it is the end of a word
-
isSpace
private boolean isSpace(char c)
- Parameters:
c- char to test- Returns:
trueif c is a space char
-
-