nu.validator.htmlparser.impl
Class MetaSniffer

java.lang.Object
  extended by nu.validator.htmlparser.impl.MetaSniffer
All Implemented Interfaces:
Locator

public final class MetaSniffer
extends Object
implements Locator


Nested Class Summary
private static class MetaSniffer.MetaState
           
private  class MetaSniffer.StopSniffingException
           
 
Field Summary
private  StringBuilder attributeName
           
private  StringBuilder attributeValue
           
private  CharsetDecoder charsetDecoder
           
private  int col
           
private static Pattern CONTENT
           
private  ErrorHandler errorHandler
           
private  int line
           
private  Locator locator
           
private  MetaSniffer.MetaState metaState
           
private  boolean prevWasCR
           
private  ByteReadable source
           
private  int unread
           
 
Constructor Summary
MetaSniffer(ByteReadable source, ErrorHandler eh, Locator locator)
           
 
Method Summary
private  boolean attribute()
          The "get an attribute" subalgorithm.
private  void checkAttribute()
           
private  void comment()
          Seen < , ! , -
private  void consumeUntilAndIncludingGt()
           
private  void endTag()
          Seen < , /
private  void err(String message)
           
 int getColumnNumber()
           
 int getLineNumber()
           
 String getPublicId()
           
 String getSystemId()
           
private  void markup()
          <
private  void markupDecl()
          Seen < , !
private  void quotedAttribute(int delim)
           
private  int read()
           
 CharsetDecoder sniff()
          Main loop.
private  void tag()
          < , x
private  void tryCharset(String encoding)
           
private  boolean unquotedAttribute()
           
private  void unread(int b)
           
private  void warn(String message)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTENT

private static final Pattern CONTENT

source

private final ByteReadable source

errorHandler

private final ErrorHandler errorHandler

charsetDecoder

private CharsetDecoder charsetDecoder

attributeName

private StringBuilder attributeName

attributeValue

private StringBuilder attributeValue

metaState

private MetaSniffer.MetaState metaState

unread

private int unread

line

private int line

col

private int col

prevWasCR

private boolean prevWasCR

locator

private final Locator locator
Constructor Detail

MetaSniffer

public MetaSniffer(ByteReadable source,
                   ErrorHandler eh,
                   Locator locator)
Parameters:
source -
errorHandler -
publicId -
systemId -
Method Detail

read

private int read()
          throws IOException,
                 MetaSniffer.StopSniffingException
Throws:
IOException
MetaSniffer.StopSniffingException

unread

private void unread(int b)

sniff

public CharsetDecoder sniff()
                     throws SAXException,
                            IOException
Main loop.

Returns:
Throws:
SAXException
IOException

markup

private void markup()
             throws SAXException,
                    MetaSniffer.StopSniffingException,
                    IOException
<

Throws:
SAXException
MetaSniffer.StopSniffingException
IOException

tag

private void tag()
          throws SAXException,
                 MetaSniffer.StopSniffingException,
                 IOException
< , x

Throws:
SAXException
MetaSniffer.StopSniffingException
IOException

attribute

private boolean attribute()
                   throws SAXException,
                          MetaSniffer.StopSniffingException,
                          IOException
The "get an attribute" subalgorithm.

Returns:
false when to stop
Throws:
SAXException
MetaSniffer.StopSniffingException
IOException

unquotedAttribute

private boolean unquotedAttribute()
                           throws SAXException,
                                  MetaSniffer.StopSniffingException,
                                  IOException
Throws:
SAXException
MetaSniffer.StopSniffingException
IOException

checkAttribute

private void checkAttribute()
                     throws SAXException,
                            MetaSniffer.StopSniffingException
Throws:
SAXException
MetaSniffer.StopSniffingException

tryCharset

private void tryCharset(String encoding)
                 throws SAXException,
                        MetaSniffer.StopSniffingException
Throws:
SAXException
MetaSniffer.StopSniffingException

err

private void err(String message)
          throws SAXException
Parameters:
string -
Throws:
SAXException

warn

private void warn(String message)
           throws SAXException
Parameters:
string -
Throws:
SAXException

quotedAttribute

private void quotedAttribute(int delim)
                      throws SAXException,
                             MetaSniffer.StopSniffingException,
                             IOException
Throws:
SAXException
MetaSniffer.StopSniffingException
IOException

consumeUntilAndIncludingGt

private void consumeUntilAndIncludingGt()
                                 throws IOException,
                                        MetaSniffer.StopSniffingException
Throws:
IOException
MetaSniffer.StopSniffingException

endTag

private void endTag()
             throws SAXException,
                    MetaSniffer.StopSniffingException,
                    IOException
Seen < , /

Throws:
SAXException
MetaSniffer.StopSniffingException
IOException

markupDecl

private void markupDecl()
                 throws IOException,
                        MetaSniffer.StopSniffingException
Seen < , !

Throws:
IOException
MetaSniffer.StopSniffingException

comment

private void comment()
              throws IOException,
                     MetaSniffer.StopSniffingException
Seen < , ! , -

Throws:
IOException
MetaSniffer.StopSniffingException

getColumnNumber

public int getColumnNumber()
Specified by:
getColumnNumber in interface Locator

getLineNumber

public int getLineNumber()
Specified by:
getLineNumber in interface Locator

getPublicId

public String getPublicId()
Specified by:
getPublicId in interface Locator

getSystemId

public String getSystemId()
Specified by:
getSystemId in interface Locator