public abstract class MapItem extends java.lang.Object implements Function
| Constructor and Description |
|---|
MapItem() |
| Modifier and Type | Method and Description |
|---|---|
abstract MapItem |
addEntry(AtomicValue key,
GroundedValue value)
Create a new map containing the existing entries in the map plus an additional entry,
without modifying the original.
|
AtomicSequence |
atomize()
Atomize the item.
|
Sequence |
call(XPathContext context,
Sequence[] args)
Invoke the function
|
abstract boolean |
conforms(AtomicType keyType,
SequenceType valueType,
TypeHierarchy th)
Ask whether the map conforms to a given map type
|
boolean |
deepEquals(Function other,
XPathContext context,
AtomicComparer comparer,
int flags)
Test whether this FunctionItem is deep-equal to another function item,
under the rules of the deep-equal function
|
boolean |
effectiveBooleanValue()
Get the effective boolean value of this sequence
|
void |
export(ExpressionPresenter out)
Export information about this function item to the export() or explain() output
|
abstract GroundedValue |
get(AtomicValue key)
Get an entry from the Map
|
AnnotationList |
getAnnotations()
Get the function annotations (as defined in XQuery).
|
int |
getArity()
Get the arity of the function
|
java.lang.String |
getDescription()
Get a description of this function for use in error messages.
|
FunctionItemType |
getFunctionItemType()
Get the item type of this item as a function item.
|
StructuredQName |
getFunctionName()
Get the name of the function, or null if it is anonymous
|
Genre |
getGenre()
Get the genre of this item
|
abstract ItemType |
getItemType(TypeHierarchy th)
Get the type of the map.
|
static ItemType |
getItemTypeOfSequence(Sequence val)
Get an item type to which all the values in a sequence are known to conform
|
abstract UType |
getKeyUType()
Get the lowest common item type of the keys in the map
|
OperandRole[] |
getOperandRoles()
Get the roles of the arguments, for the purposes of streaming
|
SequenceIterator |
getTypedValue()
Get the typed value of the item.
|
UnicodeString |
getUnicodeStringValue()
Get the value of the item as a string.
|
boolean |
isArray()
Ask whether this function item is an array
|
boolean |
isEmpty()
Ask whether the map is empty
|
static boolean |
isKnownToConform(Sequence value,
ItemType itemType)
Ask whether all the items in a sequence are known to conform to a given item type
|
boolean |
isMap()
Ask whether this function item is a map
|
boolean |
isTrustedResultType()
Ask if the function can be trusted to return a result of the correct type
|
MapItem |
itemAt(int n)
Get the n'th item in the value, counting from 0
|
abstract AtomicIterator |
keys()
Get the set of all key values in the map.
|
abstract java.lang.Iterable<KeyValuePair> |
keyValuePairs()
Get the set of all key-value pairs in the map
|
XPathContext |
makeNewContext(XPathContext callingContext,
ContextOriginator originator)
Prepare an XPathContext object for evaluating the function
|
static java.lang.String |
mapToString(MapItem map)
Returns a string representation of the map.
|
abstract MapItem |
remove(AtomicValue key)
Remove an entry from the map
|
abstract int |
size()
Get the size of the map
|
java.lang.String |
toShortString()
Provide a short string showing the contents of the item, suitable
for use in error messages
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisSequenceVariadicgetLength, getStringValue, head, isStreamed, iterate, reduce, subsequenceasIterable, concatenate, containsNode, materializemakeRepeatablepublic abstract GroundedValue get(AtomicValue key)
key - the value of the keypublic abstract int size()
public boolean isEmpty()
public abstract AtomicIterator keys()
public abstract java.lang.Iterable<KeyValuePair> keyValuePairs()
public abstract MapItem addEntry(AtomicValue key, GroundedValue value)
key - the key of the new entryvalue - the value associated with the new entrypublic abstract MapItem remove(AtomicValue key)
key - the key of the entry to be removedpublic abstract boolean conforms(AtomicType keyType, SequenceType valueType, TypeHierarchy th)
keyType - the required keyTypevalueType - the required valueTypeth - the type hierarchy cache for the configurationpublic abstract ItemType getItemType(TypeHierarchy th)
th - the type hierarchy cachepublic abstract UType getKeyUType()
public java.lang.String toShortString()
toShortString in interface FunctiontoShortString in interface GroundedValuetoShortString in interface Itempublic Genre getGenre()
public boolean isArray()
public boolean isMap()
public AnnotationList getAnnotations()
getAnnotations in interface Functionpublic AtomicSequence atomize() throws XPathException
atomize in interface ItemXPathException - if atomization is not allowed for this kind of itempublic static boolean isKnownToConform(Sequence value, ItemType itemType)
value - the sequenceitemType - the given item typepublic static ItemType getItemTypeOfSequence(Sequence val)
val - the sequencepublic OperandRole[] getOperandRoles()
getOperandRoles in interface Functionpublic FunctionItemType getFunctionItemType()
getFunctionItemType in interface Functionpublic StructuredQName getFunctionName()
getFunctionName in interface Functionpublic java.lang.String getDescription()
getDescription in interface Functionpublic int getArity()
public XPathContext makeNewContext(XPathContext callingContext, ContextOriginator originator)
makeNewContext in interface FunctioncallingContext - the XPathContext of the function calling expressionoriginator - not usedpublic Sequence call(XPathContext context, Sequence[] args) throws XPathException
call in interface Callablecontext - the XPath dynamic evaluation contextargs - the actual arguments to be suppliedXPathException - if an error occurs evaluating
the supplied argumentpublic UnicodeString getUnicodeStringValue()
getUnicodeStringValue in interface GroundedValuegetUnicodeStringValue in interface Itemjava.lang.UnsupportedOperationException - if the item is a function item (an unchecked exception
is used here to avoid introducing exception handling to a large number of paths where it is not
needed)public SequenceIterator getTypedValue() throws XPathException
For a node, this is the typed value as defined in the XPath 2.0 data model. Since a node may have a list-valued data type, the typed value is in general a sequence, and it is returned in the form of a SequenceIterator.
If the node has not been validated against a schema, the typed value will be the same as the string value, either as an instance of xs:string or as an instance of xs:untypedAtomic, depending on the node kind.
For an atomic value, this method returns an iterator over a singleton sequence containing the atomic value itself.
XPathException - where no typed value is available, for example in the case of
an element with complex contentpublic boolean deepEquals(Function other, XPathContext context, AtomicComparer comparer, int flags) throws XPathException
deepEquals in interface Functionother - the other function itemcontext - the dynamic evaluation contextcomparer - the object to perform the comparisonflags - options for how the comparison is performedXPathException - if the comparison cannot be performedpublic MapItem itemAt(int n)
ItemitemAt in interface GroundedValueitemAt in interface Itemn - the index of the required item, with 0 representing the first item in the sequencepublic boolean effectiveBooleanValue()
throws XPathException
GroundedValueeffectiveBooleanValue in interface GroundedValueXPathException - if the sequence has no effective boolean value (for example a sequence of two integers)public static java.lang.String mapToString(MapItem map)
map - the input mappublic void export(ExpressionPresenter out) throws XPathException
export in interface Functionout - the destination for the informationXPathException - if things go wrongpublic boolean isTrustedResultType()
FunctionisTrustedResultType in interface FunctionCopyright (c) 2004-2022 Saxonica Limited. All rights reserved.