public class SingletonMap extends AbstractItem implements MapItem, GroundedValue
Constructor and Description |
---|
SingletonMap(AtomicValue key,
Sequence value)
Construct the singleton map
|
Modifier and Type | Method and Description |
---|---|
Sequence |
call(XPathContext context,
Sequence[] args)
Invoke the function
|
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 of the map
|
String |
getCollationName()
Get the name of the collation of the map
|
FunctionItemType |
getFunctionItemType(TypeHierarchy th)
Get the item type of the 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
|
String |
getStringValue()
Get the value of the item as a string.
|
CharSequence |
getStringValueCS()
Get the string value of the item as a CharSequence.
|
SequenceIterator<? extends 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
|
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 collationName,
StringCollator collation)
Set the collation of the map
|
int |
size()
Get the size of the map
|
getLength, head, iterate, reduce, subsequence
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getLength, reduce, subsequence
public SingletonMap(AtomicValue key, Sequence value)
key
- the keyvalue
- the valuepublic void setCollation(String collationName, StringCollator collation)
collationName
- the name of the collation to be used by this mapcollation
- the corresponding collation objectpublic StringCollator getCollation()
getCollation
in interface MapItem
public String getCollationName()
getCollationName
in interface MapItem
public Sequence get(AtomicValue key, XPathContext context) throws XPathException
get
in interface MapItem
key
- the value of the keycontext
- the XPath dynamic evaluation contextXPathException
- if a dynamic error occurspublic MapItem remove(AtomicValue key, XPathContext context) throws XPathException
remove
in interface MapItem
key
- the key of the entry to be removedcontext
- the XPath dynamic contextXPathException
- if a dynamic error occurspublic int size()
public boolean isEmpty()
public UnfailingIterator<AtomicValue> keys()
public AtomicType getKeyType(TypeHierarchy th)
getKeyType
in interface MapItem
th
- the type hierarchypublic SequenceType getValueType(TypeHierarchy th)
getValueType
in interface MapItem
th
- the type hierarchypublic FunctionItemType getFunctionItemType(TypeHierarchy th)
getFunctionItemType
in interface FunctionItem
th
- the type hierarchy cache. If null is supplied, the resulting item type may be less precise.public StructuredQName getFunctionName()
getFunctionName
in interface FunctionItem
public int getArity()
getArity
in interface FunctionItem
public Sequence call(XPathContext context, Sequence[] args) throws XPathException
call
in interface Callable
call
in interface FunctionItem
context
- the XPath dynamic evaluation contextargs
- the actual arguments to be suppliedXPathException
- if a dynamic error occurspublic String getStringValue()
getStringValueCS()
should
be used. If the caller requires a string, this method is preferred.getStringValue
in interface GroundedValue
getStringValue
in interface Item
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)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 GroundedValue
getStringValueCS
in interface Item
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)getStringValue()
public SequenceIterator<? extends 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 FunctionItem
other
- 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)
AbstractItem
itemAt
in interface GroundedValue
itemAt
in class AbstractItem
n
- the index of the required item, with 0 representing the first item in the sequencepublic boolean effectiveBooleanValue() throws XPathException
GroundedValue
effectiveBooleanValue
in interface GroundedValue
XPathException
- if the sequence has no effective boolean value (for example a sequence of two integers)Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.