Package net.sf.saxon.om
Class StructuredQName
- java.lang.Object
-
- net.sf.saxon.om.StructuredQName
-
- All Implemented Interfaces:
java.io.Serializable
public class StructuredQName extends java.lang.Object implements java.io.SerializableThis class provides an economical representation of a QName triple (prefix, URI, and localname). The value is stored internally as a character array containing the concatenation of URI, localname, and prefix (in that order) with two integers giving the start positions of the localname and prefix.Instances of this class are immutable.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description StructuredQName(java.lang.String prefix, java.lang.String uri, java.lang.String localName)Construct a StructuredQName from a prefix, URI, and local name.StructuredQName(NamePool pool, int nameCode)Make a structuredQName from a Namepool nameCode
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object other)Compare two StructuredQName values for equality.static StructuredQNamefromClarkName(java.lang.String expandedName)Make a structuredQName from a Clark namestatic StructuredQNamefromLexicalQName(java.lang.CharSequence lexicalName, boolean useDefault, NameChecker checker, NamespaceResolver resolver)Make a structured QName from a lexical QName, using a supplied NamespaceResolver to resolve the prefixjava.lang.StringgetClarkName()Get the expanded QName in Clark format, that is "{uri}local" if it is in a namespace, or just "local" otherwise.java.lang.StringgetDisplayName()Get the display name, that is the lexical QName in the form [prefix:]local-partjava.lang.StringgetLocalName()Get the local part of the QNamejava.lang.StringgetNamespaceURI()Get the namespace URI of the QName.java.lang.StringgetPrefix()Get the prefix of the QName.inthashCode()Get a hashcode to reflect the equals() methodjava.lang.ObjectmakeQName(Configuration config)Temporary method to construct a javax.xml.namespace.QName without actually mentioning it by name (because the class is not available in JDK 1.4)java.lang.StringtoString()The toString() method displays the QName as a lexical QName, that is prefix:local
-
-
-
Constructor Detail
-
StructuredQName
public StructuredQName(java.lang.String prefix, java.lang.String uri, java.lang.String localName)Construct a StructuredQName from a prefix, URI, and local name. This method performs no validation.- Parameters:
prefix- The prefix. Use an empty string to represent the null prefix.uri- The namespace URI. Use an empty string or null to represent the no-namespacelocalName- The local part of the name
-
StructuredQName
public StructuredQName(NamePool pool, int nameCode)
Make a structuredQName from a Namepool nameCode- Parameters:
pool- the NamePoolnameCode- a name code that has been registered in the NamePool
-
-
Method Detail
-
fromClarkName
public static StructuredQName fromClarkName(java.lang.String expandedName)
Make a structuredQName from a Clark name- Parameters:
expandedName- the name in Clark notation "{uri}local" if in a namespace, or "local" otherwise. The format "{}local" is also accepted for a name in no namespace.- Returns:
- the constructed StructuredQName
- Throws:
java.lang.IllegalArgumentException- if the Clark name is malformed
-
fromLexicalQName
public static StructuredQName fromLexicalQName(java.lang.CharSequence lexicalName, boolean useDefault, NameChecker checker, NamespaceResolver resolver) throws XPathException
Make a structured QName from a lexical QName, using a supplied NamespaceResolver to resolve the prefix- Parameters:
lexicalName- the QName as a lexical name (prefix:local)useDefault- set to true if an absent prefix implies use of the default namespace; set to false if an absent prefix implies no namespacechecker- NameChecker to be used to check conformance against XML 1.0 or 1.1 lexical rulesresolver- NamespaceResolver used to look up a URI for the prefix- Returns:
- the StructuredQName object corresponding to this lexical QName
- Throws:
XPathException- if the namespace prefix is not in scope or if the value is lexically invalid. Error code FONS0004 is set if the namespace prefix has not been declared; error code FOCA0002 is set if the name is lexically invalid.
-
getPrefix
public java.lang.String getPrefix()
Get the prefix of the QName.- Returns:
- the prefix. Returns the empty string if the name is unprefixed.
-
getNamespaceURI
public java.lang.String getNamespaceURI()
Get the namespace URI of the QName.- Returns:
- the URI. Returns the empty string to represent the no-namespace
-
getLocalName
public java.lang.String getLocalName()
Get the local part of the QName- Returns:
- the local part of the QName
-
getDisplayName
public java.lang.String getDisplayName()
Get the display name, that is the lexical QName in the form [prefix:]local-part- Returns:
- the lexical QName
-
getClarkName
public java.lang.String getClarkName()
Get the expanded QName in Clark format, that is "{uri}local" if it is in a namespace, or just "local" otherwise.- Returns:
- the QName in Clark notation
-
toString
public java.lang.String toString()
The toString() method displays the QName as a lexical QName, that is prefix:local- Overrides:
toStringin classjava.lang.Object- Returns:
- the lexical QName
-
equals
public boolean equals(java.lang.Object other)
Compare two StructuredQName values for equality. This compares the URI and local name parts, excluding any prefix- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
Get a hashcode to reflect the equals() method- Overrides:
hashCodein classjava.lang.Object- Returns:
- a hashcode based on the URI and local part only, ignoring the prefix.
-
makeQName
public java.lang.Object makeQName(Configuration config)
Temporary method to construct a javax.xml.namespace.QName without actually mentioning it by name (because the class is not available in JDK 1.4)- Parameters:
config- the Saxon configuration- Returns:
- an object of class javax.xml.namespace.QName representing this qualified name, or null if the object cannot be constructed (typically because the class javax.xml.namespace.QName is not available)
-
-