com.groiss.store
Class PersistentObject

java.lang.Object
  extended by com.groiss.store.PersistentObject
All Implemented Interfaces:
KeyValuePair<java.lang.Object,java.lang.Object>, Persistent, java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
BasicEvent, BatchJob, ExportablePersistentObject, Lock, Partner, ProcessRelation

public abstract class PersistentObject
extends java.lang.Object
implements java.io.Serializable, Persistent, KeyValuePair<java.lang.Object,java.lang.Object>, java.lang.Cloneable

This is a default implementation of the Persistent interface. All methods apart from Persistent.getTableName() are implemented with default behaviour.

This abstract class also implements the KeyValuePair interface. So persistent objects become key value pairs, where the object's OID is the key and the object's String representation is the value.

See Also:
Serialized Form

Field Summary
protected  boolean filled
           
protected  long oid
           
 
Constructor Summary
PersistentObject()
           
 
Method Summary
 java.lang.Object clone()
           
 java.util.List<java.lang.reflect.Field> dbFields()
          Returns the persistent fields of this object in a List containing java.lang.reflect.Field objects.
 boolean equals(java.lang.Object o)
          Compares two persistent objects and returns true if they are equal (i.e., they must have the same OID and the same class).
 java.lang.Object getKey()
          Returns the key (OID) of this KeyValuePair.
 long getOid()
          Getter method for the persistent object's OID.
 Store getStore()
          Returns the Store object which is responsible for storing this persistence object.
 java.lang.Object getValue()
          Returns the value (String representation) of this KeyValuePair.
 int hashCode()
          Returns a hash code for this persistent object.
 boolean isFilled()
          With this method you check if this persistent object is filled with persistent data or not.
 void onDelete()
          This method is called before the persistent object is deleted.
 void onInsert()
          This method is called before the persistent object is inserted in the store.
 void onRead()
          This method is called after the persistent object has been read.
 void onUpdate()
          This method is called before the persistent object is updated to the store (the existing object in the store will be overwritten with the values of this object).
 void setFilled(boolean f)
          This method can change the filled status of this persistent object.
 void setOid(long oid)
          Setter method for the persistent object's OID.
 void setStore(Store store)
          With this method you can change the Store of this persistent object.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.groiss.store.Persistent
getTableName
 

Field Detail

oid

protected long oid

filled

protected boolean filled
Constructor Detail

PersistentObject

public PersistentObject()
Method Detail

getOid

public long getOid()
Description copied from interface: Persistent
Getter method for the persistent object's OID.

Specified by:
getOid in interface Persistent
Returns:
The OID of the persistent object.

setOid

public void setOid(long oid)
Description copied from interface: Persistent
Setter method for the persistent object's OID. Usually you will never need to set the OID of an object directly, because OIDs are assigned automatically.

Specified by:
setOid in interface Persistent
Parameters:
oid - The new OID for the object.

setFilled

public void setFilled(boolean f)
Description copied from interface: Persistent
This method can change the filled status of this persistent object. See Persistent.isFilled() for more details.

Specified by:
setFilled in interface Persistent
Parameters:
f - The new value for the filled status.

isFilled

public boolean isFilled()
Description copied from interface: Persistent
With this method you check if this persistent object is filled with persistent data or not. If it is not filled, you can use the Store to fill it.

Specified by:
isFilled in interface Persistent
Returns:
true if the object is filled with values, or false if the object is empty (only OID is set).

getStore

public Store getStore()
Returns the Store object which is responsible for storing this persistence object.

Specified by:
getStore in interface Persistent
Returns:
The Store of this persistent object.

setStore

public void setStore(Store store)
Description copied from interface: Persistent
With this method you can change the Store of this persistent object. Usually objects are stored in the system's database and you will never need to set the Store manually.

Specified by:
setStore in interface Persistent
Parameters:
store - The new Store that will be set for this persistent object.

dbFields

public java.util.List<java.lang.reflect.Field> dbFields()
Returns the persistent fields of this object in a List containing java.lang.reflect.Field objects.

Specified by:
dbFields in interface Persistent
Returns:
A List containing the persistent fields of this persistent object. The List must contain the fields as java.lang.reflect.Field objects.

onInsert

public void onInsert()
Description copied from interface: Persistent
This method is called before the persistent object is inserted in the store.

Specified by:
onInsert in interface Persistent

onUpdate

public void onUpdate()
Description copied from interface: Persistent
This method is called before the persistent object is updated to the store (the existing object in the store will be overwritten with the values of this object).

Specified by:
onUpdate in interface Persistent

onDelete

public void onDelete()
Description copied from interface: Persistent
This method is called before the persistent object is deleted. Note that the Store.delete(Class, String, Object[]) and Store.delete(String, String, Object[]) methods do NOT call Persistent.onDelete().

Specified by:
onDelete in interface Persistent

onRead

public void onRead()
Description copied from interface: Persistent
This method is called after the persistent object has been read.

Specified by:
onRead in interface Persistent

equals

public boolean equals(java.lang.Object o)
Compares two persistent objects and returns true if they are equal (i.e., they must have the same OID and the same class).

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Returns a hash code for this persistent object. Equal objects must have equal hash codes, so the object's OID is used as hash code.

Overrides:
hashCode in class java.lang.Object

getValue

public java.lang.Object getValue()
Returns the value (String representation) of this KeyValuePair.

Specified by:
getValue in interface KeyValuePair<java.lang.Object,java.lang.Object>

getKey

public java.lang.Object getKey()
Returns the key (OID) of this KeyValuePair.

Specified by:
getKey in interface KeyValuePair<java.lang.Object,java.lang.Object>

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object


@enterprise 8.0.22989 Copyright © 2001-2017 Groiss Informatics GmbH. All Rights Reserved.