javolution.xml
Class QName

Object
  extended by QName
All Implemented Interfaces:
Serializable, CharSequence, Immutable, XMLSerializable

public final class QName
extends Object
implements XMLSerializable, Immutable, CharSequence

This class represents unique identifiers for XML elements (tags) or attributes (names).

It should be noted that QName.valueOf(null, "name") and QName.valueOf("", "name") are distinct; the first one has no namespace associated with; whereas the second is associated to the root namespace.

QName have a textual representation (CharSequence) which is either the local name (if no namespace URI) or {namespaceURI}localName (otherwise).

Version:
5.3, January 14, 2007
Author:
Jean-Marie Dautelle
See Also:
Wikipedia: QName, Serialized Form

Method Summary
 char charAt(int index)
          Returns the character at the specified index.
 boolean equals(Object obj)
          Instances of this class are unique; object's equality can be replaced object identity (==).
 CharSequence getLocalName()
          Returns the local part of this qualified name or the full qualified name if there is no namespace.
 CharSequence getNamespaceURI()
          Returns the namespace URI of this qualified name or null if none (the local name is then the full qualified name).
 int hashCode()
          Returns the hash code for this qualified name.
 int length()
          Returns the length of this character sequence.
 CharSequence subSequence(int start, int end)
          Returns a new character sequence that is a subsequence of this sequence.
 String toString()
          Returns the String representation of this qualified name.
static QName valueOf(CharSequence name)
          Returns the qualified name corresponding to the specified character sequence representation (may include the "{namespaceURI}" prefix).
static QName valueOf(CharSequence namespaceURI, CharSequence localName)
          Returns the qualified name corresponding to the specified namespace URI and local name.
static QName valueOf(String name)
          Equivalent to valueOf(CharSequence) (for J2ME compatibility).
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

valueOf

public static QName valueOf(CharSequence name)
Returns the qualified name corresponding to the specified character sequence representation (may include the "{namespaceURI}" prefix).

Parameters:
name - the qualified name lexical representation.
See Also:
toString()

valueOf

public static QName valueOf(String name)
Equivalent to valueOf(CharSequence) (for J2ME compatibility).

Parameters:
name - the qualified name lexical representation.
See Also:
toString()

valueOf

public static QName valueOf(CharSequence namespaceURI,
                            CharSequence localName)
Returns the qualified name corresponding to the specified namespace URI and local name.

Parameters:
namespaceURI - the URI reference or null if none.
localName - the local name.
See Also:
toString()

getLocalName

public CharSequence getLocalName()
Returns the local part of this qualified name or the full qualified name if there is no namespace.

Returns:
the local name.

getNamespaceURI

public CharSequence getNamespaceURI()
Returns the namespace URI of this qualified name or null if none (the local name is then the full qualified name).

Returns:
the URI reference or null

equals

public boolean equals(Object obj)
Instances of this class are unique; object's equality can be replaced object identity (==).

Overrides:
equals in class Object
Returns:
this == obj

toString

public String toString()
Returns the String representation of this qualified name.

Specified by:
toString in interface CharSequence
Overrides:
toString in class Object
Returns:
the textual representation.

hashCode

public int hashCode()
Returns the hash code for this qualified name.

Note: Returns the same hashCode as java.lang.String (consistent with equals(java.lang.Object))

Overrides:
hashCode in class Object
Returns:
the hash code value.

charAt

public char charAt(int index)
Returns the character at the specified index.

Specified by:
charAt in interface CharSequence
Parameters:
index - the index of the character starting at 0.
Returns:
the character at the specified index of this character sequence.
Throws:
IndexOutOfBoundsException - if ((index < 0) || (index >= length))

length

public int length()
Returns the length of this character sequence.

Specified by:
length in interface CharSequence
Returns:
the number of characters (16-bits Unicode) composing this character sequence.

subSequence

public CharSequence subSequence(int start,
                                int end)
Returns a new character sequence that is a subsequence of this sequence.

Specified by:
subSequence in interface CharSequence
Parameters:
start - the index of the first character inclusive.
end - the index of the last character exclusive.
Returns:
the character sequence starting at the specified start position and ending just before the specified end position.
Throws:
IndexOutOfBoundsException - if (start < 0) || (end < 0) || (start > end) || (end > this.length())


Copyright © 2005-2012 Javolution. All Rights Reserved.