com.google.template.soy.data
Class SoyMapData

java.lang.Object
  extended by com.google.template.soy.data.SoyData
      extended by com.google.template.soy.data.restricted.CollectionData
          extended by com.google.template.soy.data.SoyMapData

public class SoyMapData
extends com.google.template.soy.data.restricted.CollectionData

A map data node in a Soy data tree.


Constructor Summary
SoyMapData()
           
SoyMapData(Map<String,?> data)
          Constructor that initializes this SoyMapData from an existing map.
SoyMapData(Object... data)
          Constructor that directly takes the keys/values as parameters.
 
Method Summary
 Map<String,SoyData> asMap()
          Important: Please treat this method as superpackage-private.
 boolean equals(Object other)
          Compares this data object against another for equality in the sense of the operator '==' for Soy expressions.
 Set<String> getKeys()
          Gets the keys in this map data.
 SoyData getSingle(String key)
          Important: Do not use outside of Soy code (treat as superpackage-private).
 void putSingle(String key, SoyData value)
          Important: Do not use outside of Soy code (treat as superpackage-private).
 void removeSingle(String key)
          Important: Do not use outside of Soy code (treat as superpackage-private).
 boolean toBoolean()
          Converts this data object into a boolean (e.g.
 String toString()
          Converts this data object into a string (e.g.
protected  String toStringHelper(Map<String,SoyData> map)
          Protected helper for {toString()}.
 
Methods inherited from class com.google.template.soy.data.restricted.CollectionData
ensureValidValue, get, getBoolean, getFloat, getInteger, getListData, getMapData, getString, put, put, put, put, put, put, remove
 
Methods inherited from class com.google.template.soy.data.SoyData
booleanValue, createFromExistingData, createFromExistingData, floatValue, integerValue, numberValue, stringValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SoyMapData

public SoyMapData()

SoyMapData

public SoyMapData(Map<String,?> data)
Constructor that initializes this SoyMapData from an existing map.

Parameters:
data - The initial data in an existing map.

SoyMapData

public SoyMapData(Object... data)
Constructor that directly takes the keys/values as parameters.

Parameters:
data - The initial data, with alternating keys/values.
Method Detail

asMap

public Map<String,SoyData> asMap()
Important: Please treat this method as superpackage-private. Do not call this method from outside the 'tofu' and 'data' packages. Returns a view of this SoyMapData object as a Map.


getKeys

public Set<String> getKeys()
Gets the keys in this map data.

Returns:
A set containing the keys in this map data.

toString

public String toString()
Converts this data object into a string (e.g. when used in a string context).

This method should only be used for debugging purposes.

Specified by:
toString in class SoyData
Returns:
The value of this data object if coerced into a string.

toStringHelper

protected String toStringHelper(Map<String,SoyData> map)
Protected helper for {toString()}. Turns a regular Map into a string.

Parameters:
map - The map to turn into a string.
Returns:
The built string.

toBoolean

public boolean toBoolean()
Converts this data object into a boolean (e.g. when used in a boolean context). In other words, this method tells whether this object is truthy.

A map is always truthy.

Specified by:
toBoolean in class SoyData
Returns:
The value of this data object if coerced into a boolean. I.e. true if this object is truthy, false if this object is falsy.

equals

public boolean equals(Object other)
Description copied from class: SoyData
Compares this data object against another for equality in the sense of the operator '==' for Soy expressions.

Specified by:
equals in class SoyData
Parameters:
other - The other data object to compare against.
Returns:
True if the two objects are equal.

putSingle

public void putSingle(String key,
                      SoyData value)
Important: Do not use outside of Soy code (treat as superpackage-private). Puts data into this data object at the specified key.

Specified by:
putSingle in class com.google.template.soy.data.restricted.CollectionData
Parameters:
key - An individual key.
value - The data to put at the specified key.

removeSingle

public void removeSingle(String key)
Important: Do not use outside of Soy code (treat as superpackage-private). Removes the data at the specified key.

Specified by:
removeSingle in class com.google.template.soy.data.restricted.CollectionData
Parameters:
key - An individual key.

getSingle

public SoyData getSingle(String key)
Important: Do not use outside of Soy code (treat as superpackage-private). Gets the data at the specified key.

Specified by:
getSingle in class com.google.template.soy.data.restricted.CollectionData
Parameters:
key - An individual key.
Returns:
The data at the specified key, or null if the key is not defined.