Package org.nuxeo.ecm.core.api.impl
Class DataModelImpl
- java.lang.Object
-
- org.nuxeo.ecm.core.api.impl.DataModelImpl
-
- All Implemented Interfaces:
Serializable,DataModel
public class DataModelImpl extends Object implements DataModel
Data model implementation.- Author:
- Bogdan Stefanescu
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DataModelImpl(String schema)Builds an empty data model.DataModelImpl(String schemaName, Map<String,Object> data)Builds a data model using the given data.DataModelImpl(DocumentPart part)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectgetData(String key)Gets the named field value.Collection<String>getDirtyFields()Gets the collection of the dirty fields in this data model.DocumentPartgetDocumentPart()Gets the underlying document part.Map<String,Object>getMap()Gets all the fields set in this data model.StringgetSchema()Gets the schema of this data model.ObjectgetValue(String path)Gets a value given its path.booleanisDirty()Tests whether or not this data model is dirty (i.e.booleanisDirty(String name)Tests whether or not the specified field from this data model is dirty.voidsetData(String key, Object value)Sets the name field.voidsetDirty(String name)Marks the specified field from this data model as dirty.voidsetMap(Map<String,Object> data)Sets several field at once.ObjectsetValue(String path, Object value)Sets a value to a property given its path.StringtoString()
-
-
-
Constructor Detail
-
DataModelImpl
public DataModelImpl(String schema)
Builds an empty data model.- Parameters:
schema- a schema name.
-
DataModelImpl
public DataModelImpl(String schemaName, Map<String,Object> data)
Builds a data model using the given data.- Parameters:
schemaName- a schema name.data- the data (map String>Object) to put in the DataModel.
-
DataModelImpl
public DataModelImpl(DocumentPart part)
-
-
Method Detail
-
getDocumentPart
public DocumentPart getDocumentPart()
Gets the underlying document part.
-
getSchema
public String getSchema()
Description copied from interface:DataModelGets the schema of this data model.
-
getData
public Object getData(String key) throws PropertyException
Description copied from interface:DataModelGets the named field value.- Specified by:
getDatain interfaceDataModel- Parameters:
key- the field key- Returns:
- the value or null if no such field exists
- Throws:
PropertyException
-
setData
public void setData(String key, Object value) throws PropertyException
Description copied from interface:DataModelSets the name field.- Specified by:
setDatain interfaceDataModel- Parameters:
key- the field namevalue- the value to set. Accept null values.- Throws:
PropertyException
-
getMap
public Map<String,Object> getMap() throws PropertyException
Description copied from interface:DataModelGets all the fields set in this data model.It is not guaranteed that the returned map will contain all the fields defined by the schema. It may even be empty.
The returned map is null if the data model was not yet loaded.
- Specified by:
getMapin interfaceDataModel- Returns:
- a read only map containing actual data in this object
- Throws:
PropertyException
-
setMap
public void setMap(Map<String,Object> data) throws PropertyException
Description copied from interface:DataModelSets several field at once.- Specified by:
setMapin interfaceDataModel- Parameters:
data- the fields to set as a map- Throws:
PropertyException
-
isDirty
public boolean isDirty()
Description copied from interface:DataModelTests whether or not this data model is dirty (i.e. it was changed by the client).
-
isDirty
public boolean isDirty(String name) throws PropertyNotFoundException
Description copied from interface:DataModelTests whether or not the specified field from this data model is dirty.- Specified by:
isDirtyin interfaceDataModel- Parameters:
name- the field name to tests- Returns:
- true if the field is dirty, false otherwise
- Throws:
PropertyNotFoundException
-
getDirtyFields
public Collection<String> getDirtyFields()
Description copied from interface:DataModelGets the collection of the dirty fields in this data model.- Specified by:
getDirtyFieldsin interfaceDataModel- Returns:
- the dirty fields or null if there are no dirty fields
-
setDirty
public void setDirty(String name) throws PropertyNotFoundException
Description copied from interface:DataModelMarks the specified field from this data model as dirty.- Specified by:
setDirtyin interfaceDataModel- Parameters:
name- the field name to be dirty- Throws:
PropertyNotFoundException
-
getValue
public Object getValue(String path) throws PropertyException
Description copied from interface:DataModelGets a value given its path.The path is a subset of XPath: / and [] are supported.
- Specified by:
getValuein interfaceDataModel- Parameters:
path- the property path- Throws:
PropertyException
-
setValue
public Object setValue(String path, Object value) throws PropertyException
Description copied from interface:DataModelSets a value to a property given its path.- Specified by:
setValuein interfaceDataModel- Throws:
PropertyException
-
-