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

public final class QNameValue
extends AtomicValue

A QName value

See Also:
Serialized Form

Constructor Summary
QNameValue(java.lang.String uri, java.lang.String localName)
          Constructor
 
Method Summary
 int conversionPreference(java.lang.Class required, Configuration config)
          Get conversion preference for this value to a Java class.
 AtomicValue convert(int requiredType)
          Convert to target data type
 java.lang.Object convertToJava(java.lang.Class target, Configuration config)
          Convert to Java object (for passing to external functions)
 void display(int level, NamePool pool)
          Diagnostic print of expression structure
 boolean equals(java.lang.Object other)
          Determine if two anyURI values are equal
 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()
           
 
Methods inherited from class net.sf.saxon.value.AtomicValue
convert, effectiveBooleanValue, evaluateAsString, evaluateItem, getCardinality, getPrimitiveValue, getTypedValue, iterate
 
Methods inherited from class net.sf.saxon.value.Value
analyze, asItem, asValue, collapseWhitespace, getDependencies, getSpecialProperties, getSubExpressions, inverse, 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(java.lang.String uri,
                  java.lang.String localName)
           throws XPathException
Constructor

Parameters:
uri - The namespace part of the QName
localName - The local part of the QName.
Method Detail

getStringValue

public java.lang.String getStringValue()
                                throws XPathException
Get the string value as a String. QNames are the only kind of values that cannot be converted to a string.

Specified by:
getStringValue in interface Item
Specified by:
getStringValue in class Value
Returns:
the string value of the item
Throws:
XPathException - if the string value cannot be obtained. Some items have no string value, e.g. a QName

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 null if the namespace-uri component is requested and is not present.

Overrides:
getComponent in class AtomicValue
Parameters:
part - either Component.LOCALNAME or Componenet.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)
                    throws XPathException
Convert to target data type

Specified by:
convert in class AtomicValue
Parameters:
requiredType - an integer identifying the required atomic type
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 anyURI values are equal

Overrides:
equals in class java.lang.Object
Throws:
java.lang.ClassCastException - if they are not comparable

hashCode

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

conversionPreference

public int conversionPreference(java.lang.Class required,
                                Configuration config)
Get conversion preference for this value to a Java class. A low result indicates higher preference.

Overrides:
conversionPreference in class AtomicValue

convertToJava

public java.lang.Object convertToJava(java.lang.Class target,
                                      Configuration config)
                               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

display

public void display(int level,
                    NamePool pool)
Diagnostic print of expression structure

Parameters:
level - indentation level for this expression

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object