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 Object
getData(String key)
Gets the named field value.Collection<String>
getDirtyFields()
Gets the collection of the dirty fields in this data model.DocumentPart
getDocumentPart()
Gets the underlying document part.Map<String,Object>
getMap()
Gets all the fields set in this data model.String
getSchema()
Gets the schema of this data model.Object
getValue(String path)
Gets a value given its path.boolean
isDirty()
Tests whether or not this data model is dirty (i.e.boolean
isDirty(String name)
Tests whether or not the specified field from this data model is dirty.void
setData(String key, Object value)
Sets the name field.void
setDirty(String name)
Marks the specified field from this data model as dirty.void
setMap(Map<String,Object> data)
Sets several field at once.Object
setValue(String path, Object value)
Sets a value to a property given its path.String
toString()
-
-
-
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:DataModel
Gets the schema of this data model.
-
getData
public Object getData(String key) throws PropertyException
Description copied from interface:DataModel
Gets the named field value.- Specified by:
getData
in 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:DataModel
Sets the name field.- Specified by:
setData
in 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:DataModel
Gets 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:
getMap
in 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:DataModel
Sets several field at once.- Specified by:
setMap
in interfaceDataModel
- Parameters:
data
- the fields to set as a map- Throws:
PropertyException
-
isDirty
public boolean isDirty()
Description copied from interface:DataModel
Tests 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:DataModel
Tests whether or not the specified field from this data model is dirty.- Specified by:
isDirty
in 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:DataModel
Gets the collection of the dirty fields in this data model.- Specified by:
getDirtyFields
in 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:DataModel
Marks the specified field from this data model as dirty.- Specified by:
setDirty
in interfaceDataModel
- Parameters:
name
- the field name to be dirty- Throws:
PropertyNotFoundException
-
getValue
public Object getValue(String path) throws PropertyException
Description copied from interface:DataModel
Gets a value given its path.The path is a subset of XPath: / and [] are supported.
- Specified by:
getValue
in interfaceDataModel
- Parameters:
path
- the property path- Throws:
PropertyException
-
setValue
public Object setValue(String path, Object value) throws PropertyException
Description copied from interface:DataModel
Sets a value to a property given its path.- Specified by:
setValue
in interfaceDataModel
- Throws:
PropertyException
-
-