public class DataModelImpl extends Object implements DataModel
Constructor and Description |
---|
DataModelImpl(DocumentPart part) |
DataModelImpl(String schema)
Builds an empty data model.
|
DataModelImpl(String schema,
Map<String,Object> data)
Builds a data model using the given data.
|
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.
|
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() |
public DataModelImpl(String schema)
schema
- a schema name.public DataModelImpl(String schema, Map<String,Object> data)
schema
- a schema name.data
- the data (map String>Object) to put in the DataModel.public DataModelImpl(DocumentPart part)
public DocumentPart getDocumentPart()
public String getSchema()
DataModel
public Object getData(String key) throws PropertyException
DataModel
getData
in interface DataModel
key
- the field keyPropertyException
public void setData(String key, Object value) throws PropertyException
DataModel
setData
in interface DataModel
key
- the field namevalue
- the value to set. Accept null values.PropertyException
public Map<String,Object> getMap() throws PropertyException
DataModel
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.
getMap
in interface DataModel
PropertyException
public void setMap(Map<String,Object> data) throws PropertyException
DataModel
setMap
in interface DataModel
data
- the fields to set as a mapPropertyException
public boolean isDirty()
DataModel
public boolean isDirty(String name) throws PropertyNotFoundException
DataModel
isDirty
in interface DataModel
name
- the field name to testsPropertyNotFoundException
public Collection<String> getDirtyFields()
DataModel
getDirtyFields
in interface DataModel
public void setDirty(String name) throws PropertyNotFoundException
DataModel
setDirty
in interface DataModel
name
- the field name to be dirtyPropertyNotFoundException
public Object getValue(String path) throws PropertyException
DataModel
The path is a subset of XPath: / and [] are supported.
getValue
in interface DataModel
path
- the property pathPropertyException
public Object setValue(String path, Object value) throws PropertyException
DataModel
setValue
in interface DataModel
PropertyException
Copyright © 2013 Nuxeo SA. All Rights Reserved.