org.basex.query.value.map
Class Map

java.lang.Object
  extended by org.basex.data.ExprInfo
      extended by org.basex.query.expr.Expr
          extended by org.basex.query.value.Value
              extended by org.basex.query.value.item.Item
                  extended by org.basex.query.value.item.FItem
                      extended by org.basex.query.value.map.Map
All Implemented Interfaces:
java.lang.Iterable<Item>, XQFunction

public final class Map
extends FItem

The map item.

Author:
BaseX Team 2005-12, BSD License, Leo Woerteler

Nested Class Summary
 
Nested classes/interfaces inherited from class org.basex.query.expr.Expr
Expr.Flag
 
Field Summary
static Map EMPTY
          The empty map.
 
Fields inherited from class org.basex.query.value.item.Item
score, UNDEF
 
Fields inherited from class org.basex.query.value.Value
type
 
Method Summary
 Map addAll(Map other, InputInfo ii)
          Adds all bindings from the given map into this.
 int arity()
          Number of arguments this function takes.
 Map coerceTo(FuncType ft, QueryContext ctx, InputInfo ii)
          Coerces this function item to the given function type.
 Str collation()
          Collation of this map.
 Bln contains(Item k, InputInfo ii)
          Checks if the given key exists in the map.
 boolean deep(InputInfo ii, Map o)
          Checks if the this map is deep-equal to the given one.
 Map delete(Item key, InputInfo ii)
          Deletes a key from this map.
 java.lang.String description()
          Returns a string description of the expression.
 QNm fName()
          Name of this function, null means anonymous function.
 FuncType funcType()
          Type of this function.
 Value get(Item key, InputInfo ii)
          Gets the value from this map.
 int hash(InputInfo ii)
          Returns a hash code for this value.
 boolean hasType(MapType t)
          Checks if the map has the given type.
 Map insert(Item k, Value v, InputInfo ii)
          Inserts the given value into this map.
 Value invValue(QueryContext ctx, InputInfo ii, Value... args)
          Invokes this function with the given arguments.
 Value keys()
          All keys defined in this map.
 Int mapSize()
          Number of values contained in this map.
 void plan(FElem plan)
          Creates an expression tree.
 java.util.HashMap<java.lang.Object,java.lang.Object> toJava()
          Returns a Java representation of the value.
 TokenMap tokenMap(InputInfo ii)
          Converts the map to a map with keys and values represented as tokens.
 java.lang.String toString()
           
 
Methods inherited from class org.basex.query.value.item.FItem
eq, invItem, string
 
Methods inherited from class org.basex.query.value.item.Item
bool, castErr, comparable, dbl, dec, diff, ebv, equiv, flt, homogeneous, input, isItem, item, itemAt, iter, iterable, itr, materialize, score, score, size, test, type, typeId, writeTo, xdmInfo
 
Methods inherited from class org.basex.query.value.Value
accept, cache, checkUp, compile, copy, count, data, exprSize, has, inline, isValue, iter, iterator, removable, serialize, value
 
Methods inherited from class org.basex.query.expr.Expr
addText, compEbv, copy, hasFreeVars, indexAccessible, indexEquivalent, inlineAll, isEmpty, isFunction, isVacuous, markTailCalls, optimize, sameAs, uses, visitAll
 
Methods inherited from class org.basex.data.ExprInfo
addPlan, addPlan, info, planAttr, planElem
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY

public static final Map EMPTY
The empty map.

Method Detail

arity

public int arity()
Description copied from interface: XQFunction
Number of arguments this function takes.

Returns:
function arity

fName

public QNm fName()
Description copied from interface: XQFunction
Name of this function, null means anonymous function.

Returns:
name or null

funcType

public FuncType funcType()
Description copied from interface: XQFunction
Type of this function.

Returns:
this function's type

invValue

public Value invValue(QueryContext ctx,
                      InputInfo ii,
                      Value... args)
               throws QueryException
Description copied from interface: XQFunction
Invokes this function with the given arguments.

Parameters:
ctx - query context
ii - input info
args - arguments
Returns:
resulting iterator
Throws:
QueryException - query exception

delete

public Map delete(Item key,
                  InputInfo ii)
           throws QueryException
Deletes a key from this map.

Parameters:
key - key to delete
ii - input info
Returns:
updated map if changed, this otherwise
Throws:
QueryException - query exception

get

public Value get(Item key,
                 InputInfo ii)
          throws QueryException
Gets the value from this map.

Parameters:
key - key to look for
ii - input info
Returns:
bound value if found, the empty sequence () otherwise
Throws:
QueryException - query exception

contains

public Bln contains(Item k,
                    InputInfo ii)
             throws QueryException
Checks if the given key exists in the map.

Parameters:
k - key to look for
ii - input info
Returns:
true(), if the key exists, false() otherwise
Throws:
QueryException - query exception

addAll

public Map addAll(Map other,
                  InputInfo ii)
           throws QueryException
Adds all bindings from the given map into this.

Parameters:
other - map to add
ii - input info
Returns:
updated map if changed, this otherwise
Throws:
QueryException - query exception

hasType

public boolean hasType(MapType t)
Checks if the map has the given type.

Parameters:
t - type
Returns:
true if the type fits, false otherwise

coerceTo

public Map coerceTo(FuncType ft,
                    QueryContext ctx,
                    InputInfo ii)
             throws QueryException
Description copied from class: FItem
Coerces this function item to the given function type.

Specified by:
coerceTo in class FItem
Parameters:
ft - function type
ctx - query context
ii - input info
Returns:
coerced item
Throws:
QueryException - query exception

insert

public Map insert(Item k,
                  Value v,
                  InputInfo ii)
           throws QueryException
Inserts the given value into this map.

Parameters:
k - key to insert
v - 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

collation

public Str collation()
Collation of this map.

Returns:
collation

deep

public boolean deep(InputInfo ii,
                    Map o)
             throws QueryException
Checks if the this map is deep-equal to the given one.

Parameters:
ii - input info
o - other map
Returns:
result of check
Throws:
QueryException - query exception

tokenMap

public TokenMap tokenMap(InputInfo ii)
                  throws QueryException
Converts the map to a map with keys and values represented as tokens.

Parameters:
ii - input info
Returns:
token map
Throws:
QueryException - query exception

toJava

public java.util.HashMap<java.lang.Object,java.lang.Object> toJava()
                                                            throws QueryException
Description copied from class: Value
Returns a Java representation of the value.

Overrides:
toJava in class FItem
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)

description

public java.lang.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(FElem plan)
Description copied from class: ExprInfo
Creates an expression tree.

Specified by:
plan in class FItem
Parameters:
plan - root element

toString

public java.lang.String toString()
Specified by:
toString in class ExprInfo