public class ImmutableMap extends AbstractItem implements MapItem, GroundedValue
| Modifier and Type | Field and Description |
|---|---|
static SequenceType |
SINGLE_MAP_TYPE |
| Constructor and Description |
|---|
ImmutableMap()
Create an empty map
|
ImmutableMap(MapItem map,
StringCollator collation,
XPathContext context)
Create an ImmutableMap whose entries are copies of the entries in an existing MapItem,
and whose collation is as supplied
|
| Modifier and Type | Method and Description |
|---|---|
Sequence |
call(XPathContext context,
Sequence[] args)
Invoke the function
|
ImmutableMap |
copyPut(AtomicValue key,
Sequence value,
XPathContext context)
Create a new map containing the existing entries in the map plus an additional entry,
without modifying the original
|
boolean |
deepEquals(FunctionItem 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
|
Sequence |
get(AtomicValue key,
XPathContext context)
Get an entry from the Map
|
int |
getArity()
Get the arity of the function
|
StringCollator |
getCollation()
Get the collation used for the map
|
String |
getCollationName()
Get the name of the collation of the map
|
FunctionItemType |
getFunctionItemType(TypeHierarchy th)
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
|
AtomicType |
getKeyType(TypeHierarchy th)
Get the lowest common item type of the keys in the map
|
com.saxonica.functions.map.KeyValuePair |
getKeyValuePair(AtomicValue key,
XPathContext context)
Get an entry from the Map
|
String |
getStringValue()
Get the value of the item as a string.
|
CharSequence |
getStringValueCS()
Get the string value of the item as a CharSequence.
|
SequenceIterator<AtomicValue> |
getTypedValue()
Get the typed value of the item.
|
SequenceType |
getValueType(TypeHierarchy th)
Get the lowest common sequence type of all the values in the map
|
void |
inSituPut(AtomicValue key,
Sequence value,
XPathContext context)
Add a new entry to this map, modifying the original in place
|
boolean |
isEmpty()
Ask whether the map is empty
|
MapItem |
itemAt(int n)
Get the n'th item in the value, counting from 0
|
UnfailingIterator<AtomicValue> |
keys()
Get the set of all key values in the map
|
MapItem |
remove(AtomicValue key,
XPathContext context)
Remove an entry from the map
|
void |
setCollation(String name,
StringCollator collation)
Set the collation to be used for the map
|
int |
size()
Get the size of the map
|
getLength, head, iterate, reduce, subsequenceclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetLength, reduce, subsequencepublic static final SequenceType SINGLE_MAP_TYPE
public ImmutableMap()
public ImmutableMap(MapItem map, StringCollator collation, XPathContext context) throws XPathException
map - the existing map to be copiedcollation - the collationcontext - the XPath dynamic contextXPathException - if a dynamic error occurspublic void setCollation(String name, StringCollator collation)
name - the name of the collation to be usedcollation - the corresponding collation objectpublic StringCollator getCollation()
getCollation in interface MapItempublic String getCollationName()
getCollationName in interface MapItempublic int size()
public boolean isEmpty()
public AtomicType getKeyType(TypeHierarchy th)
getKeyType in interface MapItemth - the type hierarchypublic SequenceType getValueType(TypeHierarchy th)
getValueType in interface MapItemth - the type hierarchypublic ImmutableMap copyPut(AtomicValue key, Sequence value, XPathContext context) throws XPathException
key - the key of the new entryvalue - the value associated with the new entrycontext - the XPath dynamic contextXPathException - if a dynamic error occurspublic void inSituPut(AtomicValue key, Sequence value, XPathContext context) throws XPathException
key - the key of the new entryvalue - the value associated with the new entrycontext - the XPath dynamic contextXPathException - if a dynamic error occurspublic MapItem remove(AtomicValue key, XPathContext context) throws XPathException
remove in interface MapItemkey - the key of the entry to be removedcontext - the XPath dynamic contextXPathException - if a dynamic error occurspublic Sequence get(AtomicValue key, XPathContext context) throws XPathException
get in interface MapItemkey - the value of the keycontext - the XPath dynamic evaluation contextXPathException - if a dynamic error occurspublic com.saxonica.functions.map.KeyValuePair getKeyValuePair(AtomicValue key, XPathContext context) throws XPathException
key - the value of the keycontext - the XPath dynamic evaluation contextXPathException - if a dynamic error occurspublic UnfailingIterator<AtomicValue> keys()
public FunctionItemType getFunctionItemType(TypeHierarchy th)
getFunctionItemType in interface FunctionItemth - the type heirarchy cachepublic StructuredQName getFunctionName()
getFunctionName in interface FunctionItempublic int getArity()
getArity in interface FunctionItempublic Sequence call(XPathContext context, Sequence[] args) throws XPathException
call in interface Callablecall in interface FunctionItemcontext - the XPath dynamic evaluation contextargs - the actual arguments to be suppliedXPathExceptionpublic String getStringValue()
getStringValueCS() should
be used. If the caller requires a string, this method is preferred.getStringValue in interface GroundedValuegetStringValue in interface ItemUnsupportedOperationException - 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)getStringValueCS()public CharSequence getStringValueCS()
X.getStringValueCS().toString() returns a string that is equal to
X.getStringValue().
Note that two CharSequence values of different types should not be compared using equals(), and
for the same reason they should not be used as a key in a hash table.
If the calling code can handle any CharSequence, this method should
be used. If the caller requires a string, the getStringValue() method is preferred.getStringValueCS in interface GroundedValuegetStringValueCS in interface ItemUnsupportedOperationException - 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)getStringValue()public SequenceIterator<AtomicValue> getTypedValue() throws XPathException
XPathException - where no typed value is available, for example in the case of
an element with complex contentpublic boolean deepEquals(FunctionItem other, XPathContext context, AtomicComparer comparer, int flags) throws XPathException
deepEquals in interface FunctionItemother - 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)
AbstractItemitemAt in interface GroundedValueitemAt in class AbstractItemn - 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)Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.