Interface FragmentData
- 
public interface FragmentDataRepresents a piece of content (or data) provided by a content fragment.In general,
FragmentDataworks as a wrapper around a (generic) Java object that represents the actual value. This avoids usingObjectin 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
Objectwrapped byFragmentData- may need to be converted to the needs of the client. Basically,getValue(Class)supports to convert each value to aString(and back).For the conversion to a
Stringthe following rules are followed:- 
         The conversion of numbers is technical, i.e. based on
         
Xxxx.toString()/Xxx.parseXxxrather thanNumberFormat - 
         The conversion of 
Calendaris based on ISO-8601. 
- Since:
 - 1.1
 
 - 
         The conversion of numbers is technical, i.e. based on
         
 
- 
- 
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description @Nullable java.lang.StringgetContentType()Returns the content type for textbased data types.@NotNull DataTypegetDataType()Gets the data type of the value.@Nullable java.util.CalendargetLastModified()Returns the date the value was last modified.@Nullable java.lang.ObjectgetValue()Gets the original value as a generic Java object.<T> TgetValue(java.lang.Class<T> type)Gets the value, converted to the provided type.booleanisTypeSupported(java.lang.Class type)Checks if the specified Java data type is supported for calls togetValue(Class)andsetValue(Object).voidsetContentType(@Nullable java.lang.String contentType)Sets the content type for text-based data types.voidsetValue(@Nullable java.lang.Object value)Sets the value. 
 - 
 
- 
- 
Method Detail
- 
getDataType
@NotNull @NotNull DataType getDataType()
Gets the data type of the value.- Returns:
 - The data type
 
 
- 
getValue
@Nullable <T> T getValue(java.lang.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)returnstrue- Type Parameters:
 T- Describes the type parameter- Parameters:
 type- The type the value should be converted to- Returns:
 - The value; 
nullif the value could not be converted to the provided type 
 
- 
isTypeSupported
boolean isTypeSupported(java.lang.Class type)
Checks if the specified Java data type is supported for calls togetValue(Class)andsetValue(Object).- Parameters:
 type- The class object representing the type- Returns:
 trueif the type is supported
 
- 
getValue
@Nullable @Nullable java.lang.Object getValue()
Gets the original value as a generic Java object.- Returns:
 - The value
 
 
- 
setValue
void setValue(@Nullable @Nullable java.lang.Object value) throws ContentFragmentExceptionSets the value.The general rule is that a non-null value that was retrieved using
getValue(Class)needs to be accepted and converted to a suitable original value. Also, every value of a type whereisTypeSupported(Class)returnstrueneeds to be accepted and converted accordingly.Note that for the value to be persisted,
ContentElement.setValue(FragmentData)orContentVariation.setValue(FragmentData)have to be called explicitly. This allows for manipulating the value multiple times before actually persisting it.- Parameters:
 value- The value- Throws:
 ContentFragmentException- if the type of the value provided is unsupported
 
- 
getContentType
@Nullable @Nullable java.lang.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.- Returns:
 - The content type; 
nullif not applicable 
 
- 
setContentType
void setContentType(@Nullable @Nullable java.lang.String contentType)Sets the content type for text-based data types.For data other than text-based types
nullshould be provided.- Parameters:
 contentType- The content type;nullif not applicable
 
- 
getLastModified
@Nullable @Nullable java.util.Calendar getLastModified()
Returns the date the value was last modified.- Returns:
 - the last modified date or 
nullif not available 
 
 - 
 
 -