Javolution 6.0.0 java
javolution.xml.QName Class Reference
Inheritance diagram for javolution.xml.QName:
[legend]
Collaboration diagram for javolution.xml.QName:
[legend]

Public Member Functions

CharSequence getLocalName ()
 
CharSequence getNamespaceURI ()
 
boolean equals (Object obj)
 
String toString ()
 
int hashCode ()
 
char charAt (int index)
 
int length ()
 
CharSequence subSequence (int start, int end)
 
QName value ()
 

Static Public Member Functions

static QName valueOf (CharSequence name)
 
static QName valueOf (String name)
 
static QName valueOf (CharSequence namespaceURI, CharSequence localName)
 

Private Member Functions

 QName (String namespaceURI, String localName, String toString)
 
Object readResolve () throws ObjectStreamException
 

Static Private Member Functions

static QName createNoNamespace (String name)
 

Private Attributes

transient final CharArray _localName
 
transient final CharArray _namespaceURI
 
final String _toString
 

Static Private Attributes

static final FastMap< CharSequence, QNameFULL_NAME_TO_QNAME
 
static final long serialVersionUID = -6126031630693748647L
 

Detailed Description

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).


Author
Jean-Marie Dautelle
Version
5.3, January 14, 2007
See also
Wikipedia: QName

Definition at line 37 of file QName.java.

Constructor & Destructor Documentation

◆ QName()

javolution.xml.QName.QName ( String  namespaceURI,
String  localName,
String  toString 
)
private

Creates a qualified name having the specified local name and namespace reference.

Parameters
namespaceURIthe URI reference or null if none.
localNamethe local name.
toStringthe string representation.

Definition at line 68 of file QName.java.

68  {
69  _namespaceURI = (namespaceURI == null) ? null : new CharArray(
70  namespaceURI);
71  _localName = new CharArray(localName);
73  }

References javolution.xml.QName._localName, javolution.xml.QName._namespaceURI, javolution.xml.QName._toString, and javolution.xml.QName.toString().

Referenced by javolution.xml.QName.createNoNamespace(), and javolution.xml.QName.valueOf().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ charAt()

char javolution.xml.QName.charAt ( int  index)

Returns the character at the specified index.

Parameters
indexthe index of the character starting at 0.
Returns
the character at the specified index of this character sequence.
Exceptions
IndexOutOfBoundsExceptionif ((index < 0) || (index >= length))

Definition at line 192 of file QName.java.

192  {
193  return _toString.charAt(index);
194  }

References javolution.xml.QName._toString.

◆ createNoNamespace()

static QName javolution.xml.QName.createNoNamespace ( String  name)
staticprivate

Definition at line 88 of file QName.java.

88  {
89  String localName = name;
90  String namespaceURI = null;
91  if (name.length() > 0 && name.charAt(0) == '{') { // Namespace URI.
92  int index = name.lastIndexOf('}');
93  localName = name.substring(index + 1);
94  namespaceURI = name.substring(1, index);
95  }
96  QName qName = new QName(namespaceURI, localName, name);
97  synchronized (FULL_NAME_TO_QNAME) {
98  QName tmp = (QName) FULL_NAME_TO_QNAME.putIfAbsent(name, qName);
99  return tmp == null ? qName : tmp;
100  }
101  }

References javolution.xml.QName.FULL_NAME_TO_QNAME, and javolution.xml.QName.QName().

Referenced by javolution.xml.QName.valueOf().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ equals()

boolean javolution.xml.QName.equals ( Object  obj)

Instances of this class are unique; object's equality can be replaced object identity (==).

Returns
this == obj

Definition at line 160 of file QName.java.

160  {
161  return this == obj;
162  }

◆ getLocalName()

CharSequence javolution.xml.QName.getLocalName ( )

Returns the local part of this qualified name or the full qualified name if there is no namespace.

Returns
the local name.

Definition at line 140 of file QName.java.

140  {
141  return _localName;
142  }

References javolution.xml.QName._localName.

Referenced by javolution.xml.XMLBinding.readClass(), and javolution.xml.XMLBinding.writeClass().

Here is the caller graph for this function:

◆ getNamespaceURI()

CharSequence javolution.xml.QName.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

Definition at line 150 of file QName.java.

150  {
151  return _namespaceURI;
152  }

References javolution.xml.QName._namespaceURI.

Referenced by javolution.xml.XMLBinding.readClass(), and javolution.xml.XMLBinding.writeClass().

Here is the caller graph for this function:

◆ hashCode()

int javolution.xml.QName.hashCode ( )

Returns the hash code for this qualified name.

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

Returns
the hash code value.

Definition at line 180 of file QName.java.

180  {
181  return _toString.hashCode();
182  }

References javolution.xml.QName._toString.

◆ length()

int javolution.xml.QName.length ( )

Returns the length of this character sequence.

Returns
the number of characters (16-bits Unicode) composing this character sequence.

Definition at line 202 of file QName.java.

202  {
203  return _toString.length();
204  }

References javolution.xml.QName._toString.

◆ readResolve()

Object javolution.xml.QName.readResolve ( ) throws ObjectStreamException
private

Definition at line 222 of file QName.java.

222  {
223  return QName.valueOf(_toString);
224  }

References javolution.xml.QName._toString, and javolution.xml.QName.valueOf().

Here is the call graph for this function:

◆ subSequence()

