public class TypeConverter extends Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
asBoolean(Data data)
Helper method to safely convert an arbitrary data instance (including null) into a valid
boolean representation.
|
static boolean |
asBoolean(String value)
Parses and returns the given string as a boolean in a ClearSilver compatible way.
|
static int |
asNumber(Data data)
Helper method to safely convert an arbitrary data instance (including null) into a valid
integer representation.
|
static int |
asNumber(String value)
Parses and returns the given string as an integer in a ClearSilver compatible way.
|
static String |
asString(Data data)
Helper method to safely convert an arbitrary data instance (including null) into a valid
(non-null) string representation.
|
static boolean |
exists(Data data)
Determines if the given data node exists in a ClearSilver compatible way.
|
static int |
parseNumber(String value)
Parses a non-null string in a ClearSilver compatible way.
|
public static boolean exists(Data data)
public static String asString(Data data)
public static int parseNumber(String value) throws NumberFormatException
"123abc" parses to 123.
Additionally, ClearSilver doesn't do hex in HDF values, so "a.b=0x123" will just
resolve to 0.
In ClearSilver templates: Hex is supported, including negative values.
In JSilver: A string must be a complete, valid numeric value for parsing. This means "123abc" is invalid and will default to 0.
In JSilver: Positive hex values are supported for both HDF and templates but negative values
aren't. This means a template containing something like "" will parse
correctly but fail to render.NumberFormatException - is the string is badly formattedpublic static int asNumber(String value)
public static int asNumber(Data data)
public static boolean asBoolean(String value)
public static boolean asBoolean(Data data)
Copyright © 2010-2012 Google. All Rights Reserved.