edu.buffalo.nsf.xmlcqa.data.stream
Class Token

java.lang.Object
  extended byedu.buffalo.nsf.xmlcqa.data.stream.Token

public class Token
extends java.lang.Object

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()):

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.

Author:
staworko

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

CLOSING

public static final int CLOSING
Constant denoting closing token type.

See Also:
Constant Field Values

CLOSING_TOKEN

public static final Token CLOSING_TOKEN
Constant used to denote closing token.


OPENING

public static final int OPENING
Constant denoting opening token type.

See Also:
Constant Field Values

TEXT

public static final int TEXT
Constant denoting text token type.

See Also:
Constant Field Values
Method Detail

createTag

public static Token createTag(int tagID)
Creates an opening token. This token is labeled with tag whose Tag.ID is equal to tagID


createTag

public static Token createTag(java.lang.String tagName)
Creates an opening token. This token is labeled with a tag whose name is tagName


createTag

public static Token createTag(Tag tag)
Creates an opening token. This token is labeled with tag.


createText

public static Token createText(java.lang.String textValue)
Creates a text token. The textual data carried by this token is specified by textValue.


equals

public boolean equals(java.lang.Object o)
Find if this token is equal to a given one.


getTag

public Tag getTag()
Returns the tag. This method should be used only if this token is opening or textual.


getText

public java.lang.String getText()
Returns the textual information. This method should be used only if this token is textual.


getType

public int getType()
Returns the type of the token.


hashCode

public int hashCode()
REturns the hash code value of this token.


isClosing

public boolean isClosing()
Returns true if and only if the tag is closing.


isOpening

public boolean isOpening()
Returns true if an only if this tag is opening.


isText

public boolean isText()
Returns true if and only if it's a text tag.


toString

public java.lang.String toString()
Returns a string representation of this token.