public interface DataModel extends Serializable
The schema describe the data structure and the data model object is storing concrete values according to that structure.
When the user modifies a data structure the modified fields are tracked so that at any time you can query about the
dirty state of the data model by using the isDirty()
and isDirty(String)
methods.
The data model can be modified only through the set methods:
This is ensuring the dirty state will be correctly updated
This is the reason why the getMap()
method is returning a read only map.
Data structure are usually part of a composite model as the DocumentModel
.
Modifier and Type | Method and Description |
---|---|
Object |
getData(String key)
Gets the named field value.
|
Collection<String> |
getDirtyFields()
Gets the collection of the dirty fields in this data model.
|
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 getSchema()
void setData(String key, Object value) throws PropertyException
key
- the field namevalue
- the value to set. Accept null values.PropertyException
Object getData(String key) throws PropertyException
key
- the field keyPropertyException
Map<String,Object> getMap() throws PropertyException
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.
PropertyException
void setMap(Map<String,Object> data) throws PropertyException
data
- the fields to set as a mapPropertyException
boolean isDirty()
boolean isDirty(String name) throws PropertyNotFoundException
name
- the field name to testsPropertyNotFoundException
void setDirty(String name) throws PropertyNotFoundException
name
- the field name to be dirtyPropertyNotFoundException
Collection<String> getDirtyFields()
Object getValue(String path) throws PropertyException
The path is a subset of XPath: / and [] are supported.
path
- the property pathPropertyException
Object setValue(String path, Object value) throws PropertyException
path
- value
- PropertyException
Copyright © 2015 Nuxeo SA. All rights reserved.