|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.caleigo.core.AbstractEntity
The AbstractEntity class is an abtsract implementation of the IEntity interface. Subclasses only need to override the tree methods getRawData, setRawData and getEntityDescriptor. Entities are data objects representing single instances of data rows/records from a persistent data storage. An entity contains several fields of data accessible using the setData() and getData() methods.
| Field Summary |
| Fields inherited from interface org.caleigo.core.IEntity |
DIRTY, EMPTY, PERSISTENT |
| Constructor Summary | |
AbstractEntity()
Default constructor for AbstractEntity. |
|
AbstractEntity(Qualifier identityQualifier)
|
|
| Method Summary | |
void |
addEntityChangeListener(IEntityChangeListener listener)
Adds IEntityChangeListener to receive notifications of changes in the entity's status and data content. |
void |
addEntityListener(IEntityListener listener)
Adds IEntityListener to receive notifications of performed data operations on the entity object. |
void |
clear()
Clear resets all data in the entity to their defalt values and sets the flags to reflect an empty unchanged data entity. |
protected void |
clearAllDirtyFlags()
|
void |
clearStatusFlag(int flags)
Should not normally be used by standard API users. |
int |
compareTo(java.lang.Object entity)
Compares all identity data values between the objects if they are of the same type that is are defined by the same entity descriptor. |
void |
copyData(IDataProvider propertySource)
Copies and updates the in the entity containde data by reading each individual data field as a property from the provided property source. |
void |
delete()
This method will delete the entity from it's related persistent storage. |
protected void |
doOnDataChange(IFieldDescriptor fieldDescriptor,
java.lang.Object oldValue,
java.lang.Object newValue)
This help method is called when the called entity changes a data value. |
protected void |
doOnDirty()
This help method is called when the called when an entity changes state from non-dirty to dirty. |
protected void |
doOnStateChange(int statusType,
boolean newStatus)
This help method is called when the called entity changes state. |
boolean |
equals(java.lang.Object entity)
Returns true if the data in all the entities IDENTIY fields are considered equal according to their DataType class. |
boolean |
equalsExactly(java.lang.Object entity)
Compares all data values between the objects if they are of the same type. |
protected void |
fireDataChangedEvent(IFieldDescriptor fieldDescriptor,
java.lang.Object oldValue,
java.lang.Object newValue)
Fires an EntityChangeEvent specifying a data field change to all registered IEntityChangeListener objects. |
protected void |
fireOpPerformedEvent(int opType)
Fires an EntityEvent with the provided operation type to all registered IEntityListener objects. |
protected void |
fireStatusChangedEvent(int statusType,
boolean newStatus)
Fires an EntityChangeEvent specifying a status change to all registered IEntityChangeListener objects. |
java.lang.Object |
getData(IFieldDescriptor fieldDescriptor)
Returns the data value of the addressed data field. |
java.lang.Object |
getData(java.lang.String codeName)
Access method the returns the identified data from the object. |
boolean |
getDataBoolean(IFieldDescriptor field)
|
byte |
getDataByte(IFieldDescriptor field)
|
double |
getDataDouble(IFieldDescriptor field)
|
float |
getDataFloat(IFieldDescriptor field)
|
int |
getDataInteger(IFieldDescriptor field)
|
long |
getDataLong(IFieldDescriptor field)
|
short |
getDataShort(IFieldDescriptor field)
|
IDataSource |
getDataSource()
Returns the data source that the entity object belongs to. |
abstract IEntityDescriptor |
getEntityDescriptor()
Return the entity objects IEntityDescriptor that defines it's type and structure. |
Qualifier |
getOriginQualifier()
Returns a identity qualifier that uniquely qualifies the entity in a persistent storage. |
(package private) abstract java.lang.Object |
getRawData(int index)
Should return the contained indexed data avoidinng any convertions or formating. |
boolean |
isDataNull(IFieldDescriptor fieldDescriptor)
Returns true if the addressed entity field is contains a NULL value. |
boolean |
isDirty()
Returns true if any entity field in the entity has been changed since creation or the last syncronization with the persistent storage. |
boolean |
isEmpty()
Returns true for newly creted object that that has had no changes from the default data set at the moment of creation. |
boolean |
isFieldDirty(IFieldDescriptor fieldDescriptor)
Returns true if the addressed entity field has been changed since creation or the last syncronization with the persistent storage. |
boolean |
isPersistent()
Returns true if the the entity reflects data that exists in a related persistent storage. |
static java.lang.String |
makeLogString(IEntity entity)
Makes a descriptive log string for the provided entity object. |
static java.lang.String |
makeLogString(IEntity entity,
IFieldDescriptor[] fields)
Makes a descriptive log string for the provided entity object. |
void |
refresh()
This method will refresh the entity with current data from the related persistent storage. |
void |
removeEntityChangeListener(IEntityChangeListener listener)
Removes the specified IEntityListener from the entity object. |
void |
removeEntityListener(IEntityListener listener)
Removes the specified IEntityListener from the entity object. |
void |
setData(IDataProvider dataProvider)
This method implies to the called object to fetch all data it can consume from the provided IDataProvider object. |
void |
setData(IFieldDescriptor fieldDescriptor,
java.lang.Object data)
Sets the value of the addressed data field. |
void |
setData(java.lang.String codeName,
java.lang.Object dataValue)
Sets the data identified by the provided code name. |
void |
setDataBoolean(IFieldDescriptor field,
boolean value)
|
void |
setDataByte(IFieldDescriptor field,
byte value)
|
void |
setDataDouble(IFieldDescriptor field,
double value)
|
void |
setDataFloat(IFieldDescriptor field,
float value)
|
void |
setDataInteger(IFieldDescriptor field,
int value)
|
void |
setDataLong(IFieldDescriptor field,
long value)
|
void |
setDataShort(IFieldDescriptor field,
short value)
|
protected void |
setDefaultValues()
This method is expected to set the default values to the entity. |
protected void |
setDirtyFlag(IFieldDescriptor fieldDescriptor)
|
(package private) abstract void |
setRawData(int index,
java.lang.Object data)
Should set the indexed data avoiding any convertions or format changes. |
void |
setStatusFlag(int flags)
Should not normally be used by standard API users. |
void |
store()
This method will store any unsaved changes in the entity to it's realated persistent storage. |
java.lang.String |
toString()
Overriden to display the entity description type, identifying data and state of the status flags (D)IRTY, (E)MPTY and (P)ERSISTANT. |
ValidationResult |
validateData()
Help method that validates the data contained in the called data object and returns a ValidationResult object. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public AbstractEntity()
public AbstractEntity(Qualifier identityQualifier)
| Method Detail |
public static java.lang.String makeLogString(IEntity entity)
public static java.lang.String makeLogString(IEntity entity,
IFieldDescriptor[] fields)
public abstract IEntityDescriptor getEntityDescriptor()
getEntityDescriptor in interface IEntityabstract java.lang.Object getRawData(int index)
abstract void setRawData(int index,
java.lang.Object data)
public java.lang.String toString()
public void store()
store in interface IEntitypublic void delete()
delete in interface IEntitypublic void refresh()
refresh in interface IEntitypublic void copyData(IDataProvider propertySource)
copyData in interface IEntitypublic boolean isDataNull(IFieldDescriptor fieldDescriptor)
isDataNull in interface IEntitypublic java.lang.Object getData(IFieldDescriptor fieldDescriptor)
getData in interface IEntityInvalidFieldException
public void setData(IFieldDescriptor fieldDescriptor,
java.lang.Object data)
setData in interface IEntityInvalidFieldException
ReadOnlyViolationExceptionpublic void clear()
clear in interface IEntitypublic ValidationResult validateData()
validateData in interface IEntitypublic boolean isFieldDirty(IFieldDescriptor fieldDescriptor)
isFieldDirty in interface IEntitypublic boolean isDirty()
isDirty in interface IEntitypublic boolean isEmpty()
isEmpty in interface IEntitypublic boolean isPersistent()
isPersistent in interface IEntitypublic IDataSource getDataSource()
getDataSource in interface IEntitypublic Qualifier getOriginQualifier()
getOriginQualifier in interface IEntitypublic boolean equals(java.lang.Object entity)
equals in interface IEntitypublic boolean equalsExactly(java.lang.Object entity)
equalsExactly in interface IEntitypublic java.lang.Object getData(java.lang.String codeName)
IDataProvider
getData in interface IDataProvider
public void setData(java.lang.String codeName,
java.lang.Object dataValue)
IDataConsumer
setData in interface IDataConsumerpublic void setData(IDataProvider dataProvider)
IDataConsumer
setData in interface IDataConsumerpublic int compareTo(java.lang.Object entity)
compareTo in interface java.lang.Comparablepublic void setStatusFlag(int flags)
IEntity
setStatusFlag in interface IEntitypublic void clearStatusFlag(int flags)
IEntity
clearStatusFlag in interface IEntitypublic void addEntityListener(IEntityListener listener)
addEntityListener in interface IEntitypublic void removeEntityListener(IEntityListener listener)
removeEntityListener in interface IEntitypublic void addEntityChangeListener(IEntityChangeListener listener)
addEntityChangeListener in interface IEntitypublic void removeEntityChangeListener(IEntityChangeListener listener)
removeEntityChangeListener in interface IEntityprotected void setDefaultValues()
protected void doOnDataChange(IFieldDescriptor fieldDescriptor,
java.lang.Object oldValue,
java.lang.Object newValue)
protected void doOnDirty()
protected void doOnStateChange(int statusType,
boolean newStatus)
protected void setDirtyFlag(IFieldDescriptor fieldDescriptor)
protected void clearAllDirtyFlags()
protected void fireOpPerformedEvent(int opType)
protected void fireDataChangedEvent(IFieldDescriptor fieldDescriptor,
java.lang.Object oldValue,
java.lang.Object newValue)
protected void fireStatusChangedEvent(int statusType,
boolean newStatus)
public long getDataLong(IFieldDescriptor field)
public void setDataLong(IFieldDescriptor field,
long value)
public int getDataInteger(IFieldDescriptor field)
public void setDataInteger(IFieldDescriptor field,
int value)
public short getDataShort(IFieldDescriptor field)
public void setDataShort(IFieldDescriptor field,
short value)
public byte getDataByte(IFieldDescriptor field)
public void setDataByte(IFieldDescriptor field,
byte value)
public boolean getDataBoolean(IFieldDescriptor field)
public void setDataBoolean(IFieldDescriptor field,
boolean value)
public float getDataFloat(IFieldDescriptor field)
public void setDataFloat(IFieldDescriptor field,
float value)
public double getDataDouble(IFieldDescriptor field)
public void setDataDouble(IFieldDescriptor field,
double value)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||