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 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.

  Do not implement this interface or derive from class.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `EDM_NAMESPACE`
    `static String` | `SYSTEM_NAMESPACE`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    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.

    - ### 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-2023 The Apache Software Foundation. All Rights Reserved.