|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Tokenizes stream containing XML into XML tokens. In other words, using tokenizer XML document is represented as sequece of XML tokens (elements).
Field Summary | |
static byte |
CONTENT
text data token |
static byte |
END_DOCUMENT
end of document reached token |
static byte |
END_TOKEN
element end token |
static byte |
START_TOKEN
element start token |
static java.lang.String[] |
typeNames
just for debugging; index this by token type to get type name |
static byte |
UNKNOWN
unknown token |
Method Summary | |
byte |
currentState()
Returns the current state of the tokenizer. |
java.util.Map |
getCurrentPrefixMap()
Returns clone of the current prefix map. |
org.w3c.dom.Element |
getDOMRepresentation(org.w3c.dom.Document doc)
Returns DOM representation of the element that is being parsed. |
java.lang.String |
getLocalName()
Returns the local name of the current element. |
java.lang.String |
getNamespace()
Returns the namespace URI of the current element. |
java.lang.String |
getNamespaceForPrefix(java.lang.String prefix)
Returns a namespace URI for a declared prefix. |
byte |
next()
Parses next part of the input XML document and returns the state of the tokenizer (one of UNKNOWN, START_TOKEN, END_TOKEN, CONTENT, END_DOCUMENT). |
QName |
parseQName(java.lang.String qName)
Parses qName in the context of the opened element and returns the pair (namespaceURI, localName). |
int |
pushNewlyDeclaredPrefixes(DeclaredPrefixesStack prefixes)
Adds prefixes newly declared in this token. |
java.lang.String |
readContent()
Reads the content (PCDATA, CDATA). |
void |
readToken(Token stoken)
Reads the start/end of an element. |
boolean |
whitespaceContent()
Returns true if the content contains only whitespaces. |
Field Detail |
public static final byte UNKNOWN
public static final byte END_DOCUMENT
public static final byte START_TOKEN
public static final byte END_TOKEN
public static final byte CONTENT
public static final java.lang.String[] typeNames
Method Detail |
public java.lang.String getLocalName() throws TokenizerException
TokenizerException
- if the tokenizer is not on the START_TOKENpublic java.lang.String getNamespace() throws TokenizerException
TokenizerException
- if the tokenizer is not on the START_TOKENpublic java.lang.String getNamespaceForPrefix(java.lang.String prefix)
prefix
- the declared prefix
public org.w3c.dom.Element getDOMRepresentation(org.w3c.dom.Document doc) throws TokenizerException
doc
- the document within which the element should be created
TokenizerException
- if there is an error in
tokenizing the XML documentpublic QName parseQName(java.lang.String qName)
qName
- the qualified name
public byte next() throws TokenizerException, java.io.IOException
TokenizerException
- if there is an error in the XML
document or the tokenizer is beyond the end of the document (the
previous call to next()
has returned END_DOCUMENT).
java.io.IOException
- if some IOException has occuredpublic byte currentState()
next()
for details.
public java.lang.String readContent() throws TokenizerException
TokenizerException
- if the tokenizer is not in CONTENT statepublic void readToken(Token stoken) throws TokenizerException, java.io.IOException
stoken
. This function may be called only if the tokenizer
is on START_TOKEN or END_TOKEN.
stoken
- structure containing name, namespace URI and attribute pairs; holder for result
TokenizerException
- if the tokenizer is not in START_TOKEN, END_TOKEN or the document is not a well-formed XML.
java.io.IOException
- if there was an error reading the input documentpublic boolean whitespaceContent() throws TokenizerException
TokenizerException
- if the tokenizer is not in CONTENT statepublic java.util.Map getCurrentPrefixMap()
public int pushNewlyDeclaredPrefixes(DeclaredPrefixesStack prefixes)
prefixes
- the newly declared prefixes
java.lang.IllegalStateException
- if tokenizer is not in START_TOKEN state.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |