Class HtmlSimpleParser

  • Direct Known Subclasses:
    HtmlListParser, HtmlTableParser

    public class HtmlSimpleParser
    extends AbstractParser
    HtmlSimpleParser is a simple implementation of the AbstractParser used by Translator to search html tags. Additionally this parser store data about all attributes that are inside tags (like width, style or class).
    • Constructor Summary

      Constructors 
      Constructor Description
      HtmlSimpleParser()  
      HtmlSimpleParser​(java.lang.String name, java.lang.String start, java.lang.String end)
      standard constructor implementation
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      AbstractNode createNode​(java.lang.String start, java.lang.String end, java.lang.String text, Translator translator)
      Create AbstractNode instance from a given text
      java.util.Map generateAttributes​(java.lang.String tag)
      serach for pairs attributeKey="attributeValue" in text
      java.lang.String getEndExpression​(java.lang.String start)
      convert end parameter to exprresion
      that is used to find closing tag
      java.lang.String getStartEndExpression()
      convert start parameter to exprresion
      that is used to check if tag has separate closing tag
      or is already closed
      java.lang.String getStartExpression()
      convert start parameter to exprresion
      that is used to find starting tag
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HtmlSimpleParser

        public HtmlSimpleParser()
      • HtmlSimpleParser

        public HtmlSimpleParser​(java.lang.String name,
                                java.lang.String start,
                                java.lang.String end)
        standard constructor implementation
        Parameters:
        name -
        start -
        end -
    • Method Detail

      • createNode

        public AbstractNode createNode​(java.lang.String start,
                                       java.lang.String end,
                                       java.lang.String text,
                                       Translator translator)
        Description copied from class: AbstractParser
        Create AbstractNode instance from a given text
        Specified by:
        createNode in class AbstractParser
        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:
        SimpleNode
      • getStartExpression

        public java.lang.String getStartExpression()
        convert start parameter to exprresion
        that is used to find starting tag
        Specified by:
        getStartExpression in class AbstractParser
        Returns:
        regular expression that would be used to search for beginning of text from which node would be created
      • getStartEndExpression

        public java.lang.String getStartEndExpression()
        convert start parameter to exprresion
        that is used to check if tag has separate closing tag
        or is already closed
        Specified by:
        getStartEndExpression in class AbstractParser
        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 java.lang.String getEndExpression​(java.lang.String start)
        convert end parameter to exprresion
        that is used to find closing tag
        Specified by:
        getEndExpression in class AbstractParser
        Returns:
        regular expression that would be used to search for closing tag for a given start expression.
      • generateAttributes

        public java.util.Map generateAttributes​(java.lang.String tag)
        serach for pairs attributeKey="attributeValue" in text
        Parameters:
        tag -