PyXdmMap¶
- class PyXdmMap¶
Bases:
PyXdmFunctionItemThe class PyXdmMap represents a map item in the XDM data model. A map is a list of zero or more entries, each of which is a pair comprising a key (which is an atomic value) and a value (which is an arbitrary value). The map itself is an XDM item. A PyXdmMap is immutable.
- __iter__()¶
Returns the Iterator object of PyXdmMap
- contains_key(key)¶
Returns true if this map contains a mapping for the specified key.
- Parameters:
key (PyXdmAtomicValue) – key whose presence in this map is to be tested
- Returns:
true if this map contains a mapping for the specified key
- Return type:
- get(key, encoding=None)¶
Returns the value to which the specified key is mapped, or
Noneif this map contains no mapping for the key.All keys in the PyXdmMap are of type
PyXdmAtomicValue, but for convenience, this method also accepts keys of primitive type (str, int and float), which will be converted to PyXdmAtomicValue internally.- Parameters:
key (PyXdmAtomicValue, str, int, float) – the key whose associated value is to be returned.
encoding (str) – The encoding of the key, if supplied as a string. If not specified then the platform default encoding is used.
- Returns:
the value to which the specified key is mapped, or
Noneif this map contains no mapping for the key- Return type:
- isEmpty¶
Returns true if this map contains no key-value mappings.
- Returns:
true if this map contains no key-value mappings
- Return type:
- keys()¶
Get the keys in the PyXdmMap
- Returns:
List of PyXdmAtomicValue objects
- Return type:
- map_size¶
Get the number of entries in the map
- Returns:
the number of entries in the map. (Note that the size() method returns 1 (one), because an XDM map is an item.)
- Return type:
- put(key, value)¶
Create a new map containing an additional (key, value) pair. If there is an existing entry with the same key, it is replaced.
- Parameters:
key (PyXdmAtomicValue) – The key for the new map entry
value (PyXdmValue) – The value for the new map entry
- Returns:
a new map containing the new entry. The original map is unchanged.
- Return type:
- remove(key)¶
Create a new map in which the entry for a given key has been removed.
- Parameters:
key (PyXdmAtomicValue) – The key to be removed given as an PyXdmAtomicValue
- Returns:
a map without the specified entry. The original map is unchanged.
- Return type:
- string_value¶
Property to get the string value of the PyXdmMap
- Returns:
String value of the map item
- Return type: