net.sf.saxon.value
Class QNameValue

java.lang.Object
  |
  +--net.sf.saxon.value.Value
        |
        +--net.sf.saxon.value.AtomicValue
              |
              +--net.sf.saxon.value.QNameValue
All Implemented Interfaces:
Expression, Item, java.io.Serializable
Direct Known Subclasses:
NotationValue

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.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface net.sf.saxon.expr.Expression
EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD
 
Constructor Summary
QNameValue(NamePool namePool, int nameCode)
          Constructor
QNameValue(java.lang.String prefix, java.lang.String uri, java.lang.String localName)
          Constructor
 
Method Summary
 AtomicValue convert(int requiredType, XPathContext context)
          Convert to target data type
 java.lang.Object convertToJava(java.lang.Class target, Configuration config, XPathContext context)
          Convert to Java object (for passing to external functions)
 boolean equals(java.lang.Object other)
          Determine if two QName values are equal.
 java.lang.String getClarkName()
          Get the name in Clark notation, that is {uri}local
 AtomicValue getComponent(int part)
          Get a component.
 ItemType getItemType()
          Return the type of the expression
 java.lang.String getLocalName()
          Get the local part
 java.lang.String getNamespaceURI()
          Get the namespace part (null means no namespace)
 java.lang.String getStringValue()
          Get the string value as a String.
 int hashCode()
           
 java.lang.String toString()
          The toString() method returns the name in the form QName("uri", "local")
 
Methods inherited from class net.sf.saxon.value.AtomicValue
convert, display, effectiveBooleanValue, evaluateAsString, evaluateItem, getCardinality, getImplementationMethod, getPrimitiveValue, getTypedValue, iterate, process
 
Methods inherited from class net.sf.saxon.value.Value
analyze, asItem, asValue, collapseWhitespace, convertJavaObjectToXPath, getDependencies, getParentExpression, getSpecialProperties, inverse, iterateSubExpressions, normalizeWhitespace, promote, simplify, stringToNumber, trimWhitespace
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

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(java.lang.String prefix,
                  java.lang.String uri,
                  java.lang.String localName)
           throws XPathException
Constructor

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
Method Detail

getStringValue

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

Specified by:
getStringValue in interface Item
Specified by:
getStringValue in class AtomicValue
Returns:
the string value of the item

getClarkName

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


getLocalName

public java.lang.String getLocalName()
Get the local part


getNamespaceURI

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


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.

Overrides:
getComponent in class AtomicValue
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

convert

public AtomicValue convert(int requiredType,
                           XPathContext context)
                    throws XPathException
Convert to target data type

Specified by:
convert in class AtomicValue
Parameters:
requiredType - an integer identifying the required atomic type
context - the evaluation context. Used primarily for error reporting, since nearly all type conversions are context-independent. The value may be null if the context is not known.
Returns:
an AtomicValue, a value of the required type
Throws:
XPathException - if the conversion is not possible

getItemType

public ItemType getItemType()
Return the type of the expression

Returns:
Type.QNAME (always)

equals

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

Overrides:
equals in class java.lang.Object
Throws:
java.lang.ClassCastException - if they are not comparable
java.lang.IllegalStateException - if the two QNames are in different name pools

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

convertToJava

public java.lang.Object convertToJava(java.lang.Class target,
                                      Configuration config,
                                      XPathContext context)
                               throws XPathException
Convert to Java object (for passing to external functions)

Overrides:
convertToJava in class AtomicValue
Parameters:
target - The class required by the external function
config - The configuration (needed for access to schema information)
Returns:
an object of the target class
XPathException

toString

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

Overrides:
toString in class AtomicValue
Returns:
the name in Clark notation: {uri}local