org.apache.batik.xml.scanner
Class DocumentScanner

java.lang.Object
  |
  +--org.apache.batik.xml.scanner.AbstractScanner
        |
        +--org.apache.batik.xml.scanner.DocumentScanner
All Implemented Interfaces:
Localizable

public class DocumentScanner
extends AbstractScanner

This class represents a low-level lexical scanner for XML documents. It scans the input and returns raw tokens, without entity or character references management.


Field Summary
static int ATTLIST_CONTEXT
          The ATTLIST context.
static int CDATA_SECTION_CONTEXT
          The CDATA section context.
protected  boolean cdataEndRead
          A CDATA section end is the next token
static int CONTENT_CONTEXT
          The content context.
protected  int context
          The current scanning context.
protected  int depth
          The depth in the xml tree.
static int DOCTYPE_CONTEXT
          The doctype context.
static int DOCUMENT_START_CONTEXT
          The document start context.
static int DQUOTED_ATTRIBUTE_CONTEXT
          The double quoted attribute context.
static int DQUOTED_ENTITY_VALUE_CONTEXT
          The double quoted entity value context.
static int DTD_DECLARATIONS_CONTEXT
          The DTD declarations context.
static int ELEMENT_DECLARATION_CONTEXT
          The element declaration context.
static int END_TAG_CONTEXT
          The end tag context.
static int ENTITY_CONTEXT
          The entity context.
static int ENUMERATION_CONTEXT
          The enumeration context.
protected  boolean inDTD
          The scanner is in the internal DTD.
static int NOTATION_CONTEXT
          The notation context.
static int NOTATION_TYPE_CONTEXT
          The notation type context.
static int PI_CONTEXT
          The processing instruction context.
protected  boolean piEndRead
          A PI end has been previously read.
static int SQUOTED_ATTRIBUTE_CONTEXT
          The single quoted attribute context.
static int SQUOTED_ENTITY_VALUE_CONTEXT
          The single quoted entity value context.
static int START_TAG_CONTEXT
          The start tag context.
protected  char stringDelimiter
          The last attribute delimiter encountered.
static int TOP_LEVEL_CONTEXT
          The top level context.
static int XML_DECL_CONTEXT
          The XML declaration context.
 
Fields inherited from class org.apache.batik.xml.scanner.AbstractScanner
buffer, BUNDLE_CLASSNAME, inputBuffer, lastFragment, localizableSupport, type, value
 
Constructor Summary
DocumentScanner(java.io.Reader r)
          Creates a new DocumentScanner object.
 
Method Summary
 char[] currentValue()
          Returns the current lexical unit value.
 int getContext()
          Returns the current context.
 int getDepth()
          Returns the current depth in the XML tree.
 char getStringDelimiter()
          Returns the last attribute delimiter encountered.
 int next()
          Advances to the next lexical unit.
 int next(int context)
          Advances to the next lexical unit.
protected  int nextInAttList()
          Returns the next lexical unit in the context of an attribute list.
protected  int nextInAttributeValue(char sd)
          Returns the next lexical unit in the context of an attribute value.
protected  int nextInCDATASection()
          Returns the next lexical unit in the context of a CDATA section.
protected  int nextInContent()
          Returns the next lexical unit in the context of an element content.
protected  int nextInDoctype()
          Returns the next lexical unit in the context of a doctype.
protected  int nextInDocumentStart()
          Reads the first token in the stream.
protected  int nextInDTDDeclarations()
          Returns the next lexical unit in the context dtd declarations.
protected  int nextInElementDeclaration()
          Returns the next lexical unit in the context of a element declaration.
protected  int nextInEndTag()
          Returns the next lexical unit in the context of a end tag.
protected  int nextInEntity()
          Returns the next lexical unit in the context of an entity.
protected  int nextInEntityValue(char sd)
          Returns the next lexical unit in the context of an entity value.
protected  int nextInEnumeration()
          Returns the next lexical unit in the context of an enumeration.
