public class ContentValue extends Object implements ModifiableModelAwareDataHolder
AbstractContentElementType| Modifier and Type | Field and Description |
|---|---|
private ModifiableContent |
_content |
private String |
_contentId |
private AmetysObjectResolver |
_resolver |
private Session |
_session |
| Constructor and Description |
|---|
ContentValue(AmetysObjectResolver resolver,
String contentId)
Constructor of the content wrapper
|
ContentValue(AmetysObjectResolver resolver,
String contentId,
Session session)
Constructor of the content wrapper
|
| Modifier and Type | Method and Description |
|---|---|
ModifiableModelAwareComposite |
getComposite(String compositePath)
Retrieves the composite at the given path
|
ModifiableModelAwareComposite |
getComposite(String compositePath,
boolean createNew)
Retrieves the composite at the given path
|
ModifiableContent |
getContent()
Retrieves the content
|
String |
getContentId()
Retrieves the content's identifier
|
Collection<String> |
getDataNames()
Retrieves the names of data contained by this data holder
|
ModifiableModelAwareRepeater |
getRepeater(String repeaterPath)
Retrieves the repeater at the given path
|
ModifiableModelAwareRepeater |
getRepeater(String repeaterPath,
boolean createNew)
Retrieves the repeater at the given path
|
ModelItemType |
getType(String path)
Retrieves the type of the data at the given path
|
<T> T |
getValue(String dataPath)
Retrieves the value of the data at the given path
|
<T> T |
getValue(String dataPath,
boolean useDefaultFromModel,
T defaultValue)
Retrieves the value of the data at the given path, or the default value
|
boolean |
hasValue(String dataPath)
Checks if there is a value for the data at the given path
|
boolean |
isMultiple(String path)
Checks if the definition of the element at the given path is multiple
|
void |
removeValue(String dataPath)
Removes the value of the data stored in the repository at the given path
|
void |
setValue(String dataPath,
Object value)
Sets the value of the data at the given path
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waittoSAX, toSAXprivate AmetysObjectResolver _resolver
private String _contentId
private ModifiableContent _content
public ContentValue(AmetysObjectResolver resolver, String contentId)
resolver - resolver used to get the content from its identifiercontentId - content identifierpublic ContentValue(AmetysObjectResolver resolver, String contentId, Session session)
resolver - resolver used to get the content from its identifiercontentId - content identifiersession - the current session. If null, a new session will be used to retrieve the contentpublic String getContentId()
public ModifiableContent getContent() throws AmetysRepositoryException, UnknownAmetysObjectException
AmetysRepositoryException - if an error occurs.UnknownAmetysObjectException - if no content exists for the identifierpublic boolean hasValue(String dataPath) throws IllegalArgumentException
DataHolderhasValue in interface DataHolderhasValue in interface ModelAwareDataHolderdataPath - path of the datatrue if there is value for the data, false otherwiseIllegalArgumentException - if the given data path is null or emptypublic Collection<String> getDataNames()
DataHoldergetDataNames in interface DataHolderpublic <T> T getValue(String dataPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException
ModelAwareDataHoldergetValue in interface ModelAwareDataHolderT - type of the value to retrievedataPath - path of the datanull if not exists. The object returned may be of a generic class defined by the storage (if the model is unknown). For example, an url may be returned as a String.IllegalArgumentException - if the given data path is null or emptyUndefinedItemPathException - if the given data path is not defined by the modelBadItemTypeException - if the type defined by the model doesn't match the value stored in the repositorypublic <T> T getValue(String dataPath, boolean useDefaultFromModel, T defaultValue) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException
ModelAwareDataHoldergetValue in interface ModelAwareDataHolderT - type of the value to retrievedataPath - path of the datauseDefaultFromModel - true to use the default value from the model, false to use the given default valuedefaultValue - default value used if value is null and useDefaultFromModel is false, or if there is no default value on modelnull if not exists.IllegalArgumentException - if the given data path is null or emptyUndefinedItemPathException - if the given data path is not defined by the modelBadItemTypeException - if the type defined by the model doesn't match the value stored in the repositorypublic boolean isMultiple(String path) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException
ModelAwareDataHolderisMultiple in interface ModelAwareDataHolderpath - path of the element. No matter if it is a definition or data path (with repeater entry positions)true if the element is multiple, false otherwiseIllegalArgumentException - if the given path is null or emptyUndefinedItemPathException - if the given path is not defined by the modelBadItemTypeExceptionpublic ModelItemType getType(String path) throws IllegalArgumentException, UndefinedItemPathException
ModelAwareDataHoldergetType in interface ModelAwareDataHolderpath - path of the data. No matter if it is a definition or data path (with repeater entry positions)IllegalArgumentException - if the given data path is null or emptyUndefinedItemPathException - if the given data path is not defined by the modelpublic ModifiableModelAwareComposite getComposite(String compositePath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException
DataHoldergetComposite in interface DataHoldergetComposite in interface ModelAwareDataHoldergetComposite in interface ModifiableDataHoldergetComposite in interface ModifiableModelAwareDataHoldercompositePath - path of the composite to retrievenull if not existsIllegalArgumentException - if the given composite path is null or emptyUndefinedItemPathException - if the given composite path is not defined by the modelBadItemTypeException - if the value stored in the repository at the given path is not a compositepublic ModifiableModelAwareRepeater getRepeater(String repeaterPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException
DataHoldergetRepeater in interface DataHoldergetRepeater in interface ModelAwareDataHoldergetRepeater in interface ModifiableDataHoldergetRepeater in interface ModifiableModelAwareDataHolderrepeaterPath - path of the repeater to retrievenull if not existsIllegalArgumentException - if the given repeater path is null or emptyUndefinedItemPathException - if the given repeater path is not defined by the modelBadItemTypeException - if the value stored in the repository at the given path is not a repeaterpublic ModifiableModelAwareComposite getComposite(String compositePath, boolean createNew) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException
ModifiableModelAwareDataHoldergetComposite in interface ModifiableDataHoldergetComposite in interface ModifiableModelAwareDataHoldercompositePath - path of the composite to retrievecreateNew - true to create the composite if it does not exist, false otherwiseIllegalArgumentException - if the given composite path is null or emptyUndefinedItemPathException - if the given composite path is not defined by the modelBadItemTypeException - if the value stored in the repository at the given path is not a compositepublic ModifiableModelAwareRepeater getRepeater(String repeaterPath, boolean createNew) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException
ModifiableModelAwareDataHoldergetRepeater in interface ModifiableDataHoldergetRepeater in interface ModifiableModelAwareDataHolderrepeaterPath - path of the repeater to retrievecreateNew - true to create the repeater if it does not exist, false otherwiseIllegalArgumentException - if the given repeater path is null or emptyUndefinedItemPathException - if the given composite path is not defined by the modelBadItemTypeException - if the value stored in the repository at the given path is not a repeaterpublic void setValue(String dataPath, Object value) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException
ModifiableModelAwareDataHoldersetValue in interface ModifiableModelAwareDataHolderdataPath - path of the datavalue - the value to set. The type of this value will be given by the model, but if not model is associated to the path, an UnsupportedOperationException is thrown. Use the 3 arguments versions in that case.IllegalArgumentException - if the given data path is null or emptyUndefinedItemPathException - if the given data path is not defined by the modelBadItemTypeException - if the type defined by the model doesn't match the given value to setpublic void removeValue(String dataPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException
ModifiableModelAwareDataHolderremoveValue in interface ModifiableDataHolderremoveValue in interface ModifiableModelAwareDataHolderdataPath - path of the dataIllegalArgumentException - if the given data path is null or emptyUndefinedItemPathException - if the given data path is not defined by the modelBadItemTypeException