|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.google.template.soy.data.SoyData
public abstract class SoyData
Abstract base class for all nodes in a Soy data tree.
| Constructor Summary | |
|---|---|
SoyData()
|
|
| Method Summary | |
|---|---|
boolean |
booleanValue()
Precondition: Only call this method if you know that this SoyData object is a boolean. |
static SoyData |
createFromExistingData(Object obj)
Creation function for creating a SoyData object out of any existing primitive, data object, or data structure. |
static SoyData |
createFromExistingData(String str)
A special case of createFromExistingData(Object). |
abstract boolean |
equals(Object other)
Compares this data object against another for equality in the sense of the operator '==' for Soy expressions. |
double |
floatValue()
Precondition: Only call this method if you know that this SoyData object is a float. |
int |
integerValue()
Precondition: Only call this method if you know that this SoyData object is an integer. |
double |
numberValue()
Precondition: Only call this method if you know that this SoyData object is a number. |
String |
stringValue()
Precondition: Only call this method if you know that this SoyData object is a string. |
abstract boolean |
toBoolean()
Converts this data object into a boolean (e.g. |
abstract String |
toString()
Converts this data object into a string (e.g. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public SoyData()
| Method Detail |
|---|
public static SoyData createFromExistingData(Object obj)
Important: Avoid using this function if you know the type of the object at compile time.
For example, if the object is a primitive, it can be passed directly to methods such as
SoyMapData.put() or SoyListData.add(). If the object is a Map or an Iterable,
you can directly create the equivalent SoyData object using the constructor of
SoyMapData or SoyListData.
If the given object is already a SoyData object, then it is simply returned. Otherwise a new SoyData object will be created that is equivalent to the given primitive, data object, or data structure (even if the given object is null!).
Note that in order for the conversion process to succeed, the given data structure must correspond to a valid SoyData tree. Some requirements include: (a) all Maps within your data structure must have string keys that are identifiers, (b) all non-leaf nodes must be Maps or Lists, (c) all leaf nodes must be null, boolean, int, double, or String (corresponding to Soy primitive data types null, boolean, integer, float, string).
obj - The existing object or data structure to convert.
SoyDataException - If the given object cannot be converted to SoyData.public static SoyData createFromExistingData(String str)
createFromExistingData(Object).
public abstract String toString()
toString in class Objectpublic abstract boolean toBoolean()
public abstract boolean equals(Object other)
equals in class Objectother - The other data object to compare against.
public boolean booleanValue()
SoyDataException - If this object is not actually a boolean.public int integerValue()
SoyDataException - If this object is not actually an integer.public double floatValue()
SoyDataException - If this object is not actually a float.public double numberValue()
SoyDataException - If this object is not actually a number.public String stringValue()
SoyDataException - If this object is not actually a string.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||