org.apache.batik.xml

Class XMLScanner

public class XMLScanner extends Object implements Localizable

This class represents a scanner for XML documents.
Field Summary
static intATTLIST_CONTEXT
The ATTLIST context.
static intATTRIBUTE_VALUE_CONTEXT
The attribute value context.
protected charattrDelimiter
The last attribute delimiter encountered.
protected char[]buffer
The recording buffer.
protected static StringBUNDLE_CLASSNAME
The default resource bundle base name.
protected booleancdataEndRead
A CDATA section end is the next token
protected intcontext
The current scanning context.
protected intcurrent
The current char.
static intCDATA_SECTION_CONTEXT
The CDATA section context.
static intCONTENT_CONTEXT
The content context.
protected intdepth
The depth in the xml tree.
static intDOCTYPE_CONTEXT
The doctype context.
static intDOCUMENT_START_CONTEXT
The document start context.
static intDTD_DECLARATIONS_CONTEXT
The DTD declarations context.
protected intend
The end offset of the last lexical unit.
static intELEMENT_DECLARATION_CONTEXT
The element declaration context.
static intEND_TAG_CONTEXT
The end tag context.
static intENTITY_CONTEXT
The entity context.
static intENTITY_VALUE_CONTEXT
The entity value context.
static intENUMERATION_CONTEXT
The enumeration context.
protected booleaninDTD
The scanner is in the internal DTD.
protected LocalizableSupportlocalizableSupport
The localizable support.
static intNOTATION_CONTEXT
The notation context.
static intNOTATION_TYPE_CONTEXT
The notation type context.
protected booleanpiEndRead
A PI end has been previously read.
protected intposition
The current position in the buffer.
static intPI_CONTEXT
The processing instruction context.
protected NormalizingReaderreader
The reader.
protected intstart
The start offset of the last lexical unit.
static intSTART_TAG_CONTEXT
The start tag context.
protected inttype
The type of the current lexical unit.
static intTOP_LEVEL_CONTEXT
The top level context.
static intXML_DECL_CONTEXT
The XML declaration context.
Constructor Summary
XMLScanner(Reader r)
Creates a new XML scanner.
XMLScanner(InputStream is, String enc)
Creates a new XML scanner.
XMLScanner(String s)
Creates a new XML scanner.
Method Summary
voidclearBuffer()
Clears the buffer.
protected XMLExceptioncreateXMLException(String message)
Returns an XMLException initialized with the given message key.
StringformatMessage(String key, Object[] args)
Implements {@link org.apache.batik.i18n.Localizable#formatMessage(String,Object[])}.
char[]getBuffer()
Returns the buffer used to store the chars.
intgetColumn()
Returns the current column.
intgetContext()
Returns the current context.
intgetDepth()
Returns the current depth in the XML tree.
intgetEnd()
Returns the end offset of the last lexical unit.
intgetEndOffset()
Returns the end offset of the current lexical unit.
intgetLine()
Returns the current line.
LocalegetLocale()
Implements {@link org.apache.batik.i18n.Localizable#getLocale()}.
intgetStart()
Returns the start offset of the last lexical unit.
intgetStartOffset()
Returns the start offset of the current lexical unit.
chargetStringDelimiter()
Returns the last encountered string delimiter.
intgetType()
The current lexical unit type like defined in LexicalUnits.
intnext()
Advances to the next lexical unit.
intnext(int ctx)
Advances to the next lexical unit.
protected intnextChar()
Sets the value of the current char to the next character or -1 if the end of stream has been reached.
protected intnextInAttList()
Returns the next lexical unit in the context of an attribute list.
protected intnextInAttributeValue()
Returns the next lexical unit in the context of an attribute value.
protected intnextInCDATASection()
Returns the next lexical unit in the context of a CDATA section.
protected intnextInContent()
Returns the next lexical unit in the context of an element content.
protected intnextInDoctype()
Returns the next lexical unit in the context of a doctype.
protected intnextInDocumentStart()
Reads the first token in the stream.
protected intnextInDTDDeclarations()
Returns the next lexical unit in the context dtd declarations.
protected intnextInElementDeclaration()
Returns the next lexical unit in the context of a element declaration.
protected intnextInEndTag()
Returns the next lexical unit in the context of a end tag.
protected intnextInEntity()
Returns the next lexical unit in the context of an entity.
protected intnextInEntityValue()
Returns the next lexical unit in the context of an entity value.
protected intnextInEnumeration()
Returns the next lexical unit in the context of an enumeration.
protected intnextInNotation()
Returns the next lexical unit in the context of a notation.
protected intnextInNotationType()
Returns the next lexical unit in the context of a notation type.
protected intnextInPI()
Returns the next lexical unit in the context of a processing instruction.
protected intnextInStartTag()
Returns the next lexical unit in the context of a start tag.
protected intnextInTopLevel()
Advances to the next lexical unit in the top level context.
protected intnextInXMLDecl()
Returns the next lexical unit in the context of an XML declaration.
protected intreadComment()
Reads a comment.
protected intreadIdentifier(String s, int type, int ntype)
Reads the given identifier.
protected intreadName(int type)
Reads a name.
protected intreadNmtoken()
Reads a Nmtoken.
protected intreadPEReference()
Reads a parameter entity reference.
protected intreadPIStart()
Reads a processing instruction start.
protected intreadReference()
Reads an entity or character reference.
protected intreadString()
Reads a simple string, like the ones used for version, encoding, public/system identifiers...
voidsetContext(int c)
Sets the current context.
voidsetDepth(int i)
Sets the current depth in the XML tree.
voidsetLocale(Locale l)
Implements {@link org.apache.batik.i18n.Localizable#setLocale(Locale)}.

Field Detail

ATTLIST_CONTEXT

public static final int ATTLIST_CONTEXT
The ATTLIST context.

ATTRIBUTE_VALUE_CONTEXT

public static final int ATTRIBUTE_VALUE_CONTEXT
The attribute value context.

attrDelimiter

protected char attrDelimiter
The last attribute delimiter encountered.

buffer

protected char[] buffer
The recording buffer.

BUNDLE_CLASSNAME

protected static final String BUNDLE_CLASSNAME
The default resource bundle base name.

cdataEndRead

protected boolean cdataEndRead
A CDATA section end is the next token

context

protected int context
The current scanning context.

current

protected int current
The current char.

CDATA_SECTION_CONTEXT

public static final int CDATA_SECTION_CONTEXT
The CDATA section context.

CONTENT_CONTEXT

public static final int CONTENT_CONTEXT
The content context.

depth

protected int depth
The depth in the xml tree.

DOCTYPE_CONTEXT

public static final int DOCTYPE_CONTEXT
The doctype context.

DOCUMENT_START_CONTEXT

public static final int DOCUMENT_START_CONTEXT
The document start context.

DTD_DECLARATIONS_CONTEXT

public static final int DTD_DECLARATIONS_CONTEXT
The DTD declarations context.

end

protected int end
The end offset of the last lexical unit.

ELEMENT_DECLARATION_CONTEXT

public static final int ELEMENT_DECLARATION_CONTEXT
The element declaration context.

END_TAG_CONTEXT

public static final int END_TAG_CONTEXT
The end tag context.

ENTITY_CONTEXT

public static final int ENTITY_CONTEXT
The entity context.

ENTITY_VALUE_CONTEXT

public static final int ENTITY_VALUE_CONTEXT
The entity value context.

ENUMERATION_CONTEXT

public static final int ENUMERATION_CONTEXT
The enumeration context.

inDTD

protected boolean inDTD
The scanner is in the internal DTD.

localizableSupport

protected LocalizableSupport localizableSupport
The localizable support.

NOTATION_CONTEXT

public static final int NOTATION_CONTEXT
The notation context.

NOTATION_TYPE_CONTEXT

public static final int NOTATION_TYPE_CONTEXT
The notation type context.

piEndRead

protected boolean piEndRead
A PI end has been previously read.

position

protected int position
The current position in the buffer.

PI_CONTEXT

public static final int PI_CONTEXT
The processing instruction context.

reader

protected NormalizingReader reader
The reader.

start

protected int start
The start offset of the last lexical unit.

START_TAG_CONTEXT

public static final int START_TAG_CONTEXT
The start tag context.

type

protected int type
The type of the current lexical unit.

TOP_LEVEL_CONTEXT

public static final int TOP_LEVEL_CONTEXT
The top level context.

XML_DECL_CONTEXT

public static final int XML_DECL_CONTEXT
The XML declaration context.

Constructor Detail

XMLScanner

public XMLScanner(Reader r)
Creates a new XML scanner.

Parameters: r The reader to scan.

XMLScanner

public XMLScanner(InputStream is, String enc)
Creates a new XML scanner.

Parameters: is The input stream to scan. enc The character encoding to use.

XMLScanner

public XMLScanner(String s)
Creates a new XML scanner.

Parameters: s The string to parse.

Method Detail

clearBuffer

public void clearBuffer()
Clears the buffer.

createXMLException

protected XMLException createXMLException(String message)
Returns an XMLException initialized with the given message key.

formatMessage

public String formatMessage(String key, Object[] args)
Implements {@link org.apache.batik.i18n.Localizable#formatMessage(String,Object[])}.

getBuffer

public char[] getBuffer()
Returns the buffer used to store the chars.

getColumn

public int getColumn()
Returns the current column.

getContext

public int getContext()
Returns the current context.

getDepth

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

getEnd

public int getEnd()
Returns the end offset of the last lexical unit.

getEndOffset

public int getEndOffset()
Returns the end offset of the current lexical unit.

getLine

public int getLine()
Returns the current line.

getLocale

public Locale getLocale()
Implements {@link org.apache.batik.i18n.Localizable#getLocale()}.

getStart

public int getStart()
Returns the start offset of the last lexical unit.

getStartOffset

public int getStartOffset()
Returns the start offset of the current lexical unit.

getStringDelimiter

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

getType

public int getType()
The current lexical unit type like defined in LexicalUnits.

next

public int next()
Advances to the next lexical unit.

Returns: The type of the lexical unit like defined in LexicalUnits.

next

public int next(int ctx)
Advances to the next lexical unit.

Parameters: ctx The context to use for scanning.

Returns: The type of the lexical unit like defined in LexicalUnits.

nextChar

protected int nextChar()
Sets the value of the current char to the next character or -1 if the end of stream has been reached.

nextInAttList

protected int nextInAttList()
Returns the next lexical unit in the context of an attribute list.

nextInAttributeValue

protected int nextInAttributeValue()
Returns the next lexical unit in the context of an attribute value.

nextInCDATASection

protected int nextInCDATASection()
Returns the next lexical unit in the context of a CDATA section.

nextInContent

protected int nextInContent()
Returns the next lexical unit in the context of an element content.

nextInDoctype

protected int nextInDoctype()
Returns the next lexical unit in the context of a doctype.

nextInDocumentStart

protected int nextInDocumentStart()
Reads the first token in the stream.

nextInDTDDeclarations

protected int nextInDTDDeclarations()
Returns the next lexical unit in the context dtd declarations.

nextInElementDeclaration

protected int nextInElementDeclaration()
Returns the next lexical unit in the context of a element declaration.

nextInEndTag

protected int nextInEndTag()
Returns the next lexical unit in the context of a end tag.

nextInEntity

protected int nextInEntity()
Returns the next lexical unit in the context of an entity.

nextInEntityValue

protected int nextInEntityValue()
Returns the next lexical unit in the context of an entity value.

nextInEnumeration

protected int nextInEnumeration()
Returns the next lexical unit in the context of an enumeration.

nextInNotation

protected int nextInNotation()
Returns the next lexical unit in the context of a notation.

nextInNotationType

protected int nextInNotationType()
Returns the next lexical unit in the context of a notation type.

nextInPI

protected int nextInPI()
Returns the next lexical unit in the context of a processing instruction.

nextInStartTag

protected int nextInStartTag()
Returns the next lexical unit in the context of a start tag.

nextInTopLevel

protected int nextInTopLevel()
Advances to the next lexical unit in the top level context.

Returns: The type of the lexical unit like defined in LexicalUnits.

nextInXMLDecl

protected int nextInXMLDecl()
Returns the next lexical unit in the context of an XML declaration.

readComment

protected int readComment()
Reads a comment. '<!-' must have been read.

readIdentifier

protected int readIdentifier(String s, int type, int ntype)
Reads the given identifier.

Parameters: s The portion of the identifier to read. type The lexical unit type of the identifier. ntype The lexical unit type to set if the identifier do not match or -1 if an error must be signaled.

readName

protected int readName(int type)
Reads a name. The current character must be the first character.

Parameters: type The lexical unit type to set.

Returns: type.

readNmtoken

protected int readNmtoken()
Reads a Nmtoken. The current character must be the first character.

Returns: LexicalUnits.NMTOKEN.

readPEReference

protected int readPEReference()
Reads a parameter entity reference. The current character must be '%'.

Returns: type.

readPIStart

protected int readPIStart()
Reads a processing instruction start.

Returns: type.

readReference

protected int readReference()
Reads an entity or character reference. The current character must be '&'.

Returns: type.

readString

protected int readString()
Reads a simple string, like the ones used for version, encoding, public/system identifiers... The current character must be the string delimiter.

Returns: type.

setContext

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

setDepth

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

setLocale

public void setLocale(Locale l)
Implements {@link org.apache.batik.i18n.Localizable#setLocale(Locale)}.
Copyright B) 2007 Apache Software Foundation. All Rights Reserved.