Class TextParser

java.lang.Object
org.apache.maven.doxia.module.twiki.parser.TextParser

public class TextParser extends Object
Parse almost plain text in search of WikiWords, links, ...
  • Field Details

    • WIKIWORD_PATTERN

      private static final Pattern WIKIWORD_PATTERN
      pattern to detect WikiWords
    • ANCHOR_PATTERN

      private static final Pattern ANCHOR_PATTERN
      anchor name
    • URL_PATTERN

      private static final Pattern URL_PATTERN
      url word
    • IMAGE_PATTERN

      private static final Pattern IMAGE_PATTERN
      image pattern specification
    • IMAGE_TAG_PATTERN

      private static final Pattern IMAGE_TAG_PATTERN
      image tag pattern specification (used for images at relative URLs)
    • HTML_TAG_PATTERN

      private static final Pattern HTML_TAG_PATTERN
      HTML tag pattern
    • wikiWordLinkResolver

      private final WikiWordLinkResolver wikiWordLinkResolver
      resolves wikiWordLinks
  • Constructor Details

    • TextParser

      public TextParser(WikiWordLinkResolver resolver)
      Creates the TextParser.
      Parameters:
      resolver - resolver for wikiWord links
  • Method Details

    • parse

      public final List<Block> parse(String line)

      parse.

      Parameters:
      line - line to parse
      Returns:
      a list of block that represents the input
    • parseImage

      private void parseImage(String line, List<Block> ret, Matcher imageTagMatcher)
      Parses the image tag
      Parameters:
      line - the line to parse
      ret - where the results live
      imageTagMatcher - image tag matcher
    • parseUrl

      private void parseUrl(String line, List<Block> ret, Matcher urlMatcher)
      Parses the url
      Parameters:
      line - the line to parse
      ret - where the results live
      urlMatcher - url matcher
    • parseAnchor

      private void parseAnchor(String line, List<Block> ret, Matcher anchorMatcher)
      Parses the anchor
      Parameters:
      line - the line to parse
      ret - where the results live
      anchorMatcher - anchor matcher
    • parseForcedLink

      private void parseForcedLink(String line, List<Block> ret, Matcher forcedLinkMatcher)
      Parses the link
      Parameters:
      line - line to parse
      ret - where the results live
      forcedLinkMatcher - forced link matcher
    • createLink

      private Block createLink(String link, String showText)
      Decides between a WikiWordBlock or a a LinkBlock
      Parameters:
      link - the link text
      showText - the show text.
      Returns:
      either a WikiWordBlock or a LinkBlock
    • parseWiki

      private void parseWiki(String line, List<Block> ret, Matcher wikiMatcher)
      Parses a wiki word
      Parameters:
      line - the line to parse
      ret - where the results live
      wikiMatcher - wiki matcher
    • parseLink

      private void parseLink(String line, List<Block> ret, Matcher linkMatcher)
      Parses a link
      Parameters:
      line - the line to parse
      ret - where the results live
      linkMatcher - link matcher
    • parseXHTML

      private void parseXHTML(String line, List<Block> ret, Matcher xhtmlMatcher)
      Parses xhtml.
      Parameters:
      line - the line to parse
      ret - where the results live
      xhtmlMatcher - xhtml matcher
    • isAWord

      private boolean isAWord(Matcher m, String line)
      Parameters:
      m - matcher to test
      line - line to test
      Returns:
      true if 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(Matcher m, String line)
      Parameters:
      m - matcher to test
      line - line to test
      Returns:
      true if it is the beginning of a word
    • endLikeWord

      private boolean endLikeWord(Matcher m, String line)
      Parameters:
      m - matcher to test
      line - 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:
      true if c is a space char