Interface EdmSimpleType

All Superinterfaces:
EdmNamed, EdmType
All Known Implementing Classes:
AbstractSimpleType, Bit, EdmBinary, EdmBoolean, EdmByte, EdmDateTime, EdmDateTimeOffset, EdmDecimal, EdmDouble, EdmGuid, EdmInt16, EdmInt32, EdmInt64, EdmNull, EdmSByte, EdmSingle, EdmString, EdmTime, Uint7

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, Timestamp, Long
DateTimeOffsetCalendar, Date, Timestamp, 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, 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.

  • Field Details

  • Method Details

    • 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:
    • 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:
    • 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:
    • 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