org.idoox.xml
Class Token

java.lang.Object
  extended byorg.idoox.xml.Token

public final class Token
extends java.lang.Object

This class is a java mapping to the start/end of an element. XML element can be thought of as two XML token. Start token with local name, namespace URI and array of attributes and end token with local name and namespace URI.

Since:
4.0
Component:
Core

Field Summary
 Attribute[] attArr
          an array of attributes.
 int attEnd
          position of the end of attributes array
 java.lang.String localName
          the local name of the element
 java.lang.String prefix
          prefix of this Token
 byte type
          the type of the token; one of Tokenizer.UNKNOWN, Tokenizer.START_TOKEN, Tokenizer.END_TOKEN
 java.lang.String uri
          the uri of the element
 
Constructor Summary
Token()
           
 
Method Summary
 void clear()
          Not to be called from an application.
 void ensureCapacity(int size)
          Not to be called from the application.
 Attribute getAttribute(int idx)
          Get an attribute.
 int getAttributeCount()
          Returns the number of attributes of the filled start token.
 java.lang.String getAttributeLocalName(int index)
          Returns local name for the attribute.
 java.lang.String getAttributeNamespace(int index)
          Returns namespace URI for the attribute
 java.lang.String getAttributeValue(int index)
          Returns value for the attribute
 java.lang.String getAttributeValue(java.lang.String uri, java.lang.String localName)
          Returns value for an attribute given by name.
 java.lang.String getLocalName()
          Returns the local name of the token.
 java.lang.String getNamespace()
          Returns the namespace URI of the token.
 byte getType()
          Returns the type of the token.
 java.lang.String toString()
          Returns the string representation of the token.
 void writeTo(Token token)
          Copy this token to new one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

type

public byte type
the type of the token; one of Tokenizer.UNKNOWN, Tokenizer.START_TOKEN, Tokenizer.END_TOKEN


uri

public java.lang.String uri
the uri of the element


localName

public java.lang.String localName
the local name of the element


attEnd

public int attEnd
position of the end of attributes array


attArr

public Attribute[] attArr
an array of attributes. Only attributes up to index attEnd (excluding) are part of the value of this token. No reference in this array is ever null. Also all referenced Attribute instances must be unique.


prefix

public java.lang.String prefix
prefix of this Token

Constructor Detail

Token

public Token()
Method Detail

getType

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

Returns:
one of Tokenizer.UNKNOWN, Tokenizer.START_TOKEN, Tokenizer.END_TOKEN

clear

public void clear()
Not to be called from an application. Clears the state of the token.


getLocalName

public java.lang.String getLocalName()
Returns the local name of the token.

Returns:
the local name

getNamespace

public java.lang.String getNamespace()
Returns the namespace URI of the token.

Returns:
the namespace URI

getAttributeCount

public int getAttributeCount()
Returns the number of attributes of the filled start token.

Returns:
number of attributes

getAttributeLocalName

public java.lang.String getAttributeLocalName(int index)
Returns local name for the attribute.

Parameters:
index - the position of the attribute
Returns:
local name of the attribute

getAttributeNamespace

public java.lang.String getAttributeNamespace(int index)
Returns namespace URI for the attribute

Parameters:
index - the position of the attribute
Returns:
namespace URI of the attribute

getAttributeValue

public java.lang.String getAttributeValue(int index)
Returns value for the attribute

Parameters:
index - the position of the attribute
Returns:
value of the attribute

getAttributeValue

public java.lang.String getAttributeValue(java.lang.String uri,
                                          java.lang.String localName)
Returns value for an attribute given by name. Unlike org.w3.dom.Element, this call returns null if the attribute has not been found.

Parameters:
uri - the namespace URI of the attribute
localName - the local name of the attribute
Returns:
value of the attribute

toString

public java.lang.String toString()
Returns the string representation of the token. Used mainly for debugging.

Returns:
the human readable representation of the token

getAttribute

public Attribute getAttribute(int idx)
Get an attribute.

Parameters:
idx - index of the attribute
Returns:
the attribute

ensureCapacity

public void ensureCapacity(int size)
Not to be called from the application. Make sure that there is enough space to keep size attributes.

Parameters:
size - the size which should be ensured

writeTo

public void writeTo(Token token)
Copy this token to new one.

Parameters:
token - the token to be copied