Interface FragmentData

  • public interface FragmentData
    Represents a piece of content (or data) provided by a content fragment.

    In general, FragmentData works as a wrapper around a (generic) Java object that represents the actual value. This avoids using Object in the API and also allows to provide helper functionality to access the generic value in a controlled way.

    Values are typed. For more information about data types, see DataType.

    Values of a given type - represented by an Object wrapped by FragmentData - may need to be converted to the needs of the client. Basically, getValue(Class) supports to convert each value to a String (and back).

    For the conversion to a String the following rules are followed:

    • The conversion of numbers is technical, i.e. based on Xxxx.toString()/Xxx.parseXxx rather than NumberFormat
    • The conversion of Calendar is based on ISO-8601.
    • Method Detail

      • getDataType

        @NotNull DataType getDataType()
        Gets the data type of the value.
        The data type
      • getValue

        <T> T getValue​(Class<T> type)
        Gets the value, converted to the provided type.

        For information about supported type conversions: see DataType.

        Note that this method is supposed to return a suitably converted value for all types where isTypeSupported(Class) returns true

        Type Parameters:
        T - Describes the type parameter
        type - The type the value should be converted to
        The value; null if the value could not be converted to the provided type
      • isTypeSupported

        boolean isTypeSupported​(Class type)
        Checks if the specified Java data type is supported for calls to getValue(Class) and setValue(Object).
        type - The class object representing the type
        true if the type is supported
      • getValue

        @Nullable Object getValue()
        Gets the original value as a generic Java object.
        The value
      • getContentType

        @Nullable String getContentType()
        Returns the content type for textbased data types.

        This will return a MIME type only when applicable. For numbers, dates, booleans, it will typically be null.

        The content type; null if not applicable
      • setContentType

        void setContentType​(@Nullable
                            @Nullable String contentType)
        Sets the content type for text-based data types.

        For data other than text-based types null should be provided.

        contentType - The content type; null if not applicable
      • getLastModified

        @Nullable Calendar getLastModified()
        Returns the date the value was last modified.
        the last modified date or null if not available