net.sf.saxon.value
Class QNameValue

java.lang.Object
  extended by net.sf.saxon.value.Value
      extended by net.sf.saxon.value.AtomicValue
          extended by net.sf.saxon.value.QNameValue
All Implemented Interfaces:
Serializable, Expression, Item

public final class QNameValue
extends AtomicValue

A QName value

See Also:
Serialized Form

Constructor Summary
QNameValue(String uri, String localName)
          Constructor
 
Method Summary
 int conversionPreference(Class required)
          Get conversion preference for this value to a Java class.
 AtomicValue convert(int requiredType)
          Convert to target data type
 Object convertToJava(Class target)
          Convert to Java object (for passing to external functions)
 void display(int level, NamePool pool)
          Diagnostic print of expression structure
 boolean equals(Object other)
          Determine if two anyURI values are equal
 AtomicValue getComponent(int part)
          Get a component.
 ItemType getItemType()
          Return the type of the expression
 String getLocalName()
          Get the local part
 String getNamespaceURI()
          Get the namespace part (null means no namespace)
 String getStringValue()
          Get the string value as a String.
 int hashCode()
           
static String makeTriple(String prefix, String uri, String localName)
          Internally we sometimes hold QNames in the form "{uri}[prefix]:local-name".
static String[] parseTriple(CharSequence triple)
          This method extracts the three components of a QNameTriple.
 String toString()
           
 
Methods inherited from class net.sf.saxon.value.AtomicValue
convert, 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, stringToInteger, stringToNumber, trimWhitespace
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QNameValue

public QNameValue(String uri,
                  String localName)
           throws XPathException
Constructor

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

getStringValue

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

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 String getLocalName()
Get the local part


getNamespaceURI

public 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(Object other)
Determine if two anyURI values are equal

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

conversionPreference

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

Overrides:
conversionPreference in class AtomicValue

convertToJava

public Object convertToJava(Class target)
                     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
Returns:
an object of the target class
Throws:
XPathException

display

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

Parameters:
level - indentation level for this expression

toString

public String toString()
Overrides:
toString in class Object

makeTriple

public static String makeTriple(String prefix,
                                String uri,
                                String localName)
Internally we sometimes hold QNames in the form "{uri}[prefix]:local-name". This is referred to as a QNameTriple This method constructs a QNameTriple from its components


parseTriple

public static String[] parseTriple(CharSequence triple)
This method extracts the three components of a QNameTriple. They are returned as an array of three strings containing respectively the prefix, the uri, and the local name