net.sf.saxon.value
Class DerivedAtomicValue

java.lang.Object
  |
  +--net.sf.saxon.value.Value
        |
        +--net.sf.saxon.value.AtomicValue
              |
              +--net.sf.saxon.value.DerivedAtomicValue
All Implemented Interfaces:
Expression, Item, java.io.Serializable

public class DerivedAtomicValue
extends AtomicValue
implements Item

A DerivedAtomicValue is an atomic value of a user-defined type

See Also:
Serialized Form

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 the value to a given 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)
          Display the value as part of an expression tree display
 boolean effectiveBooleanValue(XPathContext context)
          Get the effective boolean value of the value
 boolean equals(java.lang.Object obj)
          Determine if this value is equal to another value
 Item evaluateItem(XPathContext context)
          Evaluate the value (this simply returns the value unchanged)
 ItemType getItemType()
          Get the item type of this atomic value
 AtomicValue getPrimitiveValue()
          Get the primitive value (the value in the value space)
 java.lang.String getStringValue()
          Evaluate as a string
 int hashCode()
          Generate a hash code to support equality testing
static DerivedAtomicValue makeValue(AtomicValue primValue, java.lang.String lexicalValue, AtomicType type, boolean throwError)
          Create a value of a user-defined atomic type
 java.lang.String toString()
          Generate a string representation suitable for error messages
 
Methods inherited from class net.sf.saxon.value.AtomicValue
convert, evaluateAsString, getCardinality, getComponent, 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
 
Methods inherited from interface net.sf.saxon.om.Item
getTypedValue
 

Method Detail

makeValue

public static DerivedAtomicValue makeValue(AtomicValue primValue,
                                           java.lang.String lexicalValue,
                                           AtomicType type,
                                           boolean throwError)
                                    throws XPathException
Create a value of a user-defined atomic type

Parameters:
primValue - the value in the value space of the primitive type
lexicalValue - the value in the lexical space. If null, the string value of primValue is used. This value is checked against the pattern facet (if any)
type - the required atomic type
throwError - true if an exception is to be thrown when the value is invalid (if false, the method returns null instead)
Throws:
XPathException - if the value is invalid

getPrimitiveValue

public AtomicValue getPrimitiveValue()
Get the primitive value (the value in the value space)

Overrides:
getPrimitiveValue in class AtomicValue

convert

public AtomicValue convert(int requiredType)
                    throws XPathException
Convert the value to a given type. The result of the conversion will be an atomic value of the required type.

Specified by:
convert in class AtomicValue
Parameters:
requiredType - type code of the required atomic type
Returns:
the result of the conversion, if conversion was possible. This will always be an instance of the class corresponding to the type of value requested
Throws:
XPathException - if conversion is not allowed for this required type, or if the particular value cannot be converted

evaluateItem

public Item evaluateItem(XPathContext context)
                  throws XPathException
Evaluate the value (this simply returns the value unchanged)

Specified by:
evaluateItem in interface Expression
Overrides:
evaluateItem in class AtomicValue
Parameters:
context - the evaluation context (not used in this implementation)
Returns:
the value, unchanged
Throws:
XPathException

getStringValue

public java.lang.String getStringValue()
                                throws XPathException
Evaluate as 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

effectiveBooleanValue

public boolean effectiveBooleanValue(XPathContext context)
Get the effective boolean value of the value

Specified by:
effectiveBooleanValue in interface Expression
Overrides:
effectiveBooleanValue in class AtomicValue
Parameters:
context - the evaluation context (not used in this implementation)
Returns:
true, unless the value is boolean false, numeric zero, or zero-length string

convertToJava

public java.lang.Object convertToJava(java.lang.Class target,
                                      Configuration config)
                               throws XPathException
Description copied from class: AtomicValue
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

conversionPreference

public int conversionPreference(java.lang.Class required,
                                Configuration config)
Description copied from class: AtomicValue
Get conversion preference for this value to a Java class. A low result indicates higher preference. This method is overridden in subclasses, but it contains common functionality to supply a scalar value to a method expecting a list or iterator.

Overrides:
conversionPreference in class AtomicValue

getItemType

public ItemType getItemType()
Get the item type of this atomic value

Specified by:
getItemType in interface Expression
Returns:
the item type

display

public void display(int level,
                    NamePool pool)
Display the value as part of an expression tree display

Specified by:
display in interface Expression
Parameters:
level - indentation level of this subexpression
pool - NamePool for resolving names

hashCode

public int hashCode()
Generate a hash code to support equality testing

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code of the primitive base value

equals

public boolean equals(java.lang.Object obj)
Determine if this value is equal to another value

Overrides:
equals in class java.lang.Object
Parameters:
obj - the other value to be compared
Returns:
true if the values are equal according to the XPath rules

toString

public java.lang.String toString()
Generate a string representation suitable for error messages

Overrides:
toString in class java.lang.Object
Returns:
the string representation for the primitive base type