|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.visualization.datasource.datatable.ValueFormatter
public class ValueFormatter
Formats a Value, or parses a string to create a Value.
An instance of this class can be created using the
createFromPattern(ValueType, String, ULocale) method, and can then use the format
and/or parse.
The class also supplies a set of default patterns per ValueType. The default patterns
can be used for parsing/formatting values when there is no specified pattern.
Otherwise, create a class instance by specifying a pattern and locale.
Note: This class is not thread safe since it uses UFormat.
| Method Summary | |
|---|---|
static ValueFormatter |
createDefault(ValueType type,
com.ibm.icu.util.ULocale locale)
Creates a default formatter for the specified value type and locale. |
static java.util.Map<ValueType,ValueFormatter> |
createDefaultFormatters(com.ibm.icu.util.ULocale locale)
Creates default formatters for all the value types for the specified locale. |
static ValueFormatter |
createFromPattern(ValueType type,
java.lang.String pattern,
com.ibm.icu.util.ULocale locale)
Creates a formatter for the given value type with the given pattern string and locale. |
java.lang.String |
format(Value value)
Formats a value to a string, using the given pattern. |
com.ibm.icu.util.ULocale |
getLocale()
Returns the ulocale. |
java.lang.String |
getPattern()
Returns the pattern for this formatter. |
ValueType |
getType()
Returns the type. |
com.ibm.icu.text.UFormat |
getUFormat()
Returns the internal UFormat object. |
Value |
parse(java.lang.String val)
Creates the corresponding Value from the given string. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static ValueFormatter createFromPattern(ValueType type,
java.lang.String pattern,
com.ibm.icu.util.ULocale locale)
LocaleUtil#getDefaultLocale.
type - The column value type.pattern - The string pattern representing the formatter pattern.locale - The ULocale of the formatter.
public static ValueFormatter createDefault(ValueType type,
com.ibm.icu.util.ULocale locale)
LocaleUtil#getDefaultLocale.
type - The value type.locale - The data table locale.
public static java.util.Map<ValueType,ValueFormatter> createDefaultFormatters(com.ibm.icu.util.ULocale locale)
locale - The data table locale.
public java.lang.String format(Value value)
value - The value to format.
public Value parse(java.lang.String val)
Value from the given string.
If parsing fails, returns a NULL_VALUE for the specified type.
For example, if val="3" and type=ValueType.Number, then after successfully parsing
the string "3" into the double 3.0 a new NumberValue would
be returned with an internal double value = 3.
val - The string to parse.
Value for the given string. If parsing fails the value would
be a NULL_VALUE of the correct ValueType.public com.ibm.icu.text.UFormat getUFormat()
UFormat object.
UFormat object.public java.lang.String getPattern()
public com.ibm.icu.util.ULocale getLocale()
public ValueType getType()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||