Class EmptyMap

All Implemented Interfaces:
Callable, FunctionItem, GroundedValue, Item, Sequence

public class EmptyMap extends MapItem
A map with no entries.

There are two empty maps, a 3.1 version and a 4.0 version. This is because maps constructed by adding entries inherit the version of the original. The difference is that in a 3.1 map, hexBinary and base64Binary values are always distinct, whereas in a 4.0 map, they may be duplicates.

  • Field Details

    • INSTANCE_31

      public static final EmptyMap INSTANCE_31
    • INSTANCE_40

      public static final EmptyMap INSTANCE_40
  • Method Details

    • getInstance

      public static EmptyMap getInstance(int version)
    • get

      public GroundedValue get(AtomicValue key)
      Get an entry from the Map
      Specified by:
      get in class MapItem
      Parameters:
      key - the value of the key
      Returns:
      the value associated with the given key, or null if the key is not present in the map.
    • size

      public int size()
      Get the size of the map
      Specified by:
      size in class MapItem
      Returns:
      the number of keys/entries present in this map
    • isEmpty

      public boolean isEmpty()
      Ask whether the map is empty
      Overrides:
      isEmpty in class MapItem
      Returns:
      true if and only if the size of the map is zero
    • keys

      public AtomicIterator keys()
      Get the set of all key values in the map.
      Overrides:
      keys in class MapItem
      Returns:
      a set containing all the key values present in the map, in unpredictable order
    • keyValuePairs

      public Iterable<KeyValuePair> keyValuePairs()
      Get the set of all key-value pairs in the map
      Specified by:
      keyValuePairs in class MapItem
      Returns:
      an iterable containing all the key-value pairs
    • put

      public MapItem put(AtomicValue key, GroundedValue value)
      Create a new map containing the existing entries in the map plus an additional entry, without modifying the original. If there is already an entry with the specified key, this entry is replaced by the new entry.
      Specified by:
      put in class MapItem
      Parameters:
      key - the key of the new entry
      value - the value associated with the new entry
      Returns:
      the new map containing the additional entry
    • remove

      public MapItem remove(AtomicValue key)
      Remove an entry from the map
      Specified by:
      remove in class MapItem
      Parameters:
      key - the key of the entry to be removed
      Returns:
      a new map in which the requested entry has been removed; or this map unchanged if the specified key was not present
    • conforms

      public boolean conforms(PlainType keyType, SequenceType valueType)
      Ask whether the map conforms to a given map type
      Overrides:
      conforms in class MapItem
      Parameters:
      keyType - the required keyType
      valueType - the required valueType
      Returns:
      true if the map conforms to the required type
    • getItemType

      public ItemType getItemType(TypeHierarchy th)
      Get the type of the map. This method is used largely for diagnostics, to report the type of a map when it differs from the required type.
      Overrides:
      getItemType in class MapItem
      Parameters:
      th - the type hierarchy cache
      Returns:
      the type of this map
    • toString

      public String toString()
      Overrides:
      toString in class Object