Package net.sf.saxon.ma.map

## Class RangeKey

- java.lang.Object
- - net.sf.saxon.ma.map.RangeKey

- All Implemented Interfaces:
    `Callable`, `MapItem`, `Function`, `GroundedValue`, `Item`, `Sequence`

      public class RangeKey
      extends java.lang.Object
      implements MapItem

  This class implements an XPath map item as a view of an XSLT key index. It is possible to specify a minimum and maximum key value to be included in the map, and keys are returned in sorted order.

  At present range keys are only available for string-valued keys using the Unicode codepoint collating sequence.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `RangeKey​(java.lang.String min, java.lang.String max, java.util.TreeMap<AtomicMatchKey,​java.lang.Object> index)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `MapItem` | `addEntry​(AtomicValue key, GroundedValue value)` | Create a new map containing the existing entries in the map plus an additional entry, without modifying the original.
    `boolean` | `conforms​(AtomicType keyType, SequenceType valueType, TypeHierarchy th)` | Ask whether the map conforms to a given map type
    `boolean` | `deepEquals​(Function 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
    `void` | `export​(ExpressionPresenter out)` | Output information about this function item to the diagnostic explain() output
    `GroundedValue` | `get​(AtomicValue key)` | Get an entry from the Map
    `java.lang.String` | `getDescription()` | Get a description of this function for use in error messages.
    `MapType` | `getFunctionItemType()` | Get the item type of the function item
    `MapType` | `getItemType​(TypeHierarchy th)` | Get the type of the map.
    `UType` | `getKeyUType()` | Get the lowest common item type of the keys in the map
    `boolean` | `isEmpty()` | Ask whether the map is empty
    `boolean` | `isTrustedResultType()` | Check that result type is of the trusted system functions to return a result of the correct type
    `AtomicIterator` | `keys()` | Get the set of all key values in the map.
    `java.lang.Iterable<KeyValuePair>` | `keyValuePairs()` | Get the set of all key-value pairs in the map
    `MapItem` | `remove​(AtomicValue key)` | Remove an entry from the map
    `int` | `size()` | Get the size of the map
    `java.lang.String` | `toString()` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface net.sf.saxon.om.GroundedValue

      `asIterable, concatenate, containsNode, materialize`

    - ### Methods inherited from interface net.sf.saxon.om.Item

      `getLength, head, isStreamed, iterate, reduce, subsequence`

    - ### Methods inherited from interface net.sf.saxon.ma.map.MapItem

      `atomize, call, effectiveBooleanValue, getAnnotations, getArity, getFunctionName, getGenre, getOperandRoles, getStringValue, getStringValueCS, getTypedValue, isArray, isMap, itemAt, makeNewContext, toShortString`

    - ### Methods inherited from interface net.sf.saxon.om.Sequence

      `makeRepeatable`

- - ### Constructor Detail

    - #### RangeKey

          public RangeKey​(java.lang.String min,
                          java.lang.String max,
                          java.util.TreeMap<AtomicMatchKey,​java.lang.Object> index)

  - ### Method Detail

    - #### get

          public GroundedValue get​(AtomicValue key)

      Get an entry from the Map
      Specified by:
        `get` in interface `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 interface `MapItem`
      Returns:
        the number of keys/entries present in this map

    - #### isEmpty

          public boolean isEmpty()

      Ask whether the map is empty
      Specified by:
        `isEmpty` in interface `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.
      Specified by:
        `keys` in interface `MapItem`
      Returns:
        a set containing all the key values present in the map.

    - #### keyValuePairs

          public java.lang.Iterable<KeyValuePair> keyValuePairs()

      Get the set of all key-value pairs in the map
      Specified by:
        `keyValuePairs` in interface `MapItem`
      Returns:
        an iterator over the key-value pairs

    - #### remove

          public MapItem remove​(AtomicValue key)

      Remove an entry from the map
      Specified by:
        `remove` in interface `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

    - #### getKeyUType

          public UType getKeyUType()

      Get the lowest common item type of the keys in the map
      Specified by:
        `getKeyUType` in interface `MapItem`
      Returns:
        the most specific type to which all the keys belong. If the map is empty, return ErrorType.getInstance() (the type with no instances)

    - #### addEntry

          public MapItem addEntry​(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:
        `addEntry` in interface `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

    - #### conforms

          public boolean conforms​(AtomicType keyType,
                                  SequenceType valueType,
                                  TypeHierarchy th)

      Ask whether the map conforms to a given map type
      Specified by:
        `conforms` in interface `MapItem`
      Parameters:
        `keyType` - the required keyType
        `valueType` - the required valueType
        `th` - the type hierarchy cache for the configuration
      Returns:
        true if the map conforms to the required type

    - #### getItemType

          public MapType 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.
      Specified by:
        `getItemType` in interface `MapItem`
      Parameters:
        `th` - the type hierarchy (not used)
      Returns:
        the type of this map

    - #### getFunctionItemType

          public MapType getFunctionItemType()

      Get the item type of the function item
      Specified by:
        `getFunctionItemType` in interface `Function`
      Specified by:
        `getFunctionItemType` in interface `MapItem`
      Returns:
        the function item's type

    - #### getDescription

          public java.lang.String getDescription()

      Get a description of this function for use in error messages. For named functions, the description is the function name (as a lexical QName). For others, it might be, for example, "inline function", or "partially-applied ends-with function".
      Specified by:
        `getDescription` in interface `Function`
      Specified by:
        `getDescription` in interface `MapItem`
      Returns:
        a description of the function for use in error messages

    - #### deepEquals

          public boolean deepEquals​(Function 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
      Specified by:
        `deepEquals` in interface `Function`
      Specified by:
        `deepEquals` in interface `MapItem`
      Parameters:
        `other` - the other function item
        `context` - the dynamic evaluation context
        `comparer` - the object to perform the comparison
        `flags` - options for how the comparison is performed
      Returns:
        true if the two function items are deep-equal

    - #### export

          public void export​(ExpressionPresenter out)
                      throws XPathException

      Output information about this function item to the diagnostic explain() output
      Specified by:
        `export` in interface `Function`
      Specified by:
        `export` in interface `MapItem`
      Throws:
        `XPathException`

    - #### isTrustedResultType

          public boolean isTrustedResultType()

      Description copied from interface: `Function`
      Check that result type is of the trusted system functions to return a result of the correct type
      Specified by:
        `isTrustedResultType` in interface `Function`
      Specified by:
        `isTrustedResultType` in interface `MapItem`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`