Class XQMap

All Implemented Interfaces:
Iterable<Item>, XQFunction, XQFunctionExpr

public final class XQMap extends XQData
The map item.
Author:
BaseX Team 2005-21, BSD License, Leo Woerteler
  • Field Details

    • EMPTY

      public static final XQMap EMPTY
      The empty map.
  • Method Details

    • paramName

      public QNm paramName(int pos)
      Description copied from interface: XQFunctionExpr
      Name of the parameter at the given position.
      Parameters:
      pos - position of the parameter
      Returns:
      name of the parameter
    • refineType

      public void refineType(Expr expr)
      Description copied from class: Expr
      Refines the expression type.
      Overrides:
      refineType in class FItem
      Parameters:
      expr - original expression
    • cache

      public void cache(boolean lazy, InputInfo ii) throws QueryException
      Description copied from class: Item
      Caches lazy values. Overwritten by Lazy, XQMap and XQArray.
      Overrides:
      cache in class Item
      Parameters:
      lazy - lazy caching
      ii - input info
      Throws:
      QueryException - query exception
    • delete

      public XQMap delete(Item key, InputInfo ii) throws QueryException
      Deletes a key from this map.
      Parameters:
      key - key to delete (must not be null)
      ii - input info
      Returns:
      updated map if changed, this otherwise
      Throws:
      QueryException - query exception
    • get

      public Value get(Item key, InputInfo ii) throws QueryException
      Description copied from class: XQData
      Gets a value from this item.
      Specified by:
      get in class XQData
      Parameters:
      key - key to look for (must not be null)
      ii - input info
      Returns:
      bound value if found, the empty sequence () otherwise
      Throws:
      QueryException - query exception
    • contains

      public boolean contains(Item key, InputInfo ii) throws QueryException
      Checks if the given key exists in the map.
      Parameters:
      key - key to look for (must not be null)
      ii - input info
      Returns:
      true() if the key exists, false() otherwise
      Throws:
      QueryException - query exception
    • addAll

      public XQMap addAll(XQMap map, MergeDuplicates merge, QueryContext qc, InputInfo ii) throws QueryException
      Adds all bindings from the given map into this.
      Parameters:
      map - map to add
      merge - merge duplicate keys
      qc - query context
      ii - input info
      Returns:
      updated map if changed, this otherwise
      Throws:
      QueryException - query exception
    • atomValue

      public Value atomValue(QueryContext qc, InputInfo ii) throws QueryException
      Description copied from class: Item
      Evaluates the expression and returns the atomized items. Overwritten by XQArray, FuncItem and ANode.
      Overrides:
      atomValue in class Item
      Parameters:
      qc - query context
      ii - input info (only required by Seq instances, which have no input info)
      Returns:
      atomized item
      Throws:
      QueryException - query exception
    • atomItem

      public Item atomItem(QueryContext qc, InputInfo ii) throws QueryException
      Description copied from class: Item
      Evaluates the expression and returns the resulting, atomized item, or Empty.VALUE if the expression yields an empty sequence. Overwritten by XQArray, FuncItem and ANode.
      Overrides:
      atomItem in class Item
      Parameters:
      qc - query context
      ii - input info (only required by Seq instances, which have no input info)
      Returns:
      item or Empty.VALUE
      Throws:
      QueryException - query exception
    • materialize

      public Item materialize(QueryContext qc, boolean copy)
      Description copied from class: Item
      Returns a materialized, context-independent version of this item.
      Overrides:
      materialize in class Item
      Parameters:
      qc - query context (if null, process cannot be interrupted)
      copy - create full copy
      Returns:
      item copy, or null) if the item cannot be materialized
    • instanceOf

      public boolean instanceOf(Type tp)
      Description copied from class: Item
      Checks if this item is instance of the specified type. Overwritten by XQMap and XQArray.
      Overrides:
      instanceOf in class Item
      Parameters:
      tp - type
      Returns:
      result of check
    • put

      public XQMap put(Item key, Value value, InputInfo ii) throws QueryException
      Puts the given value into this map and replaces existing keys.
      Parameters:
      key - key to insert (must not be null)
      value - value to insert
      ii - input info
      Returns:
      updated map if changed, this otherwise
      Throws:
      QueryException - query exception
    • mapSize

      public int mapSize()
      Number of values contained in this map.
      Returns:
      size
    • keys

      public Value keys()
      All keys defined in this map.
      Returns:
      list of keys
    • values

      public void values(ValueBuilder vb)
      Adds all values defined in this map to the specified value builder.
      Parameters:
      vb - value builder
    • forEach

      public Value forEach(FItem func, QueryContext qc, InputInfo ii) throws QueryException
      Applies a function on all entries.
      Parameters:
      func - function to apply on keys and values
      qc - query context
      ii - input info
      Returns:
      resulting value
      Throws:
      QueryException - query exception
    • deep

      public boolean deep(Item item, Collation coll, InputInfo ii) throws QueryException
      Description copied from class: FItem
      Performs a deep comparison of two items.
      Specified by:
      deep in class FItem
      Parameters:
      item - item to be compared
      coll - collation (can be null)
      ii - input info
      Returns:
      result of check
      Throws:
      QueryException - query exception
    • toJava

      public HashMap<Object,Object> toJava() throws QueryException
      Description copied from class: Value
      Returns a Java representation of the value.
      Specified by:
      toJava in class Value
      Returns:
      Java object
      Throws:
      QueryException - query exception
    • hash

      public int hash(InputInfo ii) throws QueryException
      Description copied from class: Value
      Returns a hash code for this value.
      Overrides:
      hash in class Item
      Parameters:
      ii - input info
      Returns:
      hash code
      Throws:
      QueryException - if atomization can't be applied (e.g. function item)
    • string

      public void string(boolean indent, TokenBuilder tb, int level, InputInfo ii) throws QueryException
      Description copied from class: XQData
      Returns a string representation of the item.
      Specified by:
      string in class XQData
      Parameters:
      indent - indent output
      tb - token builder
      level - current level
      ii - input info
      Throws:
      QueryException - query exception
    • description

      public String description()
      Description copied from class: ExprInfo
      Returns a string description of the expression. This method is only called by error messages. Contrary to the ExprInfo.toString() method, arguments are not included in the output.
      Overrides:
      description in class Item
      Returns:
      result of check
    • plan

      public void plan(QueryPlan plan)
      Description copied from class: ExprInfo
      Creates a query plan.
      Overrides:
      plan in class Item
      Parameters:
      plan - expression plan
    • plan

      public void plan(QueryString qs)
      Description copied from class: ExprInfo
      Creates a query string.
      Specified by:
      plan in class ExprInfo
      Parameters:
      qs - query string builder