protected  int nextInNotation()
          Returns the next lexical unit in the context of a notation.
protected  int nextInNotationType()
          Returns the next lexical unit in the context of a notation type.
protected  int nextInPI()
          Returns the next lexical unit in the context of a processing instruction.
protected  int nextInStartTag()
          Returns the next lexical unit in the context of a start tag.
protected  int nextInTopLevel()
          Advances to the next lexical unit in the top level context.
protected  int nextInXMLDecl()
          Returns the next lexical unit in the context of an XML declaration.
 void setContext(int c)
          Sets the current context.
 void setDepth(int i)
          Sets the current depth in the XML tree.
 
Methods inherited from class org.apache.batik.xml.scanner.AbstractScanner
createException, currentType, formatMessage, getInputBuffer, getLocale, readComment, readIdentifier, readName, readNmtoken, readPEReference, readPIStart, readReference, readString, setLocale
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DTD_DECLARATIONS_CONTEXT

public static final int DTD_DECLARATIONS_CONTEXT
The DTD declarations context.

DQUOTED_ATTRIBUTE_CONTEXT

public static final int DQUOTED_ATTRIBUTE_CONTEXT
The double quoted attribute context.

SQUOTED_ATTRIBUTE_CONTEXT

public static final int SQUOTED_ATTRIBUTE_CONTEXT
The single quoted attribute context.

DQUOTED_ENTITY_VALUE_CONTEXT

public static final int DQUOTED_ENTITY_VALUE_CONTEXT
The double quoted entity value context.

SQUOTED_ENTITY_VALUE_CONTEXT

public static final int SQUOTED_ENTITY_VALUE_CONTEXT
The single quoted entity value context.

ELEMENT_DECLARATION_CONTEXT

public static final int ELEMENT_DECLARATION_CONTEXT
The element declaration context.

ENTITY_CONTEXT

public static final int ENTITY_CONTEXT
The entity context.

NOTATION_CONTEXT

public static final int NOTATION_CONTEXT
The notation context.

ATTLIST_CONTEXT

public static final int ATTLIST_CONTEXT
The ATTLIST context.

DOCUMENT_START_CONTEXT

public static final int DOCUMENT_START_CONTEXT
The document start context.

TOP_LEVEL_CONTEXT

public static final int TOP_LEVEL_CONTEXT
The top level context.

PI_CONTEXT

public static final int PI_CONTEXT
The processing instruction context.

START_TAG_CONTEXT

public static final int START_TAG_CONTEXT
The start tag context.

DOCTYPE_CONTEXT

public static final int DOCTYPE_CONTEXT
The doctype context.

XML_DECL_CONTEXT

public static final int XML_DECL_CONTEXT
The XML declaration context.

CONTENT_CONTEXT

public static final int CONTENT_CONTEXT
The content context.

CDATA_SECTION_CONTEXT

public static final int CDATA_SECTION_CONTEXT
The CDATA section context.

END_TAG_CONTEXT

public static final int END_TAG_CONTEXT
The end tag context.

NOTATION_TYPE_CONTEXT

public static final int NOTATION_TYPE_CONTEXT
The notation type context.

ENUMERATION_CONTEXT

public static final int ENUMERATION_CONTEXT
The enumeration context.

context

protected int context
The current scanning context.

depth

protected int depth
The depth in the xml tree.

piEndRead

protected boolean piEndRead
A PI end has been previously read.

cdataEndRead

protected boolean cdataEndRead
A CDATA section end is the next token

inDTD

protected boolean inDTD
The scanner is in the internal DTD.

stringDelimiter

protected char stringDelimiter
The last attribute delimiter encountered.
Constructor Detail

DocumentScanner

public DocumentScanner(java.io.Reader r)
                throws LexicalException
Creates a new DocumentScanner object.
Parameters:
r - The reader to scan.
Method Detail

setDepth

public void setDepth(int i)
Sets the current depth in the XML tree.

getDepth

public int getDepth()
Returns the current depth in the XML tree.

