Class XMLScanner
java.lang.Object
org.apache.batik.xml.XMLScanner
- All Implemented Interfaces:
Localizable
This class represents a scanner for XML documents.
- Version:
- $Id$
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe ATTLIST context.protected charThe last attribute delimiter encountered.static final intThe attribute value context.protected char[]The recording buffer.protected static final StringThe default resource bundle base name.static final intThe CDATA section context.protected booleanA CDATA section end is the next tokenstatic final intThe content context.protected intThe current scanning context.protected intThe current char.protected intThe depth in the xml tree.static final intThe doctype context.static final intThe document start context.static final intThe DTD declarations context.static final intThe element declaration context.protected intThe end offset of the last lexical unit.static final intThe end tag context.static final intThe entity context.static final intThe entity value context.static final intThe enumeration context.protected booleanThe scanner is in the internal DTD.protected LocalizableSupportThe localizable support.static final intThe notation context.static final intThe notation type context.static final intThe processing instruction context.protected booleanA PI end has been previously read.protected intThe current position in the buffer.protected NormalizingReaderThe reader.protected intThe start offset of the last lexical unit.static final intThe start tag context.static final intThe top level context.protected intThe type of the current lexical unit.static final intThe XML declaration context. -
Constructor Summary
ConstructorsConstructorDescriptionXMLScanner(InputStream is, String enc) Creates a new XML scanner.XMLScanner(Reader r) Creates a new XML scanner.XMLScanner(String s) Creates a new XML scanner. -
Method Summary
Modifier and TypeMethodDescriptionvoidClears the buffer.protected XMLExceptioncreateXMLException(String message) Returns an XMLException initialized with the given message key.formatMessage(String key, Object[] args) ImplementsLocalizable.formatMessage(String,Object[]).char[]Returns the buffer used to store the chars.intReturns the current column.intReturns the current context.intgetDepth()Returns the current depth in the XML tree.intgetEnd()Returns the end offset of the last lexical unit.intReturns the end offset of the current lexical unit.intgetLine()Returns the current line.ImplementsLocalizable.getLocale().intgetStart()Returns the start offset of the last lexical unit.intReturns the start offset of the current lexical unit.charReturns 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 intReturns the next lexical unit in the context of an attribute list.protected intReturns the next lexical unit in the context of an attribute value.protected intReturns the next lexical unit in the context of a CDATA section.protected intReturns the next lexical unit in the context of an element content.protected intReturns the next lexical unit in the context of a doctype.protected intReads the first token in the stream.protected intReturns the next lexical unit in the context dtd declarations.protected intReturns the next lexical unit in the context of a element declaration.protected intReturns the next lexical unit in the context of a end tag.protected intReturns the next lexical unit in the context of an entity.protected intReturns the next lexical unit in the context of an entity value.protected intReturns the next lexical unit in the context of an enumeration.protected intReturns the next lexical unit in the context of a notation.protected intReturns 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 intReturns the next lexical unit in the context of a start tag.protected intAdvances to the next lexical unit in the top level context.protected intReturns the next lexical unit in the context of an XML declaration.protected intReads a comment.protected intreadIdentifier(String s, int type, int ntype) Reads the given identifier.protected intreadName(int type) Reads a name.protected intReads a Nmtoken.protected intReads a parameter entity reference.protected intReads a processing instruction start.protected intReads an entity or character reference.protected intReads 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.voidImplementsLocalizable.setLocale(Locale).
-
Field Details
-
DOCUMENT_START_CONTEXT
public static final int DOCUMENT_START_CONTEXTThe document start context.- See Also:
-
TOP_LEVEL_CONTEXT
public static final int TOP_LEVEL_CONTEXTThe top level context.- See Also:
-
PI_CONTEXT
public static final int PI_CONTEXTThe processing instruction context.- See Also:
-
XML_DECL_CONTEXT
public static final int XML_DECL_CONTEXTThe XML declaration context.- See Also:
-
DOCTYPE_CONTEXT
public static final int DOCTYPE_CONTEXTThe doctype context.- See Also:
-
START_TAG_CONTEXT
public static final int START_TAG_CONTEXTThe start tag context.- See Also:
-
CONTENT_CONTEXT
public static final int CONTENT_CONTEXTThe content context.- See Also:
-
DTD_DECLARATIONS_CONTEXT
public static final int DTD_DECLARATIONS_CONTEXTThe DTD declarations context.- See Also:
-
CDATA_SECTION_CONTEXT
public static final int CDATA_SECTION_CONTEXTThe CDATA section context.- See Also:
-
END_TAG_CONTEXT
public static final int END_TAG_CONTEXTThe end tag context.- See Also:
-
ATTRIBUTE_VALUE_CONTEXT
public static final int ATTRIBUTE_VALUE_CONTEXTThe attribute value context.- See Also:
-
ATTLIST_CONTEXT
public static final int ATTLIST_CONTEXTThe ATTLIST context.- See Also:
-
ELEMENT_DECLARATION_CONTEXT
public static final int ELEMENT_DECLARATION_CONTEXTThe element declaration context.- See Also:
-
ENTITY_CONTEXT
public static final int ENTITY_CONTEXTThe entity context.- See Also:
-
NOTATION_CONTEXT
public static final int NOTATION_CONTEXTThe notation context.- See Also:
-
NOTATION_TYPE_CONTEXT
public static final int NOTATION_TYPE_CONTEXTThe notation type context.- See Also:
-
ENUMERATION_CONTEXT
public static final int ENUMERATION_CONTEXTThe enumeration context.- See Also:
-
ENTITY_VALUE_CONTEXT
public static final int ENTITY_VALUE_CONTEXTThe entity value context.- See Also:
-
BUNDLE_CLASSNAME
-
localizableSupport
The localizable support. -
reader
The reader. -
current
protected int currentThe current char. -
type
protected int typeThe type of the current lexical unit. -
buffer
protected char[] bufferThe recording buffer. -
position
protected int positionThe current position in the buffer. -
start
protected int startThe start offset of the last lexical unit. -
end
protected int endThe end offset of the last lexical unit. -
context
protected int contextThe current scanning context. -
depth
protected int depthThe depth in the xml tree. -
piEndRead
protected boolean piEndReadA PI end has been previously read. -
inDTD
protected boolean inDTDThe scanner is in the internal DTD. -
attrDelimiter
protected char attrDelimiterThe last attribute delimiter encountered. -
cdataEndRead
protected boolean cdataEndReadA CDATA section end is the next token
-
-
Constructor Details
-
XMLScanner
Creates a new XML scanner.- Parameters:
r- The reader to scan.- Throws:
XMLException
-
XMLScanner
Creates a new XML scanner.- Parameters:
is- The input stream to scan.enc- The character encoding to use.- Throws:
XMLException
-
XMLScanner
Creates a new XML scanner.- Parameters:
s- The string to parse.- Throws:
XMLException
-
-
Method Details
-
setLocale
ImplementsLocalizable.setLocale(Locale).- Specified by:
setLocalein interfaceLocalizable- Parameters:
l- The locale to set.
-
getLocale
ImplementsLocalizable.getLocale().- Specified by:
getLocalein interfaceLocalizable
-
formatMessage
ImplementsLocalizable.formatMessage(String,Object[]).- Specified by:
formatMessagein interfaceLocalizable- Parameters:
key- The key used to retreive the message from the resource bundle.args- The objects that compose the message.- Throws:
MissingResourceException- if the key is not in the bundle.
-
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. -
getType
public int getType()The current lexical unit type like defined in LexicalUnits. -
getLine
public int getLine()Returns the current line. -
getColumn
public int getColumn()Returns the current column. -
getBuffer
public char[] getBuffer()Returns the buffer used to store the chars. -
getStart
public int getStart()Returns the start offset of the last lexical unit. -
getEnd
public int getEnd()Returns the end offset of the last lexical unit. -
getStringDelimiter
public char getStringDelimiter()Returns the last encountered string delimiter. -
getStartOffset
public int getStartOffset()Returns the start offset of the current lexical unit. -
getEndOffset
public int getEndOffset()Returns the end offset of the current lexical unit. -
clearBuffer
public void clearBuffer()Clears the buffer. -
next
Advances to the next lexical unit.- Returns:
- The type of the lexical unit like defined in LexicalUnits.
- Throws:
XMLException
-
next
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.
- Throws:
XMLException
-
nextInDocumentStart
Reads the first token in the stream.- Throws:
IOExceptionXMLException
-
nextInTopLevel
Advances to the next lexical unit in the top level context.- Returns:
- The type of the lexical unit like defined in LexicalUnits.
- Throws:
IOExceptionXMLException
-
nextInPI
Returns the next lexical unit in the context of a processing instruction.- Throws:
IOExceptionXMLException
-
nextInStartTag
Returns the next lexical unit in the context of a start tag.- Throws:
IOExceptionXMLException
-
nextInAttributeValue
Returns the next lexical unit in the context of an attribute value.- Throws:
IOExceptionXMLException
-
nextInContent
Returns the next lexical unit in the context of an element content.- Throws:
IOExceptionXMLException
-
nextInEndTag
Returns the next lexical unit in the context of a end tag.- Throws:
IOExceptionXMLException
-
nextInCDATASection
Returns the next lexical unit in the context of a CDATA section.- Throws:
IOExceptionXMLException
-
nextInXMLDecl
Returns the next lexical unit in the context of an XML declaration.- Throws:
IOExceptionXMLException
-
nextInDoctype
Returns the next lexical unit in the context of a doctype.- Throws:
IOExceptionXMLException
-
nextInDTDDeclarations
Returns the next lexical unit in the context dtd declarations.- Throws:
IOExceptionXMLException
-
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.
- Throws:
IOExceptionXMLException
-
readComment
Reads a comment. '<!-' must have been read.- Throws:
IOExceptionXMLException
-
readIdentifier
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.- Throws:
IOExceptionXMLException
-
readName
Reads a name. The current character must be the first character.- Parameters:
type- The lexical unit type to set.- Returns:
- type.
- Throws:
IOExceptionXMLException
-
readPIStart
Reads a processing instruction start.- Returns:
- type.
- Throws:
IOExceptionXMLException
-
nextInElementDeclaration
Returns the next lexical unit in the context of a element declaration.- Throws:
IOExceptionXMLException
-
nextInAttList
Returns the next lexical unit in the context of an attribute list.- Throws:
IOExceptionXMLException
-
nextInNotation
Returns the next lexical unit in the context of a notation.- Throws:
IOExceptionXMLException
-
nextInEntity
Returns the next lexical unit in the context of an entity.- Throws:
IOExceptionXMLException
-
nextInEntityValue
Returns the next lexical unit in the context of an entity value.- Throws:
IOExceptionXMLException
-
nextInNotationType
Returns the next lexical unit in the context of a notation type.- Throws:
IOExceptionXMLException
-
nextInEnumeration
Returns the next lexical unit in the context of an enumeration.- Throws:
IOExceptionXMLException
-
readReference
Reads an entity or character reference. The current character must be '&'.- Returns:
- type.
- Throws:
IOExceptionXMLException
-
readPEReference
Reads a parameter entity reference. The current character must be '%'.- Returns:
- type.
- Throws:
IOExceptionXMLException
-
readNmtoken
Reads a Nmtoken. The current character must be the first character.- Returns:
- LexicalUnits.NMTOKEN.
- Throws:
IOExceptionXMLException
-
nextChar
Sets the value of the current char to the next character or -1 if the end of stream has been reached.- Throws:
IOException
-
createXMLException
Returns an XMLException initialized with the given message key.
-