|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.cayenne.CayenneDataObject
public class CayenneDataObject
A default implementation of DataObject interface. It is normally used as a superclass of Cayenne persistent objects.
Field Summary | |
---|---|
protected ObjectContext |
objectContext
|
protected ObjectId |
objectId
|
protected int |
persistenceState
|
protected long |
snapshotVersion
|
protected java.util.Map |
values
|
Fields inherited from interface org.apache.cayenne.DataObject |
---|
DEFAULT_VERSION |
Constructor Summary | |
---|---|
CayenneDataObject()
|
Method Summary | |
---|---|
void |
addToManyTarget(java.lang.String relName,
DataObject value,
boolean setReverse)
|
protected void |
appendProperties(java.lang.StringBuffer buffer)
|
void |
decodeFromXML(XMLDecoder decoder)
Decodes itself from XML using the provided XMLDecoder. |
void |
encodeAsXML(XMLEncoder encoder)
Encodes object to XML using provided encoder. |
void |
fetchFinished()
Default implementation does nothing. |
DataContext |
getDataContext()
Returns a DataContext that holds this object. |
ObjectContext |
getObjectContext()
Returns this object's DataContext. |
ObjectId |
getObjectId()
|
ObjEntity |
getObjEntity()
Returns mapped ObjEntity for this object. |
int |
getPersistenceState()
|
long |
getSnapshotVersion()
Returns a version of a DataRow snapshot that was used to create this object. |
java.lang.Object |
readNestedProperty(java.lang.String path)
Returns a value of the property identified by a property path. |
java.lang.Object |
readProperty(java.lang.String propName)
Returns a value of the property identified by propName. |
java.lang.Object |
readPropertyDirectly(java.lang.String propName)
Returns mapped property value as curently stored in the DataObject. |
void |
removeToManyTarget(java.lang.String relName,
DataObject value,
boolean setReverse)
|
void |
resolveFault()
Deprecated. since 1.2 use 'getObjectContext().prepareForAccess(object)' |
void |
setDataContext(DataContext dataContext)
Initializes DataObject's persistence context. |
void |
setObjectContext(ObjectContext objectContext)
|
void |
setObjectId(ObjectId objectId)
|
void |
setPersistenceState(int persistenceState)
|
protected void |
setReverseRelationship(java.lang.String relName,
DataObject val)
Initializes reverse relationship from object val to this object. |
void |
setSnapshotVersion(long snapshotVersion)
|
void |
setToOneTarget(java.lang.String relationshipName,
DataObject value,
boolean setReverse)
Sets to-one relationship to a new value. |
java.lang.String |
toString()
|
java.lang.StringBuffer |
toStringBuffer(java.lang.StringBuffer buffer,
boolean fullDesc)
A variation of "toString" method, that may be more efficient in some cases. |
protected void |
unsetReverseRelationship(java.lang.String relName,
DataObject val)
Removes current object from reverse relationship of object val to
this object. |
void |
validateForDelete(ValidationResult validationResult)
This implementation does nothing. |
void |
validateForInsert(ValidationResult validationResult)
Calls validateForSave(ValidationResult) . |
protected void |
validateForSave(ValidationResult validationResult)
Performs property validation of the object, appending any validation failures to the provided validationResult object. |
void |
validateForUpdate(ValidationResult validationResult)
Calls validateForSave(ValidationResult) . |
protected void |
willConnect(java.lang.String relationshipName,
DataObject dataObject)
Called before establishing a relationship with another object. |
void |
writeProperty(java.lang.String propName,
java.lang.Object val)
Sets the property to the new value. |
void |
writePropertyDirectly(java.lang.String propName,
java.lang.Object val)
Modifies a value of a named property without altering the object state in any way, and without triggering any database operations. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected long snapshotVersion
protected ObjectId objectId
protected transient int persistenceState
protected transient ObjectContext objectContext
protected java.util.Map values
Constructor Detail |
---|
public CayenneDataObject()
Method Detail |
---|
public DataContext getDataContext()
getDataContext
in interface DataObject
public void setDataContext(DataContext dataContext)
setDataContext
in interface DataObject
public ObjEntity getObjEntity()
public ObjectId getObjectId()
getObjectId
in interface Persistent
public void setObjectId(ObjectId objectId)
setObjectId
in interface Persistent
public int getPersistenceState()
getPersistenceState
in interface Persistent
public void setPersistenceState(int persistenceState)
setPersistenceState
in interface Persistent
public java.lang.Object readNestedProperty(java.lang.String path)
DataObject
Property path (or nested property) is a dot-separated path used to traverse object
relationships until the final object is found. If a null object found while
traversing path, null is returned. If a list is encountered in the middle of the
path, CayenneRuntimeException is thrown. Unlike
DataObject.readPropertyDirectly(String)
, this method will resolve an object if it is
HOLLOW.
Examples:
String name = (String)artist.readNestedProperty("name");
Gallery g = (Gallery)paintingInfo.readNestedProperty("toPainting.toGallery");
String name = (String)painting.readNestedProperty("toArtist.artistName");
List exhibits = (List)painting.readNestedProperty("toGallery.exhibitArray");
String name = (String)artist.readNestedProperty("paintingArray.paintingName");
readNestedProperty
in interface DataObject
public void resolveFault()
DataObject
resolveFault
in interface DataObject
public java.lang.Object readProperty(java.lang.String propName)
DataObject
readProperty
in interface DataObject
public java.lang.Object readPropertyDirectly(java.lang.String propName)
DataObject
readPropertyDirectly
in interface DataObject
public void writeProperty(java.lang.String propName, java.lang.Object val)
DataObject
DataObject.setToOneTarget(String, DataObject, boolean)
.
writeProperty
in interface DataObject
propName
- a name of the bean property being modified.val
- a new value of the property.public void writePropertyDirectly(java.lang.String propName, java.lang.Object val)
DataObject
writePropertyDirectly
in interface DataObject
public void removeToManyTarget(java.lang.String relName, DataObject value, boolean setReverse)
removeToManyTarget
in interface DataObject
public void addToManyTarget(java.lang.String relName, DataObject value, boolean setReverse)
addToManyTarget
in interface DataObject
public void setToOneTarget(java.lang.String relationshipName, DataObject value, boolean setReverse)
DataObject
setToOneTarget
in interface DataObject
relationshipName
- a name of the bean property being modified - same as the
name of ObjRelationship.value
- a new value of the property.setReverse
- whether to update the reverse relationship pointing from the old
and new values of the property to this object.protected void willConnect(java.lang.String relationshipName, DataObject dataObject)
protected void setReverseRelationship(java.lang.String relName, DataObject val)
val
to this object.
relName
- name of relationship from this object to val
.protected void unsetReverseRelationship(java.lang.String relName, DataObject val)
val
to
this object.
public java.lang.StringBuffer toStringBuffer(java.lang.StringBuffer buffer, boolean fullDesc)
protected void appendProperties(java.lang.StringBuffer buffer)
public java.lang.String toString()
toString
in class java.lang.Object
public void fetchFinished()
fetchFinished
in interface DataObject
DataObject.fetchFinished()
public long getSnapshotVersion()
getSnapshotVersion
in interface DataObject
public void setSnapshotVersion(long snapshotVersion)
setSnapshotVersion
in interface DataObject
protected void validateForSave(ValidationResult validationResult)
public void validateForInsert(ValidationResult validationResult)
validateForSave(ValidationResult)
. CayenneDataObject subclasses may
override it providing validation logic that should be executed for the newly
created objects before saving them.
validateForInsert
in interface DataObject
public void validateForUpdate(ValidationResult validationResult)
validateForSave(ValidationResult)
. CayenneDataObject subclasses may
override it providing validation logic that should be executed for the modified
objects before saving them.
validateForUpdate
in interface DataObject
public void validateForDelete(ValidationResult validationResult)
validateForDelete
in interface DataObject
public void encodeAsXML(XMLEncoder encoder)
encodeAsXML
in interface XMLSerializable
encoder
- The encoder object.public void decodeFromXML(XMLDecoder decoder)
XMLSerializable
decodeFromXML
in interface XMLSerializable
decoder
- The decoder object.public ObjectContext getObjectContext()
getObjectContext
in interface Persistent
public void setObjectContext(ObjectContext objectContext)
setObjectContext
in interface Persistent
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |