Class QName
- java.lang.Object
-
- javax.xml.namespace.QName
-
- All Implemented Interfaces:
Serializable
public class QName extends Object implements Serializable
NOTE: copied from Apache AXIS until QName is really standard in some JDK version ...QNameclass represents the value of a qualified name as specified in XML Schema Part2: Datatypes specification.The value of a QName contains a namespaceURI, a localPart and a prefix. The localPart provides the local part of the qualified name. The namespaceURI is a URI reference identifying the namespace.
- Version:
- 1.1
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)Tests this QName for equality with another object.StringgetLocalPart()Gets the Local part for this QNameStringgetNamespaceURI()Gets the Namespace URI for this QNameStringgetPrefix()Gets the Prefix for this QNameinthashCode()Returns a hash code value for this QName object.StringtoString()Returns a string representation of this QNamestatic QNamevalueOf(String s)Returns a QName holding the value of the specified String.
-
-
-
Constructor Detail
-
QName
public QName(String localPart)
Constructor for the QName.- Parameters:
localPart- Local part of the QName
-
QName
public QName(String namespaceURI, String localPart)
Constructor for the QName.- Parameters:
namespaceURI- Namespace URI for the QNamelocalPart- Local part of the QName.
-
-
Method Detail
-
getNamespaceURI
public String getNamespaceURI()
Gets the Namespace URI for this QName- Returns:
- Namespace URI
-
getLocalPart
public String getLocalPart()
Gets the Local part for this QName- Returns:
- Local part
-
getPrefix
public String getPrefix()
Gets the Prefix for this QName- Returns:
- Prefix
-
toString
public String toString()
Returns a string representation of this QName
-
equals
public final boolean equals(Object obj)
Tests this QName for equality with another object.If the given object is not a QName or is null then this method returns false.
For two QNames to be considered equal requires that both localPart and namespaceURI must be equal. This method uses
String.equalsto check equality of localPart and namespaceURI. Any class that extends QName is required to satisfy this equality contract.This method satisfies the general contract of the
Object.equalsmethod.
-
valueOf
public static QName valueOf(String s)
Returns a QName holding the value of the specified String.The string must be in the form returned by the QName.toString() method, i.e. "{namespaceURI}localPart", with the "{namespaceURI}" part being optional.
This method doesn't do a full validation of the resulting QName. In particular, it doesn't check that the resulting namespace URI is a legal URI (per RFC 2396 and RFC 2732), nor that the resulting local part is a legal NCName per the XML Namespaces specification.
- Parameters:
s- the string to be parsed- Returns:
- QName corresponding to the given String
- Throws:
IllegalArgumentException- If the specified String cannot be parsed as a QName
-
hashCode
public final int hashCode()
Returns a hash code value for this QName object. The hash code is based on both the localPart and namespaceURI parts of the QName. This method satisfies the general contract of theObject.hashCodemethod.
-
-