CharSequence javolution.xml.QName.subSequence ( int  start,
int  end 
)

Returns a new character sequence that is a subsequence of this sequence.

Parameters
startthe index of the first character inclusive.
endthe index of the last character exclusive.
Returns
the character sequence starting at the specified start position and ending just before the specified end position.
Exceptions
IndexOutOfBoundsExceptionif
(start < 0) || (end < 0) ||
(start > end) || (end > this.length())

Definition at line 217 of file QName.java.

217  {
218  return _toString.substring(start, end);
219  }

References javolution.xml.QName._toString.

◆ toString()

String javolution.xml.QName.toString ( )

Returns the String representation of this qualified name.

Returns
the textual representation.

Definition at line 169 of file QName.java.

169  {
170  return _toString;
171  }

References javolution.xml.QName._toString.

Referenced by javolution.xml.QName.QName(), javolution.xml.QName.valueOf(), and javolution.xml.XMLBinding.writeClass().

Here is the caller graph for this function:

◆ value()

QName javolution.xml.QName.value ( )

Returns the constant value held by this object.

Implements javolution.lang.Immutable< T >.

Definition at line 229 of file QName.java.

229  {
230  return this;
231  }

◆ valueOf() [1/3]

static QName javolution.xml.QName.valueOf ( CharSequence  name)
static

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

Parameters
namethe qualified name lexical representation.
See also
toString()

Definition at line 82 of file QName.java.

82  {
83  QName qName = (QName) FULL_NAME_TO_QNAME.get(name);
84  return (qName != null) ? qName : QName.createNoNamespace(name
85  .toString());
86  }

References javolution.xml.QName.createNoNamespace(), javolution.xml.QName.FULL_NAME_TO_QNAME, javolution.xml.QName.QName(), and javolution.xml.QName.toString().

Referenced by javolution.xml.XMLBinding.readClass(), javolution.xml.QName.readResolve(), javolution.xml.XMLBinding.reset(), javolution.xml.XMLBinding.setAlias(), javolution.xml.XMLBinding.setClassAttribute(), and javolution.xml.QName.valueOf().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ valueOf() [2/3]

static QName javolution.xml.QName.valueOf ( CharSequence  namespaceURI,
CharSequence  localName 
)
static

Returns the qualified name corresponding to the specified namespace URI and local name.

Parameters
namespaceURIthe URI reference or null if none.
localNamethe local name.
See also
toString()

Definition at line 122 of file QName.java.

123  {
124  if (namespaceURI == null)
125  return QName.valueOf(localName);
126  TextBuilder tmp = new TextBuilder();
127  tmp.append('{');
128  tmp.append(namespaceURI);
129  tmp.append('}');
130  tmp.append(localName);
131  return QName.valueOf(tmp);
132  }

References javolution.text.TextBuilder.append(), and javolution.xml.QName.valueOf().

Here is the call graph for this function:

◆ valueOf() [3/3]

static QName javolution.xml.QName.valueOf ( String  name)
static

Equivalent to valueOf(CharSequence) (for J2ME compatibility).

Parameters
namethe qualified name lexical representation.
See also
toString()

Definition at line 109 of file QName.java.

109  {
110  QName qName = (QName) FULL_NAME_TO_QNAME.get(name);
111  return (qName != null) ? qName : QName.createNoNamespace(name);
112  }

References javolution.xml.QName.createNoNamespace(), javolution.xml.QName.FULL_NAME_TO_QNAME, and javolution.xml.QName.QName().

Here is the call graph for this function:

Member Data Documentation

◆ _localName

transient final CharArray javolution.xml.QName._localName
private

Holds the local name.

Definition at line 42 of file QName.java.

Referenced by javolution.xml.QName.getLocalName(), and javolution.xml.QName.QName().

◆ _namespaceURI

transient final CharArray javolution.xml.QName._namespaceURI
private

Holds the namespace URI reference or null if none.

Definition at line 47 of file QName.java.

Referenced by javolution.xml.QName.getNamespaceURI(), and javolution.xml.QName.QName().

◆ _toString

◆ FULL_NAME_TO_QNAME

final FastMap<CharSequence, QName> javolution.xml.QName.FULL_NAME_TO_QNAME
staticprivate
Initial value:
= new FastMap<CharSequence, QName>(
Equalities.LEXICAL)

Holds the full name (String) to QName mapping.

Definition at line 57 of file QName.java.

Referenced by javolution.xml.QName.createNoNamespace(), and javolution.xml.QName.valueOf().

◆ serialVersionUID

final long javolution.xml.QName.serialVersionUID = -6126031630693748647L
staticprivate

Definition at line 226 of file QName.java.


The documentation for this class was generated from the following file:
javolution.xml.QName.FULL_NAME_TO_QNAME
static final FastMap< CharSequence, QName > FULL_NAME_TO_QNAME
Definition: QName.java:57
javolution.xml.QName.QName
QName(String namespaceURI, String localName, String toString)
Definition: QName.java:68
javolution.xml.QName._namespaceURI
transient final CharArray _namespaceURI
Definition: QName.java:47
javolution.xml.QName._localName
transient final CharArray _localName
Definition: QName.java:42
javolution.xml.QName.length
int length()
Definition: QName.java:202
javolution.xml.QName._toString
final String _toString
Definition: QName.java:52
javolution.xml.QName.toString
String toString()
Definition: QName.java:169