Class AbstractParser

java.lang.Object
de.hybris.platform.commons.translator.parsers.AbstractParser
Direct Known Subclasses:
HtmlSimpleEntityParser, HtmlSimpleParser

public abstract class AbstractParser extends Object
Abstract class for all translators parsers Parsers are classes used to search for special parts of text (usually html tags) and then to produce AbstractNodes from them. AbstractParser keep information about regular expression that should be used to search for these special parts of text and contain mechanism how to create node from them.
  • Field Details

    • start

      protected String start
      expression used to find starting tag
    • end

      protected String end
      expression used to find closing tag
    • name

      protected String name
      parser name, this name should be given to created node
  • Constructor Details

    • AbstractParser

      public AbstractParser()
    • AbstractParser

      public AbstractParser(String name, String start, String end)
      Constructor for AbstractParser
      Parameters:
      name - parser name
      start - regular expression that would be used to find beginning of text from which node has to be created
      end - regular expression that would be used to find end of text from which node has to be created
  • Method Details

    • getEnd

      public String getEnd()
      Returns:
      the end
    • setEnd

      public void setEnd(String end)
      Parameters:
      end - the end to set
    • getStart

      public String getStart()
      Returns:
      the start
    • setStart

      public void setStart(String start)
      Parameters:
      start - the start to set
    • getName

      public String getName()
      Returns:
      the name
    • setName

      public void setName(String name)
      Parameters:
      name - the name to set
    • getStartExpression

      public abstract String getStartExpression()
      Returns:
      regular expression that would be used to search for beginning of text from which node would be created
    • getStartEndExpression

      public abstract String getStartEndExpression()
      Returns:
      regular expression that would be used to check if beginning of text is not also the finishing one ( like br html tag which have no separate closing tag)
    • getEndExpression

      public abstract String getEndExpression(String start)
      Returns:
      regular expression that would be used to search for closing tag for a given start expression.
    • createNode

      public abstract AbstractNode createNode(String start, String end, String text, Translator translator)
      Create AbstractNode instance from a given text
      Parameters:
      start - is a String that was found when searching for a start of text that should be used to create node
      end - is a String that was found when searching for a end of text that should be used to create node
      text - text is whole text that was between start and end Strings
      translator - reference to Translator that would be used to search for sub tags in given text
      Returns:
      node that was created from the given text (can be with subnodes if any was found in text)