Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.core.api.impl
Class DataModelImpl

java.lang.Object
  extended by 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
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.
 
Method Summary
 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()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataModelImpl

public DataModelImpl(String schema)
Builds an empty data model.

Parameters:
schema - a schema name.

DataModelImpl

public DataModelImpl(String schema,
                     Map<String,Object> data)
Builds a data model using the given data.

Parameters:
schema - 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.

Specified by:
getSchema in interface DataModel
Returns:
the data model schema

getData

public Object getData(String key)
               throws PropertyException
Description copied from interface: DataModel
Gets the named field value.

Specified by:
getData in interface DataModel
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 interface DataModel
Parameters:
key - the field name
value - 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 interface DataModel
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 interface DataModel
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).

Specified by:
isDirty in interface DataModel
Returns:
true if the data model is dirty, false otherwise

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 interface DataModel
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 interface DataModel
Returns:
the dirty fields or null if there are no dirty fields

toString

public String toString()
Overrides:
toString in class Object

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 interface DataModel
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 interface DataModel
Parameters:
path - the property path
Returns:
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 interface DataModel
Returns:
Throws:
PropertyException

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.