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
public interface ElementType<T> extends ModelItemType
Interface for element types
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description T
castValue(Object value)
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.Stream<Triple<DataChangeType,DataChangeTypeDetail,String>>
compareValues(Object value1, Object value2)
Compares the given values and retrieves the changes as a stream ofTriple
s.Object
fromJSONForClient(Object json)
Convert the given client side JSON object to the types valueClass<T>
getManagedClass()
Get the class managed by the implementationClass<T[]>
getManagedClassArray()
Get 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.T
parseConfiguration(Configuration configuration)
Parses the given configuration to get the typed valueString
toString(T value)
Cast a typed value to a StringObject
valueFromXML(Element parent, String name, Optional<Object> additionalData)
Parses the given DOM node to get the typed valueObject
valueToJSONForClient(Object value, DataContext context)
Convert the value into a JSON object to use client side-
Methods 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 Detail
-
castValue
T castValue(Object value) throws BadItemTypeException
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 String value can't be cast to the type
-
toString
String toString(T value)
Cast a typed value to a String- Parameters:
value
- the value to cast- Returns:
- the String representation of the value
-
fromJSONForClient
Object fromJSONForClient(Object json)
Convert the given client side JSON object to the types value- Parameters:
json
- the JSON object to convert- Returns:
- the typed value corresponding to the JSON object
-
valueToJSONForClient
Object valueToJSONForClient(Object value, DataContext context)
Convert the value into a JSON object to use client side- Parameters:
value
- the value to convertcontext
- The context of the data to convert- Returns:
- The value as JSON
-
parseConfiguration
T parseConfiguration(Configuration configuration) throws ConfigurationException
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
Object valueFromXML(Element parent, String name, Optional<Object> additionalData) throws TransformerException, IOException
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
- Throws:
TransformerException
- if an error occurs while parsing the DOM nodeIOException
- if an error occurs while parsing a value using the I/O API
-
compareValues
Stream<Triple<DataChangeType,DataChangeTypeDetail,String>> compareValues(Object value1, Object value2) throws IOException
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 - Throws:
IOException
- if an error occurs while comparing values using the I/O API
- the general type of the change (added, modified or removed) as a
-
isCompatible
boolean isCompatible(Object value)
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
Class<T> 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)
-
-