com.saxonica.deploy
Class ItemClosure

java.lang.Object
  extended by net.sf.saxon.value.Value
      extended by com.saxonica.deploy.ItemClosure
All Implemented Interfaces:
Serializable, SequenceIterable, ValueRepresentation

public class ItemClosure
extends Value

An ItemClosure represents a singleton value that has not yet been evaluated: the value is represented by an EvaluableItem object which performs the evaluation. Once this has been called the first time, the actual item value is stored in the ItemClosure for use on subsequent occasions.

This class is currently used only by the Saxon-SA Java code-generator.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sf.saxon.value.Value
EMPTY_CLASS_ARRAY, INDETERMINATE_ORDERING
 
Fields inherited from interface net.sf.saxon.om.ValueRepresentation
EMPTY_VALUE_ARRAY
 
Constructor Summary
ItemClosure(EvaluableItem evaluator, XPathContext context, int primitiveType)
          Create an ItemClosure
 
Method Summary
 Item asItem()
          Evaluate as a singleton item (or empty sequence).
 int getCardinality()
          Get the cardinality.
 ItemType getItemType(TypeHierarchy th)
          Get the static item type
 int getLength()
          Get the length of the value.
 Comparable getSchemaComparable()
          Get a Comparable value that implements the XML Schema ordering comparison semantics for this value.
 Item itemAt(int n)
          Get the n'th item in the sequence (starting from 0).
 SequenceIterator iterate()
          Evaluate the expression in a given context to return an iterator over a sequence
 Value reduce()
          Reduce a value to its simplest form.
 
Methods inherited from class net.sf.saxon.value.Value
asItem, asIterator, asValue, checkPermittedContents, convertJavaObjectToXPath, convertToJava, convertToJava, effectiveBooleanValue, equals, fromItem, getCanonicalLexicalRepresentation, getIterator, getStringValue, getStringValueCS, iterate, makeQNameValue, process, stringToNumber, toString
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ItemClosure

public ItemClosure(EvaluableItem evaluator,
                   XPathContext context,
                   int primitiveType)
Create an ItemClosure

Parameters:
evaluator - used to do deferred evaluation of the item
context - XPath dynamic context for evaluating the item
primitiveType - the expected primitive type of the result
Method Detail

getItemType

public ItemType getItemType(TypeHierarchy th)
Get the static item type

Overrides:
getItemType in class Value
Parameters:
th - the type hierarchy cache
Returns:
for the default implementation: AnyItemType (not known)

getCardinality

public int getCardinality()
Get the cardinality. This method is intended to be implemented in a subclass, but if it is not implemented, the fallback implementation simply returns StaticProperty.ALLOWS_ZERO_OR_MORE

Overrides:
getCardinality in class Value
Returns:
the cardinality

asItem

public Item asItem()
            throws XPathException
Evaluate as a singleton item (or empty sequence). Note: this implementation returns the first item in the sequence. The method should not be used unless appropriate type-checking has been done to ensure that the value will be a singleton.

Overrides:
asItem in class Value
Returns:
the value in the form of an Item
Throws:
XPathException

itemAt

public Item itemAt(int n)
            throws XPathException
Get the n'th item in the sequence (starting from 0). This is defined for all Values, but its real benefits come for a sequence Value stored extensionally (or for a MemoClosure, once all the values have been read)

Overrides:
itemAt in class Value
Parameters:
n - position of the required item, counting from zero.
Returns:
the n'th item in the sequence, where the first item in the sequence is numbered zero. If n is negative or >= the length of the sequence, returns null.
Throws:
XPathException

iterate

public SequenceIterator iterate()
                         throws XPathException
Evaluate the expression in a given context to return an iterator over a sequence

Specified by:
iterate in class Value
Returns:
an iterator over the sequence of items
Throws:
XPathException - if a dynamic error occurs. This is possible only in the case of values that are materialized lazily, that is, where the iterate() method leads to computation of an expression that delivers the values.

reduce

public Value reduce()
             throws XPathException
Reduce a value to its simplest form. If the value is a closure or some other form of deferred value such as a FunctionCallPackage, then it is reduced to a SequenceExtent. If it is a SequenceExtent containing a single item, then it is reduced to that item. One consequence that is exploited by class FilterExpression is that if the value is a singleton numeric value, then the result will be an instance of NumericValue

Overrides:
reduce in class Value
Returns:
the value in simplified form
Throws:
XPathException

getLength

public int getLength()
              throws XPathException
Get the length of the value. Note: this consumes the iterator!

Overrides:
getLength in class Value
Returns:
the number of items in the sequence
Throws:
XPathException

getSchemaComparable

public Comparable getSchemaComparable()
Get a Comparable value that implements the XML Schema ordering comparison semantics for this value. The default implementation returns "this", which ensures that comparisons between list values are handled by the equals() and compareTo() methods on this class itself. This is overridden for atomic values.

In the case of data types that are partially ordered, the returned Comparable extends the standard semantics of the compareTo() method by returning the value Value.INDETERMINATE_ORDERING when there is no defined order relationship between two given values.

Overrides:
getSchemaComparable in class Value
Returns:
a Comparable that follows XML Schema comparison rules


Copyright (C) Michael H. Kay. All rights reserved.