net.sf.saxon.value
Class AtomicUserDefinedValue

java.lang.Object
  extended bynet.sf.saxon.value.Value
      extended bynet.sf.saxon.value.AtomicValue
          extended bynet.sf.saxon.value.AtomicUserDefinedValue
All Implemented Interfaces:
Expression, Item, java.io.Serializable

public class AtomicUserDefinedValue
extends AtomicValue
implements Item

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

See Also:
Serialized Form

Field Summary
(package private)  AtomicValue primitiveValue
           
(package private)  AtomicType typeLabel
           
 
Method Summary
 int conversionPreference(java.lang.Class required)
          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)
          Convert to Java object (for passing to external functions)
 void display(int level, NamePool pool)
          Diagnostic print of expression structure.
 boolean effectiveBooleanValue(XPathContext context)
          Get the effective boolean value of the value
 boolean equals(java.lang.Object obj)
           
 Item evaluateItem(XPathContext context)
          Evaluate the value (this simply returns the value unchanged)
 ItemType getItemType()
          Determine the data type of the expression, if possible.
 AtomicValue getPrimitiveValue()
          Get the primitive value (the value in the value space)
 java.lang.String getStringValue()
          Evaluate as a string
 int hashCode()
           
static AtomicUserDefinedValue makeValue(AtomicValue primValue, AtomicType type, boolean throwError)
          Create a value of a user-defined atomic type
 
Methods inherited from class net.sf.saxon.value.AtomicValue
convert, 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, stringToInteger, stringToNumber, trimWhitespace
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.saxon.om.Item
getTypedValue
 

Field Detail

primitiveValue

AtomicValue primitiveValue

typeLabel

AtomicType typeLabel
Method Detail

makeValue

public static AtomicUserDefinedValue makeValue(AtomicValue primValue,
                                               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
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
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

hashCode

public int hashCode()

convertToJava

public java.lang.Object convertToJava(java.lang.Class target)
                               throws XPathException
Description copied from class: AtomicValue
Convert to Java object (for passing to external functions)

Overrides:
convertToJava in class AtomicValue
Throws:
XPathException

conversionPreference

public int conversionPreference(java.lang.Class required)
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()
Description copied from interface: Expression
Determine the data type of the expression, if possible. All expression return sequences, in general; this method determines the type of the items within the sequence, assuming that (a) this is known in advance, and (b) it is the same for all items in the sequence.

This method should always return a result, though it may be the best approximation that is available at the time.

Specified by:
getItemType in interface Expression
Returns:
a value such as Type.STRING, Type.BOOLEAN, Type.NUMBER, Type.NODE, or Type.ITEM (meaning not known at compile time)

display

public void display(int level,
                    NamePool pool)
Description copied from interface: Expression
Diagnostic print of expression structure. The expression is written to the System.err output stream

Specified by:
display in interface Expression
Parameters:
level - indentation level for this expression

equals

public boolean equals(java.lang.Object obj)