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 type | Java types |
---|---|
Binary | byte[], Byte [] |
Boolean | Boolean |
Byte | Short , Byte , Integer , Long |
DateTime | Calendar , Date , Timestamp ,
Long |
DateTimeOffset | Calendar , Date , Timestamp ,
Long |
Decimal | BigDecimal , BigInteger , Double , Float ,
Byte , Short , Integer , Long |
Double | Double , Float , BigDecimal , Byte , Short ,
Integer , Long |
Guid | UUID |
Int16 | Short , Byte , Integer , Long |
Int32 | Integer , Byte , Short , Long |
Int64 | Long , Byte , Short , Integer , BigInteger
|
SByte | Byte , Short , Integer , Long |
Single | Float , Double , BigDecimal , Byte , Short ,
Integer , Long |
String | String |
Time | Calendar , Date , Timestamp ,
Time , 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
.
Parsing details for the EDM simple type DateTimeOffset
When an time string is parsed to an according value object it is assumed that the time part in this string represents the local time with a timezone set.
As an example, when the following 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 with 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").
Please see ISO specification ISO 8601 for further details. Time offsets are also explained in Wikipedia:
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.
Modifier and Type | Field and Description |
---|---|
static String |
EDM_NAMESPACE |
static String |
SYSTEM_NAMESPACE |
Modifier and Type | Method and Description |
---|---|
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.
|
getKind, getNamespace
static final String EDM_NAMESPACE
static final String SYSTEM_NAMESPACE
boolean isCompatible(EdmSimpleType simpleType)
simpleType
- the EdmSimpleType
to be tested for compatibilitytrue
if the provided type is compatible to this typeClass<?> getDefaultType()
EdmSimpleType
.boolean validate(String value, EdmLiteralKind literalKind, EdmFacets facets)
value
- the literal valueliteralKind
- the kind of literal representation of valuefacets
- additional constraints for parsing (optional)true
if the validation is successfulEdmLiteralKind
,
EdmFacets
<T> T valueOfString(String value, EdmLiteralKind literalKind, EdmFacets facets, Class<T> returnType) throws EdmSimpleTypeException
value
- the literal representation of valueliteralKind
- the kind of literal representation of valuefacets
- additional constraints for parsing (optional)returnType
- the class of the returned value; it must be one of the
list in the documentation of EdmSimpleType
returnType
indicatesEdmSimpleTypeException
EdmLiteralKind
,
EdmFacets
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.
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 representationfacets
- additional constraints for formatting (optional)EdmSimpleTypeException
EdmLiteralKind
,
EdmFacets
String toUriLiteral(String literal) throws EdmSimpleTypeException
literal
- the literal in default representationEdmSimpleTypeException
Copyright © 2013-2017 The Apache Software Foundation. All Rights Reserved.