sleep.bridges

Class KeyValuePair

public class KeyValuePair extends Object

Arguments passed to functions with the form key => expression are available via the KeyValuePair object. The following is the implementation of the built-in function &hash(key => "value", key2 => 3, ...):

 class hash implements Function
 {
    public Scalar evaluate(String n, ScriptInstance si, Stack arguments)
    {
       Scalar value = SleepUtils.getHashScalar();

       while (!arguments.isEmpty())
       {
          KeyValuePair kvp = BridgeUtilities.getKeyValuePair(arguments);

          Scalar blah = value.getHash().getAt(kvp.getKey());
          blah.setValue(kvp.getValue());
       }

       return value;
    }
 }

See Also: BridgeUtilities

Field Summary
protected Scalarkey
the key scalar
protected Scalarvalue
the value scalar
Constructor Summary
KeyValuePair(Scalar _key, Scalar _value)
Instantiates a key/value pair
Method Summary
ScalargetKey()
Obtain the key portion of this pair
ScalargetValue()
Obtain the value portion of this pair
StringtoString()
Return a string representation of this key/value pair

Field Detail

key

protected Scalar key
the key scalar

value

protected Scalar value
the value scalar

Constructor Detail

KeyValuePair

public KeyValuePair(Scalar _key, Scalar _value)
Instantiates a key/value pair

Method Detail

getKey

public Scalar getKey()
Obtain the key portion of this pair

getValue

public Scalar getValue()
Obtain the value portion of this pair

toString

public String toString()
Return a string representation of this key/value pair