Package net.sf.saxon.value
Class ShareableSequence
- java.lang.Object
-
- net.sf.saxon.value.Value
-
- net.sf.saxon.value.ShareableSequence
-
- All Implemented Interfaces:
ValueRepresentation
public final class ShareableSequence extends Value
A sequence value implemented extensionally using an extensible List whose leading part can be shared with other sequence values. The list can be appended to by other users (at most one other user!), but the items within the range used by this sequence value cannot be modified.
-
-
Field Summary
-
Fields inherited from class net.sf.saxon.value.Value
INDETERMINATE_ORDERING
-
Fields inherited from interface net.sf.saxon.om.ValueRepresentation
EMPTY_VALUE_ARRAY
-
-
Constructor Summary
Constructors Constructor Description ShareableSequence(java.util.List list)
Construct an sequence from an array of items.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
effectiveBooleanValue()
Get the effective boolean valueint
getCardinality()
Determine the cardinalityItemType
getItemType(TypeHierarchy th)
Get the (lowest common) item typeint
getLength()
Get the number of items in the sequencejava.util.List
getList()
Get the underlying listboolean
isShareable()
Determine whether another value can share this list.Item
itemAt(int n)
Get the n'th item in the sequence (starting with 0 as the first item)SequenceIterator
iterate()
Return an iterator over this sequence.static ShareableSequence
makeShareableSequence(Value baseVal, SequenceIterator iter)
Make a new ShareableSequence from an existing value and an iterator over items to be appended to the sequenceValue
reduce()
Reduce a value to its simplest form.Value
simplify()
Simplify this valuejava.lang.String
toString()
-
Methods inherited from class net.sf.saxon.value.Value
asItem, asItem, asIterator, asValue, checkPermittedContents, convertToJava, equals, fromItem, getCanonicalLexicalRepresentation, getIterator, getSchemaComparable, getSequenceLength, getStringValue, getStringValueCS, hashCode, isIdentical, process
-
-
-
-
Constructor Detail
-
ShareableSequence
public ShareableSequence(java.util.List list)
Construct an sequence from an array of items. Note, the list of items is used as is, which means the caller must not subsequently change its contents; however it is permitted to subsequently append items to the list (indeed, that is the raison d'etre of this class)- Parameters:
list
- the list of items to be included in the sequence
-
-
Method Detail
-
makeShareableSequence
public static ShareableSequence makeShareableSequence(Value baseVal, SequenceIterator iter) throws XPathException
Make a new ShareableSequence from an existing value and an iterator over items to be appended to the sequence- Parameters:
baseVal
- the base value (which may or may not be a ShareableSequence)iter
- the items to be added- Returns:
- a ShareableSequence containing the concatenation of the base value and the new items, optimized for further shared appending.
- Throws:
XPathException
-
isShareable
public boolean isShareable()
Determine whether another value can share this list. This is true provided the list has not already been extended by another value.- Returns:
- true if another value can share this list
-
getList
public java.util.List getList()
Get the underlying list- Returns:
- the underlying list of values
-
simplify
public Value simplify()
Simplify this value- Returns:
- the simplified value
-
reduce
public Value reduce()
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
-
getLength
public int getLength()
Get the number of items in the sequence
-
getCardinality
public int getCardinality()
Determine the cardinality- Overrides:
getCardinality
in classValue
- Returns:
- the cardinality of the sequence, using the constants defined in net.sf.saxon.value.Cardinality
- See Also:
Cardinality
-
getItemType
public ItemType getItemType(TypeHierarchy th)
Get the (lowest common) item type- Overrides:
getItemType
in classValue
- Parameters:
th
- the type hierarchy cache. If null is supplied, the resulting value may be less precise- Returns:
- integer identifying an item type to which all the items in this sequence conform
-
itemAt
public Item itemAt(int n)
Get the n'th item in the sequence (starting with 0 as the first item)
-
iterate
public SequenceIterator iterate()
Return an iterator over this sequence.
-
effectiveBooleanValue
public boolean effectiveBooleanValue() throws XPathException
Get the effective boolean value- Overrides:
effectiveBooleanValue
in classValue
- Returns:
- the effective boolean value
- Throws:
XPathException
- if any dynamic error occurs evaluating the expression
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-