org.apache.olingo.odata2.api.edm
Interface EdmSimpleType

All Superinterfaces:
EdmNamed, EdmType

public interface EdmSimpleType
extends EdmType

EdmSimpleType is a primitive type as defined in the Entity Data Model (EDM).

There are methods to convert EDM simple types from and to Java objects, respectively. The following Java types are supported:

EDM simple typeJava types
Binarybyte[], Byte[]
BooleanBoolean
ByteShort, Byte, Integer, Long
DateTimeCalendar, Date, Long
DateTimeOffsetCalendar, Date, Long
DecimalBigDecimal, BigInteger, Double, Float, Byte, Short, Integer, Long
DoubleDouble, Float, BigDecimal, Byte, Short, Integer, Long
GuidUUID
Int16Short, Byte, Integer, Long
Int32Integer, Byte, Short, Long
Int64Long, Byte, Short, Integer, BigInteger
SByteByte, Short, Integer, Long
SingleFloat, Double, BigDecimal, Byte, Short, Integer, Long
StringString
TimeCalendar, Date, Long

The first Java type is the default type for the respective EDM simple type.

For all EDM simple types, the facet Nullable is taken into account. For Binary, MaxLength is also applicable. For String, the facets MaxLength and Unicode are also considered. The EDM simple types DateTime, DateTimeOffset, and Time can have a Precision facet. Decimal can have the facets Precision and Scale.

EDM simple typeParsing details
DateTimeOffset When an time string is parsed to an according EdmDateTimeOffset object it is assumed that this time string represents the local time with a timezone set.
As an example, when the following time string "2012-02-29T15:33:00-04:00" is parsed it is assumed that we have the local time ("15:33:00") which is in a timezone with an offset from UTC of "-04:00". Hence the result is a calendar object within the local time (which is "15:33:00") and the according timezone offset ("-04:00") which then results in the UTC time of "19:33:00+00:00" ("15:33:00" - "-04:00" -> "19:33:00 UTC").
As further explanation about our date time handling I reference to the following ISO specification: ISO 8601 - http://en.wikipedia.org/wiki/ISO_8601 and the copied section: Time_offsets_from_UTC - http://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC
> The following times all refer to the same moment: "18:30Z", "22:30+04:00", and "15:00-03:30". Nautical time zone letters are not used with the exception of Z. To calculate UTC time one has to subtract the offset from the local time, e.g. for "15:00-03:30" do 15:00 - (-03:30) to get 18:30 UTC.
The behavior of our ABAP OData Library and Microsoft examples is the same as described above.

Do not implement this interface or derive from class.

Field Summary
static String EDM_NAMESPACE
           
static String SYSTEM_NAMESPACE
           
 
Method Summary
 Class<?> getDefaultType()
          Returns the default Java type for this EDM simple type as described in the documentation of EdmSimpleType.
 boolean isCompatible(EdmSimpleType simpleType)
          Checks type compatibility.
 String toUriLiteral(String literal)
          Converts default literal representation to URI literal representation.
 boolean validate(String value, EdmLiteralKind literalKind, EdmFacets facets)
          Validates literal value.
<T> T
valueOfString(String value, EdmLiteralKind literalKind, EdmFacets facets, Class<T> returnType)
          Converts literal representation of value to system data type.
 String valueToString(Object value, EdmLiteralKind literalKind, EdmFacets facets)
          Converts system data type to literal representation of value.
 
Methods inherited from interface org.apache.olingo.odata2.api.edm.EdmType
getKind, getNamespace
 
Methods inherited from interface org.apache.olingo.odata2.api.edm.EdmNamed
getName
 

Field Detail

EDM_NAMESPACE

static final String EDM_NAMESPACE
See Also:
Constant Field Values

SYSTEM_NAMESPACE

static final String SYSTEM_NAMESPACE
See Also:
Constant Field Values
Method Detail

isCompatible

boolean isCompatible(EdmSimpleType simpleType)
Checks type compatibility.

Parameters:
simpleType - the EdmSimpleType to be tested for compatibility
Returns:
true if the provided type is compatible to this type

getDefaultType

Class<?> getDefaultType()
Returns the default Java type for this EDM simple type as described in the documentation of EdmSimpleType.

Returns:
the default Java type

validate

boolean validate(String value,
                 EdmLiteralKind literalKind,
                 EdmFacets facets)
Validates literal value.

Parameters:
value - the literal value
literalKind - the kind of literal representation of value
facets - additional constraints for parsing (optional)
Returns:
true if the validation is successful
See Also:
EdmLiteralKind, EdmFacets

valueOfString

<T> T valueOfString(String value,
                    EdmLiteralKind literalKind,
                    EdmFacets facets,
                    Class<T> returnType)
                throws EdmSimpleTypeException
Converts literal representation of value to system data type.

Parameters:
value - the literal representation of value
literalKind - the kind of literal representation of value
facets - additional constraints for parsing (optional)
returnType - the class of the returned value; it must be one of the list in the documentation of EdmSimpleType
Returns:
the value as an instance of the class the parameter returnType indicates
Throws:
EdmSimpleTypeException
See Also:
EdmLiteralKind, EdmFacets

valueToString

String valueToString(Object value,
                     EdmLiteralKind literalKind,
                     EdmFacets facets)
                     throws EdmSimpleTypeException

Converts system data type to literal representation of value.

Returns null if value is null and the facets allow the null value.

Parameters:
value - the Java value as Object; its type must be one of the list in the documentation of EdmSimpleType
literalKind - the requested kind of literal representation
facets - additional constraints for formatting (optional)
Returns:
literal representation as String
Throws:
EdmSimpleTypeException
See Also:
EdmLiteralKind, EdmFacets

toUriLiteral

String toUriLiteral(String literal)
                    throws EdmSimpleTypeException
Converts default literal representation to URI literal representation.

Parameters:
literal - the literal in default representation
Returns:
URI literal representation as String
Throws:
EdmSimpleTypeException


Copyright © 2013-2015 The Apache Software Foundation. All Rights Reserved.