Class Value


  extended by Object
      extended by Value

public class Value
extends Object

Value is a general composite type. It is used when storing data into storage or communicating with the server side.

It can contain following types:

There are a number of cast operators that convert between Value and other types.

  Value <-> boolean
  Value <-> int
  Value <-> long
  Value <-> String
  Value <-  List
  Value <-> ByteArray

Value list is the native array format (operator_array()):

 
  Value list = [];  
  list.add("foo");
  list.add("bar");

Value supports inline appending when being constructed (operator_append(Value)):

 
  Value list = ["foo", "bar"];  
  Value list2 = ["foo", ["bar", "baz"]];  

IS_BINDING can be created with arrow expression (operator_bind(Value, Value)):

 
  Value tel = "tel"=>"555-HELIUM";
  Value person = ["age"=>25,
                  "name=>"john"];  
  person.add(tel);

See Also:
operator_array(), operator_bind(Value, Value), operator_append(Value), call(Object, String, String, Value), Script.onSuccess(Object, Value), Script.onFailure(Object, String), SuccessCallback, FailureCallback, Store

Method Summary
 Value add(Value value)
          Adds a new element to this Value.
 boolean contains(String key)
          Checks if any of the child elements with type IS_BINDING has a matching key.
 boolean contains(Value key)
          Checks if any of the child elements matches given Value.
 Value copy()
          Returns duplicate of this Value.
 boolean isNull()
          Checks if this Value is IS_NULL.
 void operator_append(Value element)
          Array append support, see class description.
 Value operator_get(int index)
          Returns an element at specified index.
 Value operator_get(String key)
          Returns right side of IS_BINDING that has a key that matches given argument.
 Value operator_get(Value key)
          Returns right side of IS_BINDING that has a key matching given argument.
 Value operator_set(int index, Value value)
          Sets element at specified index.
 Value operator_set(String key, Value value)
          Sets right side of IS_BINDING that has a key matching given argument.
 Value operator_set(Value key, Value value)
          Sets right side of IS_BINDING that has a key matching given argument.
 Value remove(int index)
          Removes an element at specified index from this Value.
 Value remove(Value value)
          Removes an element from this Value.
 int size()
          Returns the size of elements in this Value.
 int type()
          Returns the type of Value.
 
Methods inherited from class Object
toString, equals, hashCode
 
Methods inherited from
equals, getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

type

public int type()
Returns the type of Value.

Returns:
type of Value
See Also:
IS_NULL, IS_BOOLEAN, IS_INT, IS_STRING, IS_LIST, IS_BINDING, IS_BINARY

size

public int size()
Returns the size of elements in this Value.

Returns:
size of this Value.

copy

public Value copy()
Returns duplicate of this Value.

Returns:
New instance of this value

add

public Value add(Value value)
Adds a new element to this Value. Only meaningful when type is IS_LIST.

Parameters:
value - Element to add
Returns:
this Value

remove

public Value remove(Value value)
Removes an element from this Value. Only meaningful when type is IS_LIST.

Parameters:
value - Element to remove
Returns:
this Value

remove

public Value remove(int index)
Removes an element at specified index from this Value. Only meaningful when type is IS_LIST.

Parameters:
index - Index of element, must be on range [0..size()-1]
Returns:
this Value

operator_get

public Value operator_get(int index)
Returns an element at specified index. Only meaningful when type is IS_LIST or IS_BINDING.

Parameters:
index - Index of element, must be on range [0..size()-1]
Returns:
Value at specified index

operator_get

public Value operator_get(Value key)
Returns right side of IS_BINDING that has a key matching given argument. Only meaningful when type is IS_LIST.

Parameters:
key - Key to look for
Returns:
Found value or IS_NULL if it wasn't found.

operator_get

public Value operator_get(String key)
Returns right side of IS_BINDING that has a key that matches given argument. Only meaningful when type is IS_LIST.

Parameters:
key - Key to look for
Returns:
Found value or IS_NULL if it wasn't found.

operator_set

public Value operator_set(int index,
                          Value value)
Sets element at specified index. Only meaningful when type is IS_LIST.

Parameters:
index - Index of element, must be on range [0..size()-1]
value - Element to set

operator_set

public Value operator_set(Value key,
                          Value value)
Sets right side of IS_BINDING that has a key matching given argument. If there wasn't any such binding, adds a new binding. Only meaningful when type is IS_LIST.

Parameters:
key - Key to look for
value - Element to set

operator_set

public Value operator_set(String key,
                          Value value)
Sets right side of IS_BINDING that has a key matching given argument. If there wasn't any such binding, adds a new binding. Only meaningful when type is IS_LIST.

Parameters:
key - Key to look for
value - Element to set

contains

public boolean contains(String key)
Checks if any of the child elements with type IS_BINDING has a matching key. Only meaningful when type is IS_LIST.

Returns:
true if matching binding was found, false otherwise

contains

public boolean contains(Value key)
Checks if any of the child elements matches given Value. Only meaningful when type is IS_LIST.

Parameters:
key - Key to search for
Returns:
true if element was found, false otherwise

operator_append

public void operator_append(Value element)
Array append support, see class description.


isNull

public boolean isNull()
Checks if this Value is IS_NULL.

Returns:
true if IS_NULL, false otherwise.