setContext

public void setContext(int c)
Sets the current context.

getContext

public int getContext()
Returns the current context.

getStringDelimiter

public char getStringDelimiter()
Returns the last attribute delimiter encountered.

currentValue

public char[] currentValue()
Returns the current lexical unit value.

LexicalUnits.START_TAG token value is returned without the leading '<'. LexicalUnits.COMMENT token value is returned without the leading ''. LexicalUnits.STRING value is returned without quotes. LexicalUnits.STRING_FRAGMENT value is returned without quotes.


next

public int next()
         throws LexicalException
Advances to the next lexical unit.
Returns:
The type of the lexical unit like defined in LexicalUnits.

next

public int next(int context)
         throws LexicalException
Advances to the next lexical unit.
Parameters:
context - The context to use for scanning.
Returns:
The type of the lexical unit like defined in LexicalUnits.

nextInElementDeclaration

protected int nextInElementDeclaration()
                                throws java.io.IOException,
                                       LexicalException
Returns the next lexical unit in the context of a element declaration.

nextInAttList

protected int nextInAttList()
                     throws java.io.IOException,
                            LexicalException
Returns the next lexical unit in the context of an attribute list.

nextInNotationType

protected int nextInNotationType()
                          throws java.io.IOException,
                                 LexicalException
Returns the next lexical unit in the context of a notation type.

nextInEnumeration

protected int nextInEnumeration()
                         throws java.io.IOException,
                                LexicalException
Returns the next lexical unit in the context of an enumeration.

nextInNotation

protected int nextInNotation()
                      throws java.io.IOException,
                             LexicalException
Returns the next lexical unit in the context of a notation.

nextInEntity

protected int nextInEntity()
                    throws java.io.IOException,
                           LexicalException
Returns the next lexical unit in the context of an entity.

nextInEntityValue

protected int nextInEntityValue(char sd)
                         throws java.io.IOException,
                                LexicalException
Returns the next lexical unit in the context of an entity value.
Parameters:
sd - The current string delimiter.

nextInDocumentStart

protected int nextInDocumentStart()
                           throws java.io.IOException,
                                  LexicalException
Reads the first token in the stream.

nextInTopLevel

protected int nextInTopLevel()
                      throws java.io.IOException,
                             LexicalException
Advances to the next lexical unit in the top level context.
Returns:
The type of the lexical unit like defined in LexicalUnits.

nextInPI

protected int nextInPI()
                throws java.io.IOException,
                       LexicalException
Returns the next lexical unit in the context of a processing instruction.

nextInStartTag

protected int nextInStartTag()
                      throws java.io.IOException,
                             LexicalException
Returns the next lexical unit in the context of a start tag.

nextInAttributeValue

protected int nextInAttributeValue(char sd)
                            throws java.io.IOException,
                                   LexicalException
Returns the next lexical unit in the context of an attribute value.
Parameters:
sd - The current string delimiter.

nextInContent

protected int nextInContent()
                     throws java.io.IOException,
                            LexicalException
Returns the next lexical unit in the context of an element content.

nextInEndTag

protected int nextInEndTag()
                    throws java.io.IOException,
                           LexicalException
Returns the next lexical unit in the context of a end tag.

nextInCDATASection

protected int nextInCDATASection()
                          throws java.io.IOException,
                                 LexicalException
Returns the next lexical unit in the context of a CDATA section.

nextInXMLDecl

protected int nextInXMLDecl()
                     throws java.io.IOException,
                            LexicalException
Returns the next lexical unit in the context of an XML declaration.

nextInDoctype

protected int nextInDoctype()
                     throws java.io.IOException,
                            LexicalException
Returns the next lexical unit in the context of a doctype.

nextInDTDDeclarations

protected int nextInDTDDeclarations()
                             throws java.io.IOException,
                                    LexicalException
Returns the next lexical unit in the context dtd declarations.


Copyright © 2001 Apache Software Foundation. All Rights Reserved.