Package org.ametys.runtime.model.type
Interface ElementType<T>
- Type Parameters:
T
- Type of the element value
- All Superinterfaces:
ModelItemType
,PluginAware
- All Known Subinterfaces:
ComplexRepositoryElementType<T>
,RepositoryElementType<T>
,XMLElementType<T>
,XSLElementType<T>
- All Known Implementing Classes:
AbstractBinaryElementType
,AbstractBooleanElementType
,AbstractContentElementType
,AbstractDateElementType
,AbstractDateTimeElementType
,AbstractDoubleElementType
,AbstractElementType
,AbstractFileElementType
,AbstractGeocodeElementType
,AbstractLongElementType
,AbstractMultilingualStringElementType
,AbstractReferenceElementType
,AbstractRichTextElementType
,AbstractStringElementType
,AbstractUserElementType
,BinaryRepositoryElementType
,BooleanRepositoryElementType
,BooleanXMLElementType
,BooleanXSLElementType
,ContentContentElementType
,ContentRepositoryElementType
,DateRepositoryElementType
,DateTimeRepositoryElementType
,DateTimeXMLElementType
,DateXMLElementType
,DoubleRepositoryElementType
,DoubleXMLElementType
,DoubleXSLElementType
,FileContentElementType
,FileRepositoryElementType
,GeocodeRepositoryElementType
,HTMLRichTextContentElementType
,HTMLRichTextRepositoryElementType
,LongRepositoryElementType
,LongXMLElementType
,LongXSLElementType
,MultilingualStringRepositoryElementType
,PasswordRepositoryElementType
,PasswordXMLElementType
,ReferenceContentElementType
,ReferenceRepositoryElementType
,RichTextContentElementType
,RichTextRepositoryElementType
,StringRepositoryElementType
,StringXMLElementType
,StringXSLElementType
,UserRepositoryElementType
Interface for element types
-
Method Summary
Modifier and TypeMethodDescriptionCast the given value to an object of the corresponding type.
It may be an untyped String value, or another Object, depending of what the type is actually compatible with.compareValues
(Object value1, Object value2) Compares the given values and retrieves the changes as a stream ofTriple
s.fromJSONForClient
(Object json, DataContext context) Convert the given client side JSON object to the types valueGet the class managed by the implementationGet the class representing an array of managed class by the implementationboolean
isCompatible
(Object value) Checks if the value is compatible with the element typeboolean
isSimple()
Determines if this type is simple or not.parseConfiguration
(Configuration configuration) Parses the given configuration to get the typed valueCast a typed value to a StringvalueFromXML
(Element parent, String name, Optional<Object> additionalData) Parses the given DOM node to get the typed valuevalueToJSONForClient
(Object value, DataContext context) Convert the value into a JSON object to use client sidevalueToJSONForEdition
(Object value, DataContext context) Convert the value into a JSON object to use in edition modeMethods inherited from interface org.ametys.runtime.model.type.ModelItemType
getId, valueToSAX, valueToSAX, valueToSAXForEdition
Methods inherited from interface org.ametys.runtime.plugin.component.PluginAware
setPluginInfo
-
Method Details
-
castValue
Cast the given value to an object of the corresponding type.
It may be an untyped String value, or another Object, depending of what the type is actually compatible with.- Parameters:
value
- the value to cast- Returns:
- An object of the parameterized type representing the given value. Returns null if value cannot be cast
- Throws:
BadItemTypeException
- if the given value can't be cast to the type
-
toString
Cast a typed value to a String- Parameters:
value
- the value to cast- Returns:
- the String representation of the value
-
fromJSONForClient
Convert the given client side JSON object to the types value- Parameters:
json
- the JSON object to convertcontext
- the context of the data to retrieve- Returns:
- the typed value corresponding to the JSON object
-
valueToJSONForClient
Convert the value into a JSON object to use client side- Parameters:
value
- the value to convertcontext
- The context of the data to convert. Can not be null.- Returns:
- The value as JSON
-
valueToJSONForEdition
Convert the value into a JSON object to use in edition mode- Parameters:
value
- the value to convertcontext
- The context of the data to convert. Can not be null.- Returns:
- The value as JSON
-
parseConfiguration
Parses the given configuration to get the typed value- Parameters:
configuration
- the configuration to parse- Returns:
- The typed value in the configuration
- Throws:
ConfigurationException
- if an error occurs while parsing the configuration
-
valueFromXML
Parses the given DOM node to get the typed value- Parameters:
parent
- the DOM element containing the valuename
- the name of the item to readadditionalData
- additional data needed to get the typed value- Returns:
- the value
-
compareValues
Stream<Triple<DataChangeType,DataChangeTypeDetail, compareValuesString>> (Object value1, Object value2) Compares the given values and retrieves the changes as a stream ofTriple
s. ATriple
contains:- the general type of the change (added, modified or removed) as a
DataChangeType
, - some details about this change if possible (after or before for a date, more or less for a number, ...) as a
DataChangeTypeDetail
- The data concerned by this change if not the element itself (or an empty String)
- Parameters:
value1
- the 1st valuevalue2
- the 2nd value- Returns:
- the changes between the two given values as a stream of
Triple
. Retrieves an empty stream if there is no change
- the general type of the change (added, modified or removed) as a
-
isCompatible
Checks if the value is compatible with the element type- Parameters:
value
- the value to check- Returns:
true
if the value matches the current type,false
otherwise
-
isSimple
boolean isSimple()Determines if this type is simple or not. A simple element type is a type of elements that can be edited in a grid- Returns:
true
if the type is simple,false
otherwise
-
getManagedClass
Get the class managed by the implementation- Returns:
- The class managed (T.class)
-
getManagedClassArray
Class<T[]> getManagedClassArray()Get the class representing an array of managed class by the implementation- Returns:
- The class managed (T[].class)
-