|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.buffalo.nsf.xmlcqa.data.stream.Token
Basic unit of XML documents. Tokens are used to convey the structure
and data in the XML document in a streamed fashion.
There are three types of tokens
(method getType()
):
OPENING
for tokens which denote a node in the XML document
labeled with a tag (getTag()
). Every opening token should be balanced
with a closing token: any information between a mathching pair of opening and closing
tokens contributes to the children of the node described by the opening token.
This type of a token can be created with methods:
createTag(int tagID)
, createTag(Tag tag)
, or
createTag(String tagName)
.
TEXT
for tokens which describe a text node. The textual
data can be accessed with the method getText()
. Becuase a text node
does not have any children, this node is not balanced with a
closing token. However, similarly to an opening token, this token has also tag
assigned which is equal to Tag.PCDATA_TAG
. This type of a token can be
created with method createText(String textValue)
CLOSING
for tokens balancing the opening tokens. For the sake
of simplicity a closing token does not carry any information on the token
it balances (the method getTag()
returns null
). This allows
us to create a constant CLOSING_TOKEN
. No other instances of a closing
token should be created.
Similarly to the class Tag
this class memoizes all opening tokens.
This behaviour prevents from multiple copies of the same object and allows to
compare opening tokens by pointer comparizon. This does not apply to text
tokens whose creation in not controled in any way, and it is posilbe that
two text tokens with the came textual information are represented by
two different instances of this class.
Field Summary | |
---|---|
static int |
CLOSING
Constant denoting closing token type. |
static Token |
CLOSING_TOKEN
Constant used to denote closing token. |
static int |
OPENING
Constant denoting opening token type. |
static int |
TEXT
Constant denoting text token type. |
Method Summary | |
---|---|
static Token |
createTag(int tagID)
Creates an opening token. |
static Token |
createTag(java.lang.String tagName)
Creates an opening token. |
static Token |
createTag(Tag tag)
Creates an opening token. |
static Token |
createText(java.lang.String textValue)
Creates a text token. |
boolean |
equals(java.lang.Object o)
Find if this token is equal to a given one. |
Tag |
getTag()
Returns the tag. |
java.lang.String |
getText()
Returns the textual information. |
int |
getType()
Returns the type of the token. |
int |
hashCode()
REturns the hash code value of this token. |
boolean |
isClosing()
Returns true if and only if the tag is closing. |
boolean |
isOpening()
Returns true if an only if this tag is opening. |
boolean |
isText()
Returns true if and only if it's a text tag. |
java.lang.String |
toString()
Returns a string representation of this token. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int CLOSING
public static final Token CLOSING_TOKEN
public static final int OPENING
public static final int TEXT
Method Detail |
public static Token createTag(int tagID)
Tag.ID
is equal to tagID
public static Token createTag(java.lang.String tagName)
tagName
public static Token createTag(Tag tag)
tag
.
public static Token createText(java.lang.String textValue)
textValue
.
public boolean equals(java.lang.Object o)
public Tag getTag()
public java.lang.String getText()
public int getType()
public int hashCode()
public boolean isClosing()
true
if and only if the tag is closing.
public boolean isOpening()
true
if an only if this tag is opening.
public boolean isText()
true
if and only if it's a text tag.
public java.lang.String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |