public abstract class AbstractContentElementType extends AbstractElementType<ContentValue> implements Component, Serviceable
Modifier and Type | Field and Description |
---|---|
protected ContentTypesHelper |
_contentTypesHelper
Helper for content types
|
protected AmetysObjectResolver |
_resolver
Ametys object resolver
|
Constructor and Description |
---|
AbstractContentElementType() |
Modifier and Type | Method and Description |
---|---|
private Map<String,Object> |
_content2Json(Content content,
Locale locale) |
private Map<String,Object> |
_content2Json(String contentId,
Locale locale) |
protected boolean |
_hasAmetysObjectsForIdentifiers(String... identifiers)
Check if ametys objects exist with the given identifiers
|
private void |
_singleContentToSAX(ContentHandler contentHandler,
String tagName,
Content content,
Locale locale) |
ContentValue |
castValue(String value)
Cast an untyped value (string) to an object of the corresponding type
|
Object |
fromJSONForClient(Object json)
Convert the given client side JSON object to the types value
|
boolean |
isCompatible(Object value)
Checks if the value is compatible with the element type
|
boolean |
isSimple()
Determines if this type is simple or not.
|
ContentValue |
parseConfiguration(Configuration configuration)
Parses the given configuration to get the typed value
|
void |
service(ServiceManager manager) |
String |
toString(ContentValue value)
Cast a typed value to a String
|
Object |
valueToJSONForClient(Object value)
Convert the value into a JSON object to use client side
|
void |
valueToSAX(ContentHandler contentHandler,
String tagName,
Object value,
Locale locale)
Generates SAX events for the given value
|
_singleValueToJSON, _singleValueToSAX, getManagedClass, getManagedClassArray
getId, setPluginInfo
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getId
setPluginInfo
protected AmetysObjectResolver _resolver
protected ContentTypesHelper _contentTypesHelper
public AbstractContentElementType()
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public ContentValue castValue(String value) throws BadItemTypeException
ElementType
castValue
in interface ElementType<ContentValue>
value
- the value to castBadItemTypeException
- if the String value can't be cast to the typepublic String toString(ContentValue value)
ElementType
toString
in interface ElementType<ContentValue>
toString
in class AbstractElementType<ContentValue>
value
- the value to castpublic void valueToSAX(ContentHandler contentHandler, String tagName, Object value, Locale locale) throws SAXException
ModelItemType
valueToSAX
in interface ModelItemType
valueToSAX
in class AbstractElementType<ContentValue>
contentHandler
- the ContentHandler
that will receive the SAX eventstagName
- the tag name of the SAX event to generate.value
- the value to SAXlocale
- The locale to use for localized data. Can be null
to generate SAX events for all existing Locale
s.SAXException
- if an error occurs during the SAX events generationprivate void _singleContentToSAX(ContentHandler contentHandler, String tagName, Content content, Locale locale) throws SAXException
SAXException
public ContentValue parseConfiguration(Configuration configuration) throws ConfigurationException
ElementType
parseConfiguration
in interface ElementType<ContentValue>
parseConfiguration
in class AbstractElementType<ContentValue>
configuration
- the configuration to parseConfigurationException
- if an error occurs while parsing the configurationpublic Object valueToJSONForClient(Object value)
ElementType
valueToJSONForClient
in interface ElementType<ContentValue>
valueToJSONForClient
in class AbstractElementType<ContentValue>
value
- the value to convertpublic Object fromJSONForClient(Object json)
ElementType
fromJSONForClient
in interface ElementType<ContentValue>
json
- the JSON object to convertpublic boolean isCompatible(Object value)
ElementType
isCompatible
in interface ElementType<ContentValue>
isCompatible
in class AbstractElementType<ContentValue>
value
- the value to checktrue
if the value matches the current type, false
otherwisepublic boolean isSimple()
ElementType
isSimple
in interface ElementType<ContentValue>
true
if the type is simple, false
otherwiseprotected boolean _hasAmetysObjectsForIdentifiers(String... identifiers)
identifiers
- the identifierstrue
if ametys object exist for each identifier, false
otherwise