edu.iu.cnets.klatsch.lang
Class VDictionary

java.lang.Object
  extended by edu.iu.cnets.klatsch.lang.Value
      extended by edu.iu.cnets.klatsch.lang.VDictionary

public class VDictionary
extends Value

This value represents a dictionary (i.e., associative array).


Field Summary
(package private)  java.util.Map<VString,Value> map
          our actual storage mechanism
 
Constructor Summary
VDictionary()
          Constructs a new, empty dictionary.
 
Method Summary
 Value method_delete(Value... args)
          delete(s) : Removes any association for s.
 Value method_get(Value... args)
          get(s) : Returns the value associated with s.
 Value method_has(Value... args)
          has(s) : Returns true if the dictionary has an association for s.
 Value method_keys(Value... args)
          keys() : Returns a stream of keys for the dictionary.
 Value method_set(Value... args)
          set(s, v) : Associates s with the value v, replacing any existing association.
 Value method_values(Value... args)
          values() : Returns a stream of values for the dictionary.
 void set(VString key, Value val)
          Updates the given association.
 java.lang.String toJson()
          Creates a JSON representation of the dictionary.
 java.lang.String toString()
          Creates a (largely opaque) printed representation of the dictionary.
 
Methods inherited from class edu.iu.cnets.klatsch.lang.Value
require, requireCount, requireType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

map

java.util.Map<VString,Value> map
our actual storage mechanism

Constructor Detail

VDictionary

public VDictionary()
Constructs a new, empty dictionary.

Method Detail

set

public void set(VString key,
                Value val)
Updates the given association.

Parameters:
key - the key to update
val - the new value for that key

toString

public java.lang.String toString()
Creates a (largely opaque) printed representation of the dictionary.

Specified by:
toString in class Value
Returns:
the printed representation

toJson

public java.lang.String toJson()
Creates a JSON representation of the dictionary.

Overrides:
toJson in class Value
Returns:
the JSON representation

method_delete

public Value method_delete(Value... args)
                    throws EvaluationException
delete(s) : Removes any association for s. (It's okay if there wasn't one to begin with.) Returns the dictionary to support method chaining.

Throws:
EvaluationException

method_has

public Value method_has(Value... args)
                 throws EvaluationException
has(s) : Returns true if the dictionary has an association for s.

Throws:
EvaluationException

method_get

public Value method_get(Value... args)
                 throws EvaluationException
get(s) : Returns the value associated with s.

Throws:
EvaluationException

method_keys

public Value method_keys(Value... args)
                  throws EvaluationException
keys() : Returns a stream of keys for the dictionary.

Throws:
EvaluationException

method_set

public Value method_set(Value... args)
                 throws EvaluationException
set(s, v) : Associates s with the value v, replacing any existing association. Returns v to support chaining.

Throws:
EvaluationException

method_values

public Value method_values(Value... args)
                    throws EvaluationException
values() : Returns a stream of values for the dictionary.

Throws:
EvaluationException