public class XdmMap extends XdmFunctionItem implements java.util.Map<XdmAtomicValue,XdmValue>
Map.
An XdmMap is immutable.
| Constructor and Description |
|---|
XdmMap()
Create an empty XdmMap
|
XdmMap(java.util.Map<? extends XdmAtomicValue,? extends XdmValue> map)
Create an XdmMap supplying the entries in the form of a Java Map,
where the keys and values in the Java Map are XDM values
|
XdmMap(MapItem map)
Create an XdmMap whose underlying value is a MapItem
|
| Modifier and Type | Method and Description |
|---|---|
java.util.Map<XdmAtomicValue,XdmValue> |
asMap()
Return a corresponding Java Map.
|
void |
clear()
Removes all of the mappings from this map (optional operation).
|
boolean |
containsKey(java.lang.Object key)
Returns true if this map contains a mapping for the specified
key.
|
boolean |
containsValue(java.lang.Object value)
Returns true if this map maps one or more keys to the
specified value.
|
java.util.Set<java.util.Map.Entry<XdmAtomicValue,XdmValue>> |
entrySet()
Returns a
Set view of the mappings contained in this map. |
XdmValue |
get(java.lang.Object key)
Returns the value to which the specified key is mapped,
or
null if this map contains no mapping for the key. |
MapItem |
getUnderlyingValue()
Get the underlying implementation object representing the value.
|
boolean |
isEmpty()
Returns true if this map contains no key-value mappings.
|
java.util.Set<XdmAtomicValue> |
keySet()
Get the keys present in the map in the form of a list.
|
static XdmMap |
makeMap(java.util.Map input)
Static factory method to construct an XDM map by converting each entry
in a supplied Java map.
|
int |
mapSize()
Get the number of entries in the map
|
XdmMap |
put(XdmAtomicValue key,
XdmValue value)
Create a new map containing an additional (key, value) pair.
|
void |
putAll(java.util.Map<? extends XdmAtomicValue,? extends XdmValue> m)
Copies all of the mappings from the specified map to this map
(optional operation).
|
XdmValue |
remove(java.lang.Object key)
Removes the mapping for a key from this map if it is present
(optional operation).
|
XdmMap |
remove(XdmAtomicValue key)
Create a new map in which the entry for a given key has been removed.
|
java.util.Collection<XdmValue> |
values()
Returns a
Collection view of the values contained in this map. |
call, getArity, getName, getSystemFunction, isAtomicValuegetStringValue, size, wrapItemappend, itemAt, iterator, makeSequence, makeValue, setValue, toString, wrapclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitpublic XdmMap()
public XdmMap(MapItem map)
map - the MapItem to be encapsulatedpublic XdmMap(java.util.Map<? extends XdmAtomicValue,? extends XdmValue> map)
map - a Java map whose entries are the (key, value) pairspublic MapItem getUnderlyingValue()
getUnderlyingValue in class XdmItempublic int mapSize()
XdmItem.size() method returns 1 (one),
because an XDM map is an item.)public XdmMap put(XdmAtomicValue key, XdmValue value)
put in interface java.util.Map<XdmAtomicValue,XdmValue>public XdmMap remove(XdmAtomicValue key)
public java.util.Set<XdmAtomicValue> keySet()
keySet in interface java.util.Map<XdmAtomicValue,XdmValue>public java.util.Map<XdmAtomicValue,XdmValue> asMap()
public void clear()
clear in interface java.util.Map<XdmAtomicValue,XdmValue>java.lang.UnsupportedOperationException - if the clear operation
is not supported by this mappublic boolean isEmpty()
isEmpty in interface java.util.Map<XdmAtomicValue,XdmValue>public boolean containsKey(java.lang.Object key)
containsKey in interface java.util.Map<XdmAtomicValue,XdmValue>key - key whose presence in this map is to be testedjava.lang.ClassCastException - if the key is of an inappropriate type for
this map
(optional)java.lang.NullPointerException - if the specified key is null and this map
does not permit null keys
(optional)public boolean containsValue(java.lang.Object value)
This implementation always throws UnsupportedOperationException.
containsValue in interface java.util.Map<XdmAtomicValue,XdmValue>value - value whose presence in this map is to be testedjava.lang.ClassCastException - if the value is of an inappropriate type for
this map
(optional)java.lang.NullPointerException - if the specified value is null and this
map does not permit null values
(optional)public XdmValue get(java.lang.Object key)
null if this map contains no mapping for the key.
get in interface java.util.Map<XdmAtomicValue,XdmValue>key - the key whose associated value is to be returned. If this is
not an XdmAtomicValue, the method attempts to construct an
XdmAtomicValue using the method XdmAtomicValue.makeAtomicValue(Object);
it is therefore possible to pass a simple key such as a string or integer.null if this map contains no mapping for the keyjava.lang.ClassCastException - if the key is of an inappropriate type for
this map (in this case, XdmAtomicValue)
(optional)java.lang.NullPointerException - if the specified key is null
(optional)public XdmValue remove(java.lang.Object key)
(key==null ? k==null : key.equals(k)), that mapping
is removed. (The map can contain at most one such mapping.)
Returns the value to which this map previously associated the key, or null if the map contained no mapping for the key.
If this map permits null values, then a return value of null does not necessarily indicate that the map contained no mapping for the key; it's also possible that the map explicitly mapped the key to null.
The map will not contain a mapping for the specified key once the call returns.
remove in interface java.util.Map<XdmAtomicValue,XdmValue>key - key whose mapping is to be removed from the mapjava.lang.UnsupportedOperationException - if the remove operation
is not supported by this mapjava.lang.ClassCastException - if the key is of an inappropriate type for
this map
(optional)java.lang.NullPointerException - if the specified key is null and this
map does not permit null keys
(optional)public void putAll(java.util.Map<? extends XdmAtomicValue,? extends XdmValue> m)
put(k, v) on this map once
for each mapping from key k to value v in the
specified map. The behavior of this operation is undefined if the
specified map is modified while the operation is in progress.putAll in interface java.util.Map<XdmAtomicValue,XdmValue>m - mappings to be stored in this mapjava.lang.UnsupportedOperationException - if the putAll operation
is not supported by this mapjava.lang.ClassCastException - if the class of a key or value in the
specified map prevents it from being stored in this mapjava.lang.NullPointerException - if the specified map is null, or if
this map does not permit null keys or values, and the
specified map contains null keys or valuesjava.lang.IllegalArgumentException - if some property of a key or value in
the specified map prevents it from being stored in this map@NotNull public java.util.Collection<XdmValue> values()
Collection view of the values contained in this map.
The collection is backed by the map, so changes to the map are
reflected in the collection, and vice-versa. If the map is
modified while an iteration over the collection is in progress
(except through the iterator's own remove operation),
the results of the iteration are undefined. The collection
supports element removal, which removes the corresponding
mapping from the map, via the Iterator.remove,
Collection.remove, removeAll,
retainAll and clear operations. It does not
support the add or addAll operations.values in interface java.util.Map<XdmAtomicValue,XdmValue>@NotNull public java.util.Set<java.util.Map.Entry<XdmAtomicValue,XdmValue>> entrySet()
Set view of the mappings contained in this map.entrySet in interface java.util.Map<XdmAtomicValue,XdmValue>public static XdmMap makeMap(java.util.Map input) throws java.lang.IllegalArgumentException
XdmAtomicValue.makeAtomicValue(Object)
method. The associated values must be convertible to XDM sequences
using the XdmValue.makeValue(Object) method.input - the supplied mapjava.lang.IllegalArgumentException - if any value in the input map cannot be converted
to a corresponding XDM value.Copyright (c) 2004-2017 Saxonica Limited. All rights reserved.