Class AbstractParser

  • Direct Known Subclasses:
    HtmlSimpleEntityParser, HtmlSimpleParser

    public abstract class AbstractParser
    extends java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String end
      expression used to find closing tag
      protected java.lang.String name
      parser name, this name should be given to created node
      protected java.lang.String start
      expression used to find starting tag
    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractParser()  
      AbstractParser​(java.lang.String name, java.lang.String start, java.lang.String end)
      Constructor for AbstractParser
    • Field Detail

      • start

        protected java.lang.String start
        expression used to find starting tag
      • end

        protected java.lang.String end
        expression used to find closing tag
      • name

        protected java.lang.String name
        parser name, this name should be given to created node
    • Constructor Detail

      • AbstractParser

        public AbstractParser()
      • AbstractParser

        public AbstractParser​(java.lang.String name,
                              java.lang.String start,
                              java.lang.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 Detail

      • getEnd

        public java.lang.String getEnd()
        Returns:
        the end
      • setEnd

        public void setEnd​(java.lang.String end)
        Parameters:
        end - the end to set
      • getStart

        public java.lang.String getStart()
        Returns:
        the start
      • setStart

        public void setStart​(java.lang.String start)
        Parameters:
        start - the start to set
      • getName

        public java.lang.String getName()
        Returns:
        the name
      • setName

        public void setName​(java.lang.String name)
        Parameters:
        name - the name to set
      • getStartExpression

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

        public abstract java.lang.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 java.lang.String getEndExpression​(java.lang.String start)
        Returns:
        regular expression that would be used to search for closing tag for a given start expression.
      • createNode

        public abstract AbstractNode createNode​(java.lang.String start,
                                                java.lang.String end,
                                                java.lang.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)