net.sf.saxon.value

Class QNameValue

public class QNameValue extends AtomicValue

A QName value. This implements the so-called "triples proposal", in which the prefix is retained as part of the value. The prefix is not used in any operation on a QName other than conversion of the QName to a string.
Constructor Summary
QNameValue(NamePool namePool, int nameCode)
Constructor
QNameValue(String prefix, String uri, String localName, NameChecker checker)
Constructor.
Method Summary
intallocateNameCode(NamePool pool)
Allocate a nameCode for this QName in the NamePool
static AtomicValuecastToQName(StringValue operand, AtomicType targetType, StaticContext env)
Create a QName value (possibly a DerivedAtomicValue derived from QName) from a string literal, given a namespace context
AtomicValueconvertPrimitive(BuiltInAtomicType requiredType, boolean validate, XPathContext context)
Convert to target data type
ObjectconvertToJava(Class target, XPathContext context)
Convert to Java object (for passing to external functions)
booleanequals(Object other)
Determine if two QName values are equal.
StringgetClarkName()
Get the name in Clark notation, that is {uri}local
AtomicValuegetComponent(int part)
Get a component.
ItemTypegetItemType(TypeHierarchy th)
Return the type of the expression
StringgetLocalName()
Get the local part
StringgetNamespaceURI()
Get the namespace part (null means no namespace)
StringgetPrefix()
Get the prefix
StringgetStringValue()
Get the string value as a String.
inthashCode()
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)
StringtoString()
The toString() method returns the name in the form QName("uri", "local")

Constructor Detail

QNameValue

public QNameValue(NamePool namePool, int nameCode)
Constructor

Parameters: namePool The name pool containing the specified name code nameCode The name code identifying this name in the name pool

QNameValue

public QNameValue(String prefix, String uri, String localName, NameChecker checker)
Constructor. This constructor validates that the local part is a valid NCName.

Parameters: prefix The prefix part of the QName (not used in comparisons). Use null or "" to represent the default prefix. uri The namespace part of the QName. Use null or "" to represent the null namespace. localName The local part of the QName checker NameChecker used to check the name against XML 1.0 or XML 1.1 rules. Supply null if the name does not need to be checked (the caller asserts that it is known to be valid)

Method Detail

allocateNameCode

public int allocateNameCode(NamePool pool)
Allocate a nameCode for this QName in the NamePool

Parameters: pool the NamePool to be used

Returns: the allocated nameCode

castToQName

public static AtomicValue castToQName(StringValue operand, AtomicType targetType, StaticContext env)
Create a QName value (possibly a DerivedAtomicValue derived from QName) from a string literal, given a namespace context

Parameters: operand the input string targetType the type required: QName, or a type derived from QName or NOTATION env the static context, including the namespace context

Returns: the value after conversion

Throws: XPathException if the name is lexically invalid or uses an undeclared prefix

convertPrimitive

public AtomicValue convertPrimitive(BuiltInAtomicType requiredType, boolean validate, XPathContext context)
Convert to target data type

Parameters: requiredType an integer identifying the required atomic type context

Returns: an AtomicValue, a value of the required type; or an ErrorValue

convertToJava

public Object convertToJava(Class target, XPathContext context)
Convert to Java object (for passing to external functions)

equals

public boolean equals(Object other)
Determine if two QName values are equal. This comparison ignores the prefix part of the value.

Throws: ClassCastException if they are not comparable IllegalStateException if the two QNames are in different name pools

getClarkName

public String getClarkName()
Get the name in Clark notation, that is {uri}local

getComponent

public AtomicValue getComponent(int part)
Get a component. Returns a zero-length string if the namespace-uri component is requested and is not present.

Parameters: part either Component.LOCALNAME or Component.NAMESPACE indicating which component of the value is required

Returns: either the local name or the namespace URI, in each case as a StringValue

getItemType

public ItemType getItemType(TypeHierarchy th)
Return the type of the expression

Parameters: th

Returns: Type.QNAME (always)

getLocalName

public String getLocalName()
Get the local part

getNamespaceURI

public String getNamespaceURI()
Get the namespace part (null means no namespace)

getPrefix

public String getPrefix()
Get the prefix

getStringValue

public String getStringValue()
Get the string value as a String. Returns the QName as a lexical QName, retaining the original prefix if available.

hashCode

public int hashCode()

makeQName

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

toString

public String toString()
The toString() method returns the name in the form QName("uri", "local")

Returns: the name in in the form QName("uri", "local")