org.jopendocument.dom
Enum ODValueType

java.lang.Object
  extended by java.lang.Enum<ODValueType>
      extended by org.jopendocument.dom.ODValueType
All Implemented Interfaces:
Serializable, Comparable<ODValueType>

@Immutable
public enum ODValueType
extends Enum<ODValueType>

A type of value, as per 16.1 "Data Types" and 6.7.1 "Variable Value Types and Values"


Enum Constant Summary
BOOLEAN
           
CURRENCY
           
DATE
           
FLOAT
          Parses to BigDecimal to return the exact number.
PERCENTAGE
           
STRING
           
TIME
           
 
Method Summary
 boolean canFormat(Class<?> toFormat)
           
abstract  String format(Object o)
           
static ODValueType forObject(Object o)
          Try to guess the value type for the passed object.
static ODValueType get(String name)
          The instance for the passed value type.
static Calendar getCalendar()
          Get the framework default calendar.
static Locale getLocale(boolean notNull)
          The framework default locale.
 String getName()
          The value for the value-type attribute.
static TimeZone getTimeZone(boolean notNull)
          The framework default time zone.
 String getValueAttribute()
          The name of the value attribute for this value type.
static boolean isTimeZoneIgnored()
          Whether to ignore explicit time zone in dates.
abstract  Object parse(String s)
           
static Calendar parseDateValue(String date)
          Parse an OpenDocument date value with the framework defaults.
static Calendar parseDateValue(String date, TimeZone tz, Locale locale, Boolean ignoreTZ)
          Parse an OpenDocument date value with the passed parameters.
static void setLocale(Locale locale)
          Set the framework default locale.
static void setTimeZone(TimeZone tz)
          Set the framework default time zone.
static void setTimeZoneIgnored(boolean b)
           
static ODValueType valueOf(String name)
          Returns the enum constant of this type with the specified name.
static ODValueType[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

FLOAT

public static final ODValueType FLOAT
Parses to BigDecimal to return the exact number.


PERCENTAGE

public static final ODValueType PERCENTAGE

CURRENCY

public static final ODValueType CURRENCY

DATE

public static final ODValueType DATE

TIME

public static final ODValueType TIME

BOOLEAN

public static final ODValueType BOOLEAN

STRING

public static final ODValueType STRING
Method Detail

values

public static ODValueType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (ODValueType c : ODValueType.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static ODValueType valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

getValueAttribute

public final String getValueAttribute()
The name of the value attribute for this value type.

Returns:
the value attribute, e.g. "boolean-value".

canFormat

public boolean canFormat(Class<?> toFormat)

format

public abstract String format(Object o)

parse

public abstract Object parse(String s)

getName

public final String getName()
The value for the value-type attribute.

Returns:
the value for the value-type attribute, e.g. "float".

get

public static ODValueType get(String name)
The instance for the passed value type.

Parameters:
name - the value of the value-type attribute, e.g. "date".
Returns:
the corresponding instance, never null, e.g. DATE.
Throws:
IllegalArgumentException - if name isn't a valid type.

forObject

public static ODValueType forObject(Object o)
                             throws NullPointerException
Try to guess the value type for the passed object.

Parameters:
o - the object.
Returns:
a value type capable of formatting o or null.
Throws:
NullPointerException - if o is null.

setTimeZone

public static final void setTimeZone(TimeZone tz)
Set the framework default time zone. Pass null to always use the VM default (passing TimeZone.getDefault() would set the value once and for all and wouldn't be changed by TimeZone.setDefault(TimeZone)).

Parameters:
tz - the new default time zone, null to use the VM default.

getTimeZone

public static final TimeZone getTimeZone(boolean notNull)
The framework default time zone.

Parameters:
notNull - true if null should be replaced by TimeZone.getDefault().
Returns:
the default time zone, can only be null if notNull is false.

setLocale

public static final void setLocale(Locale locale)
Set the framework default locale. Pass null to always use the VM default (passing Locale.getDefault() would set the value once and for all and wouldn't be changed by Locale.setDefault(Locale)).

Parameters:
locale - the new default locale, null to use the VM default.

getLocale

public static final Locale getLocale(boolean notNull)
The framework default locale.

Parameters:
notNull - true if null should be replaced by Locale.getDefault().
Returns:
the default locale, can only be null if notNull is false.

getCalendar

public static final Calendar getCalendar()
Get the framework default calendar.

Returns:
the default calendar.
See Also:
getTimeZone(boolean), getLocale(boolean)

setTimeZoneIgnored

public static final void setTimeZoneIgnored(boolean b)

isTimeZoneIgnored

public static final boolean isTimeZoneIgnored()
Whether to ignore explicit time zone in dates. Prior to 4.1 LibreOffice would ignore explicit time zones, i.e. "2013-11-15T12:00:00.000" and "2013-11-15T12:00:00.000+01:00" would both parse to noon. As of 4.1 the first one parse to noon, the second one to 11 AM.

Returns:
true if the time zone part should be ignored.

parseDateValue

public static Calendar parseDateValue(String date)
                               throws ParseException
Parse an OpenDocument date value with the framework defaults.

Parameters:
date - the string formatted value.
Returns:
a calendar with the local time of the passed date.
Throws:
ParseException - if the value couldn't be parsed.
See Also:
parseDateValue(String, TimeZone, Locale, Boolean)

parseDateValue

public static Calendar parseDateValue(String date,
                                      TimeZone tz,
                                      Locale locale,
                                      Boolean ignoreTZ)
                               throws ParseException
Parse an OpenDocument date value with the passed parameters.

Parameters:
date - the string formatted value.
tz - the time zone of the returned calendar, null meaning getTimeZone(boolean).
locale - the locale of the returned calendar, null meaning getLocale(boolean).
ignoreTZ - whether to ignore the time zone part of part, null meaning isTimeZoneIgnored().
Returns:
a calendar with the local time of the passed date.
Throws:
ParseException - if the value couldn't be parsed.


Copyright © 2010 jOpenDocument All Rights Reserved.