SMILA 1.0 API documentation

org.eclipse.smila.datamodel.util
Class AnyUtil

java.lang.Object
  extended by org.eclipse.smila.datamodel.util.AnyUtil

public final class AnyUtil
extends java.lang.Object

utility class for handling / conversion of Any objects. Hint: The Any-to-JSON conversion for Date(Time)s is not symmetric. If the Any object contains Date(Time) values, they will be serialized to String values in simple timestamp format. But when parsing JSON to an Any object, Date(Time) strings will not be recognized anymore, but just read as String values.


Field Summary
static AnyMap EMPTY_MAP
          Immutable empty AnyMap instance.
 
Method Summary
static java.lang.Object anyToNative(Any any)
          Converts an Any object into a native java object.
static java.lang.Boolean asBoolean(Any any)
          null save version.
static java.util.Date asDate(Any any)
          null save version.
static java.util.Date asDateTime(Any any)
          null save version.
static java.lang.Double asDouble(Any any)
          null save version.
static java.lang.Long asLong(Any any)
          null save version.
static AnyMap asMap(Any any)
          null save version.
static AnySeq asSeq(Any any)
          null save version.
static java.lang.String asString(Any any)
          null save version.
static AnyMap exceptionToAny(java.lang.Throwable e)
          convert an exception to an any object.
static Any objectToAny(java.lang.Object object)
          Converts an object to an Any (recursively).
static Any saveGet(Any any, java.lang.String[] path)
          get value for given path(list of keys) from AnyMap object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_MAP

public static final AnyMap EMPTY_MAP
Immutable empty AnyMap instance.

Method Detail

anyToNative

public static java.lang.Object anyToNative(Any any)
Converts an Any object into a native java object.

Parameters:
any - the Any object
Returns:
a Pojo

objectToAny

public static Any objectToAny(java.lang.Object object)
Converts an object to an Any (recursively). The leaf object(s) must be convertable by DataFactory.autoConvertValue(Object).

Parameters:
object - The object to be converted. Supported (and tested in this order) are
Returns:
The converted Any

saveGet

public static Any saveGet(Any any,
                          java.lang.String[] path)
get value for given path(list of keys) from AnyMap object. This methods throws no exception, if the path not exists an empty Any is the result.

Parameters:
any - the Any object.
path - path to the entry.
Returns:
value associated to the path.

exceptionToAny

public static AnyMap exceptionToAny(java.lang.Throwable e)
convert an exception to an any object.

Parameters:
e - exception to convert
Returns:
any representation of exception

asDouble

public static java.lang.Double asDouble(Any any)
null save version.


asBoolean

public static java.lang.Boolean asBoolean(Any any)
null save version.


asDateTime

public static java.util.Date asDateTime(Any any)
null save version.


asDate

public static java.util.Date asDate(Any any)
null save version.


asLong

public static java.lang.Long asLong(Any any)
null save version.


asString

public static java.lang.String asString(Any any)
null save version.


asMap

public static AnyMap asMap(Any any)
null save version.


asSeq

public static AnySeq asSeq(Any any)
null save version.


SMILA 1.0 API documentation