Interface EdmSimpleType
-
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 BooleanByte Short,Byte,Integer,LongDateTime Calendar,Date,Timestamp,LongDateTimeOffset Calendar,Date,Timestamp,LongDecimal BigDecimal,BigInteger,Double,Float,Byte,Short,Integer,LongDouble Double,Float,BigDecimal,Byte,Short,Integer,LongGuid UUIDInt16 Short,Byte,Integer,LongInt32 Integer,Byte,Short,LongInt64 Long,Byte,Short,Integer,BigIntegerSByte Byte,Short,Integer,LongSingle Float,Double,BigDecimal,Byte,Short,Integer,LongString StringTime Calendar,Date,Timestamp,Time,LongThe first Java type is the default type for the respective EDM simple type.
For all EDM simple types, the
facetNullableis taken into account. ForBinary,MaxLengthis also applicable. ForString, the facetsMaxLengthandUnicodeare also considered. The EDM simple typesDateTime,DateTimeOffset, andTimecan have aPrecisionfacet.Decimalcan have the facetsPrecisionandScale.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.
@org.apache.olingo.odata2.DoNotImplement
-
-
Field Summary
Fields Modifier and Type Field Description static StringEDM_NAMESPACEstatic StringSYSTEM_NAMESPACE
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Class<?>getDefaultType()Returns the default Java type for this EDM simple type as described in the documentation ofEdmSimpleType.booleanisCompatible(EdmSimpleType simpleType)Checks type compatibility.StringtoUriLiteral(String literal)Converts default literal representation to URI literal representation.booleanvalidate(String value, EdmLiteralKind literalKind, EdmFacets facets)Validates literal value.<T> TvalueOfString(String value, EdmLiteralKind literalKind, EdmFacets facets, Class<T> returnType)Converts literal representation of value to system data type.StringvalueToString(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
-
-
-
-
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- theEdmSimpleTypeto be tested for compatibility- Returns:
trueif 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 ofEdmSimpleType.- Returns:
- the default Java type
-
validate
boolean validate(String value, EdmLiteralKind literalKind, EdmFacets facets)
Validates literal value.- Parameters:
value- the literal valueliteralKind- the kind of literal representation of valuefacets- additional constraints for parsing (optional)- Returns:
trueif 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.- Type Parameters:
T- Return Type- Parameters:
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 ofEdmSimpleType- Returns:
- the value as an instance of the class the parameter
returnTypeindicates - Throws:
EdmSimpleTypeException- Caso ocorra uma exceção EDM- 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
nullif value isnulland the facets allow thenullvalue.- Parameters:
value- the Java value as Object; its type must be one of the list in the documentation ofEdmSimpleTypeliteralKind- the requested kind of literal representationfacets- additional constraints for formatting (optional)- Returns:
- literal representation as String
- Throws:
EdmSimpleTypeException- Caso ocorra uma exceção EDM- 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- Caso ocorra uma exceção EDM
-
-