|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.xml.namespace.QName
public class QName
XML namespaces provide a way to distinguish determiniscally between XML elements that have the same local name but are, in fact, from different vocabularies. This is done by associating an element with a namespace. A namespace acts as a scope for all elements associated with it. Namespaces themselves also have names. A namespace name is a uniform resource identifier (URI). Such a URI serves as a unique string, and needs not be able to be dereferenced. The namespace name and the local name of the element together form a globally unique name known as a qualified name.
Namespace declarations appear inside an element start tag and
are used to map a namespace name to another, typically shorter,
string known as a namespace prefix. The syntax for a
namespace declaration is xmlns:prefix='URI'
. It is
also possible to map a namespace name to no prefix using a default
namespace declaration. The syntax for a default namespace
declaration is xmlns='URI'
. Only one default namespace
declaration may appear on an element. Any number of nondefault
namespace declarations may appear on an element, provided they
all have different prefix parts.
The names of all elements in a document that conforms to the
Namespaces in the XML specification are QName. Syntactically,
all QNames
have a local name and an optional prefix.
Both the local name and the prefix are NCNames. An
NCName
is a name without a colon in it.
Elements not in any namespace are known as unqualified elements.
Constructor Summary | ||
---|---|---|
QName(String localName)
Constructs a QName object given the local name. |
||
QName(String namespaceURI,
String localName)
Constructs a QName object given the Namespace URI,
and the local name. |
||
QName(String namespaceURI,
String localName,
String prefix)
Constructs a QName object given the Namespace URI,
the local name, and the prefix. |
Method Summary | ||
---|---|---|
boolean |
equals(Object anObject)
Equality testing for QName s. |
|
String |
getLocalPart()
Retrieves the local name of this QName . |
|
String |
getNamespaceURI()
Retrieves the Namespace URI of this QName . |
|
String |
getPrefix()
Retrieves the prefix of this QName . |
|
int |
hashCode()
Generates the hash code for this QName . |
|
String |
toString()
Returns a String representation of this
QName . |
|
static QName |
valueOf(String aString)
Given the string representation of a QName , constructs
the QName with the prefix being set to the empty string. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public QName(String namespaceURI, String localName, String prefix)
Constructs a QName
object given the Namespace URI,
the local name, and the prefix.
If the Namespace URI is null
, it is set to "".
(The namespace name of unqualified elements is the empty string "".
If a default namespace declaration is in scope and an unqualified
element is required, the default namespace declaration can be
masked by providing a namespace declaration of the form
xmlns="" on the element.)
Note: Use "" to indicate that a prefix is either not present or not relevant.
namespaceURI
- the namespace URI of this QName.localName
- the local name of this QName.prefix
- the prefix of this QName.
- Throws:
IllegalArgumentException
- if the local name is null
or it is of length 0; or if the prefix
is null
.- Since:
- BlackBerry API 4.3.0
public QName(String namespaceURI, String localName)
Constructs a QName
object given the Namespace URI,
and the local name.
The prefix is set to the empty string "" (for default namespace).
namespaceURI
- the namespace URI of this QName
.localName
- the local name of this QName
.public QName(String localName)
QName
object given the local name.
The namespace URI is set to the empty string "" (for unqualified
elements); the prefix is set to the empty string "" (for default
namespace).
localName
- the local name of this QName
.Method Detail |
---|
public String getNamespaceURI()
Retrieves the Namespace URI of this QName
.
QName
.public String getLocalPart()
Retrieves the local name of this QName
.
QName
.public String getPrefix()
Retrieves the prefix of this QName
.
QName
.public boolean equals(Object anObject)
Equality testing for QName
s.
Two QName
s are defined to be equal to each
other iff their Namespace URIs and their local names are
the same.
Note: Their prefixes might be different.
equals
in class Object
anObject
- the Object
for equality testing.
true
if anObject
is equal
to this QName
; false
otherwise.Boolean.hashCode()
,
Hashtable
public int hashCode()
Generates the hash code for this QName
.
hashCode
in class Object
QName
.Object.equals(java.lang.Object)
,
Hashtable
public String toString()
Returns a String
representation of this
QName
.
If the Namespace URI of this QName
is the empty string,
return the localName
; otherwise, return a string of
the form
"{" + namespaceURI + "}" + localName.
toString
in class Object
String
representation of this QName
.public static QName valueOf(String aString)
Given the string representation of a QName
, constructs
the QName
with the prefix being set to the empty string.
Note:This operation is the inverse of QName.toString
.
aString
- the string representation of a QName
.
QName
constructed from aString
IllegalArgumentException
- if aString
is not of the
form returned by QName.toString
.QName.toString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal