com.saxonica.schema
Class DerivedAtomicValue

java.lang.Object
  extended bynet.sf.saxon.value.Value
      extended bynet.sf.saxon.value.AtomicValue
          extended bycom.saxonica.schema.DerivedAtomicValue
All Implemented Interfaces:
Expression, Item, java.io.Serializable, ValueRepresentation

public class DerivedAtomicValue
extends AtomicValue

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

See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sf.saxon.value.Value
EMPTY_CLASS_ARRAY
 
Fields inherited from interface net.sf.saxon.om.ValueRepresentation
EMPTY_VALUE_ARRAY
 
Fields inherited from interface net.sf.saxon.expr.Expression
EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD
 
Method Summary
 AtomicValue convertPrimitive(BuiltInAtomicType requiredType, boolean validate, XPathContext context)
          Convert a value to another primitive data type, with control over how validation is handled.
 java.lang.Object convertToJava(java.lang.Class target, XPathContext context)
          Convert to Java object (for passing to external functions)
 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(TypeHierarchy th)
          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
 java.lang.CharSequence getStringValueCS()
          Get the value of the item as a CharSequence.
 boolean hasBuiltInType()
          Test whether the type of this atomic value is a built-in type.
 int hashCode()
          Generate a hash code to support equality testing
static AtomicValue makeValue(AtomicValue primValue, java.lang.CharSequence lexicalValue, UserAtomicType type, boolean validate)
          Create a value of a user-defined atomic type
 boolean schemaEquals(Value obj)
          Compare two values for equality.
 java.lang.String toString()
          Generate a string representation suitable for error messages
 
Methods inherited from class net.sf.saxon.value.AtomicValue
checkPermittedContents, convert, convert, display, evaluateAsString, getCardinality, getComponent, getImplementationMethod, getLength, getTypedValue, iterate, process
 
Methods inherited from class net.sf.saxon.value.Value
asItem, asIterator, asValue, collapseWhitespace, convert, convertJavaObjectToXPath, getDependencies, getIterator, getParentExpression, getSpecialProperties, itemAt, iterateSubExpressions, makeQNameValue, normalizeWhitespace, optimize, promote, reduce, simplify, stringToNumber, trimWhitespace, typeCheck
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

makeValue

public static AtomicValue makeValue(AtomicValue primValue,
                                    java.lang.CharSequence lexicalValue,
                                    UserAtomicType type,
                                    boolean validate)
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
validate - true if validation is required. If this is set to false, the caller is responsible for ensuring that the value has previously been checked to be valid.
Returns:
the derived atomic value if validation succeeds; or an ErrorValue if validation fails. It is the caller's responsibility to check for this. An ErrorValue may result even if the caller requested no validation, since this request is not always honoured.

hasBuiltInType

public boolean hasBuiltInType()
Test whether the type of this atomic value is a built-in type. This implementation returns false.

Overrides:
hasBuiltInType in class AtomicValue

getPrimitiveValue

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

Overrides:
getPrimitiveValue in class AtomicValue

convertPrimitive

public AtomicValue convertPrimitive(BuiltInAtomicType requiredType,
                                    boolean validate,
                                    XPathContext context)
Convert a value to another primitive data type, with control over how validation is handled.

Specified by:
convertPrimitive in class AtomicValue
Parameters:
requiredType - type code of the required atomic type
validate - true if validation is required. If set to false, the caller guarantees that the value is valid for the target data type, and that further validation is therefore not required. Note that a validation failure may be reported even if validation was not requested.
context -
Returns:
the result of the conversion, if successful. If unsuccessful, the value returned will be a ValidationErrorValue. The caller must check for this condition. No exception is thrown, instead the exception will be encapsulated within the ErrorValue.

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()
Evaluate as a string

Specified by:
getStringValue in interface Item
Specified by:
getStringValue in class AtomicValue

getStringValueCS

public java.lang.CharSequence getStringValueCS()
Get the value of the item as a CharSequence. This is in some cases more efficient than the version of the method that returns a String.

Specified by:
getStringValueCS in interface Item
Overrides:
getStringValueCS in class AtomicValue

effectiveBooleanValue

public boolean effectiveBooleanValue(XPathContext context)
                              throws XPathException
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
Throws:
XPathException

convertToJava

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

Overrides:
convertToJava in class Value
Throws:
XPathException

getItemType

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

Specified by:
getItemType in interface Expression
Overrides:
getItemType in class Value
Parameters:
th -
Returns:
the item type

hashCode

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

Overrides:
hashCode in class Value
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 Value
Parameters:
obj - the other value to be compared
Returns:
true if the values are equal according to the XPath rules

schemaEquals

public boolean schemaEquals(Value obj)
Compare two values for equality. This supports identity constraints in XML Schema, which allow list-valued elements and attributes to participate in key and uniqueness constraints. This method returns false if any error occurs during the comparison, or if any of the items in either sequence is a node rather than an atomic value. The default implementation of schemaEquals() is the same as equals(), but subclasses can override this.

Overrides:
schemaEquals in class AtomicValue

toString

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

Overrides:
toString in class AtomicValue
Returns:
the string representation for the primitive base type