public class DefaultModelAwareDataHolder extends Object implements ModelAwareDataHolder
Modifier and Type | Field and Description |
---|---|
protected Collection<? extends ModelItemContainer> |
_itemContainers
Model containers to use to get information about definitions
|
protected RepositoryData |
_repositoryData
Repository data to use to store data in the repository
|
Constructor and Description |
---|
DefaultModelAwareDataHolder(RepositoryData repositoryData,
Collection<? extends ModelItemContainer> itemContainers)
Creates a default model aware data holder
|
DefaultModelAwareDataHolder(RepositoryData repositoryData,
ModelItemContainer... itemContainers)
Creates a default model aware data holder
|
Modifier and Type | Method and Description |
---|---|
protected ModelAwareComposite |
_getComposite(String name,
CompositeDefinition compositeDefinition)
Retrieves the composite with the given name
|
protected ModelAwareRepeater |
_getRepeater(String name,
RepeaterDefinition repeaterDefinition)
Retrieves the repeater with the given name
|
ModelAwareComposite |
getComposite(String compositePath)
Retrieves the composite at the given path
|
Collection<String> |
getDataNames()
Retrieves the names of data contained by this data holder
|
ModelAwareRepeater |
getRepeater(String repeaterPath)
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
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
toSAX, toSAX
protected RepositoryData _repositoryData
protected Collection<? extends ModelItemContainer> _itemContainers
public DefaultModelAwareDataHolder(RepositoryData repositoryData, ModelItemContainer... itemContainers)
repositoryData
- the repository data to useitemContainers
- the model containers to use to get information about definitions. Must match the given repository data. A repository data can have several item containers. For example, a content can have several content types.public DefaultModelAwareDataHolder(RepositoryData repositoryData, Collection<? extends ModelItemContainer> itemContainers)
repositoryData
- the repository data to useitemContainers
- the model containers to use to get information about definitions. Must match the given repository data. A repository data can have several item containers. For example, a content can have several content types.public ModelAwareComposite getComposite(String compositePath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
ModelAwareDataHolder
getComposite
in interface DataHolder
getComposite
in interface ModelAwareDataHolder
compositePath
- 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 compositeBadDataPathCardinalityException
- if the definition of a part of the data path is multiple. Only the last part can be multiplepublic ModelAwareRepeater getRepeater(String repeaterPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
ModelAwareDataHolder
getRepeater
in interface DataHolder
getRepeater
in interface ModelAwareDataHolder
repeaterPath
- 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 repeaterBadDataPathCardinalityException
- if the definition of a part of the data path is multiple. Only the last part can be multiplepublic <T> T getValue(String dataPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
ModelAwareDataHolder
getValue
in interface ModelAwareDataHolder
T
- 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 repositoryBadDataPathCardinalityException
- if the definition of a part of the data path is multiple. Only the last part can be multiplepublic <T> T getValue(String dataPath, boolean useDefaultFromModel, T defaultValue) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
ModelAwareDataHolder
getValue
in interface ModelAwareDataHolder
T
- 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 repositoryBadDataPathCardinalityException
- if the definition of a part of the data path is multiple. Only the last part can be multipleprotected ModelAwareComposite _getComposite(String name, CompositeDefinition compositeDefinition) throws BadItemTypeException
name
- name of the composite to retrievecompositeDefinition
- the definition of the composite to retrieveBadItemTypeException
- if the value stored in the repository with the given name is not a compositeprotected ModelAwareRepeater _getRepeater(String name, RepeaterDefinition repeaterDefinition) throws BadItemTypeException
name
- name of the repeater to retrieverepeaterDefinition
- the definition of the repeater to retrieveBadItemTypeException
- if the value stored in the repository with the given name is not a repeaterpublic boolean hasValue(String dataPath) throws IllegalArgumentException, BadDataPathCardinalityException
ModelAwareDataHolder
hasValue
in interface DataHolder
hasValue
in interface ModelAwareDataHolder
dataPath
- path of the datatrue
if there is value for the data, false
otherwiseIllegalArgumentException
- if the given data path is null or emptyBadDataPathCardinalityException
- if the definition of a part of the data path is multiple. Only the last part can be multiplepublic boolean isMultiple(String path) throws IllegalArgumentException, UndefinedItemPathException
ModelAwareDataHolder
isMultiple
in interface ModelAwareDataHolder
path
- 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 modelpublic ModelItemType getType(String path) throws IllegalArgumentException, UndefinedItemPathException
ModelAwareDataHolder
getType
in interface ModelAwareDataHolder
path
- 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 Collection<String> getDataNames()
DataHolder
getDataNames
in interface DataHolder