Class MetaScanner

java.lang.Object
nu.validator.htmlparser.impl.MetaScanner
Direct Known Subclasses:
MetaSniffer

public abstract class MetaScanner extends Object
  • Field Details

    • CHARSET

      private static final char[] CHARSET
      Constant for "charset".
    • CONTENT

      private static final char[] CONTENT
      Constant for "content".
    • HTTP_EQUIV

      private static final char[] HTTP_EQUIV
      Constant for "http-equiv".
    • CONTENT_TYPE

      private static final char[] CONTENT_TYPE
      Constant for "content-type".
    • NO

      private static final int NO
      See Also:
    • M

      private static final int M
      See Also:
    • E

      private static final int E
      See Also:
    • T

      private static final int T
      See Also:
    • A

      private static final int A
      See Also:
    • DATA

      private static final int DATA
      See Also:
    • TAG_OPEN

      private static final int TAG_OPEN
      See Also:
    • SCAN_UNTIL_GT

      private static final int SCAN_UNTIL_GT
      See Also:
    • TAG_NAME

      private static final int TAG_NAME
      See Also:
    • BEFORE_ATTRIBUTE_NAME

      private static final int BEFORE_ATTRIBUTE_NAME
      See Also:
    • ATTRIBUTE_NAME

      private static final int ATTRIBUTE_NAME
      See Also:
    • AFTER_ATTRIBUTE_NAME

      private static final int AFTER_ATTRIBUTE_NAME
      See Also:
    • BEFORE_ATTRIBUTE_VALUE

      private static final int BEFORE_ATTRIBUTE_VALUE
      See Also:
    • ATTRIBUTE_VALUE_DOUBLE_QUOTED

      private static final int ATTRIBUTE_VALUE_DOUBLE_QUOTED
      See Also:
    • ATTRIBUTE_VALUE_SINGLE_QUOTED

      private static final int ATTRIBUTE_VALUE_SINGLE_QUOTED
      See Also:
    • ATTRIBUTE_VALUE_UNQUOTED

      private static final int ATTRIBUTE_VALUE_UNQUOTED
      See Also:
    • AFTER_ATTRIBUTE_VALUE_QUOTED

      private static final int AFTER_ATTRIBUTE_VALUE_QUOTED
      See Also:
    • MARKUP_DECLARATION_OPEN

      private static final int MARKUP_DECLARATION_OPEN
      See Also:
    • MARKUP_DECLARATION_HYPHEN

      private static final int MARKUP_DECLARATION_HYPHEN
      See Also:
    • COMMENT_START

      private static final int COMMENT_START
      See Also:
    • COMMENT_START_DASH

      private static final int COMMENT_START_DASH
      See Also:
    • COMMENT

      private static final int COMMENT
      See Also:
    • COMMENT_END_DASH

      private static final int COMMENT_END_DASH
      See Also:
    • COMMENT_END

      private static final int COMMENT_END
      See Also:
    • SELF_CLOSING_START_TAG

      private static final int SELF_CLOSING_START_TAG
      See Also:
    • HTTP_EQUIV_NOT_SEEN

      private static final int HTTP_EQUIV_NOT_SEEN
      See Also:
    • HTTP_EQUIV_CONTENT_TYPE

      private static final int HTTP_EQUIV_CONTENT_TYPE
      See Also:
    • HTTP_EQUIV_OTHER

      private static final int HTTP_EQUIV_OTHER
      See Also:
    • readable

      protected ByteReadable readable
      The data source.
    • metaState

      private int metaState
      The state of the state machine that recognizes the tag name "meta".
    • contentIndex

      private int contentIndex
      The current position in recognizing the attribute name "content".
    • charsetIndex

      private int charsetIndex
      The current position in recognizing the attribute name "charset".
    • httpEquivIndex

      private int httpEquivIndex
      The current position in recognizing the attribute name "http-equive".
    • contentTypeIndex

      private int contentTypeIndex
      The current position in recognizing the attribute value "content-type".
    • stateSave

      protected int stateSave
      The tokenizer state.
    • strBufLen

      private int strBufLen
      The currently filled length of strBuf.
    • strBuf

      private char[] strBuf
      Accumulation buffer for attribute values.
    • content

      private String content
    • charset

      private String charset
    • httpEquivState

      private int httpEquivState
  • Constructor Details

    • MetaScanner

      public MetaScanner()
  • Method Details

    • destructor

      private void destructor()
    • read

      protected int read() throws IOException
      Reads a byte from the data source. -1 means end.
      Returns:
      Throws:
      IOException
    • stateLoop

      protected final void stateLoop(int state) throws SAXException, IOException
      The runs the meta scanning algorithm.
      Throws:
      SAXException
      IOException
    • handleCharInAttributeValue

      private void handleCharInAttributeValue(int c)
    • toAsciiLowerCase

      private int toAsciiLowerCase(int c)
    • addToBuffer

      private void addToBuffer(int c)
      Adds a character to the accumulation buffer.
      Parameters:
      c - the character to add
    • handleAttributeValue

      private void handleAttributeValue() throws SAXException
      Attempts to extract a charset name from the accumulation buffer.
      Throws:
      SAXException
    • handleTag

      private boolean handleTag() throws SAXException
      Throws:
      SAXException
    • handleTagInner

      private boolean handleTagInner() throws SAXException
      Throws:
      SAXException
    • tryCharset

      protected abstract boolean tryCharset(String encoding) throws SAXException
      Tries to switch to an encoding.
      Parameters:
      encoding -
      Returns:
      true if successful
      Throws:
      SAXException