Package com.jalios.jstore
Class BasicStorable
- java.lang.Object
 - 
- com.jalios.jstore.BasicStorable
 
 
- 
- All Implemented Interfaces:
 Storable,java.lang.Cloneable,java.lang.Comparable<BasicStorable>
- Direct Known Subclasses:
 Data
public class BasicStorable extends java.lang.Object implements Storable, java.lang.Comparable<BasicStorable>, java.lang.Cloneable
This class is a convenient super class for any Storable classes. It gets and sets all (non transient) attributs by introspection. It provides getter/setter for store, cdate and mdate. It encapsulated the store id of the object.- Version:
 - $Revision: 134140 $
 - Author:
 - Olivier Dedieu
 
 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBasicStorable.CdateComparator<T extends Storable>Compares two Storables using their Cdate in descending order (newest date first).static classBasicStorable.IdComparator<T extends Storable>Compares two Storables using their ID.static classBasicStorable.MdateComparator<T extends Storable>Compares two Storables using their Mdate in descending order (newest date first). 
- 
Constructor Summary
Constructors Constructor Description BasicStorable()Creates a new BasicStorableBasicStorable(BasicStorable other)Creates a new BasicStorable by cloning 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearId()Clear the ID of this storable.java.lang.Objectclone()intcompareTo(BasicStorable other)booleanequals(java.lang.Object obj)java.lang.StringgetAttribute(java.lang.Object attVal)Returns a persistent representation of an attribute from its namejava.util.Map<java.lang.String,java.lang.String>getAttributes()Returns a map containing all the attributs of this Storablejava.util.DategetCdate()Get the value of cdate.static <T extends Storable>
java.util.Comparator<T>getCdateComparator()java.util.DategetDdate()Returns the delete date of this storable.java.lang.StringgetId()Get the value of id.static <T extends Storable>
java.util.Comparator<T>getIdComparator()java.util.DategetMdate()Get the value of mdate.static <T extends Storable>
java.util.Comparator<T>getMdateComparator()StoregetStore()Get the value of store.java.lang.StringgetUrid()Returns the URID where this Storable has been created (ie return the urid of this id).booleanhasBeenUpdated()Check if this storable has been updatedinthashCode()This method return the HashCode of a storable using the storable id's hashcode if id is not null.booleanisStored()Check if this storable is registered in the store.voidresetInternalCaches()Reset internal caches (like isStoredCache for example)java.lang.StringresolveAtt(java.lang.Object attVal)This method is called if the type was not resolved by the getAttribute methodjava.lang.ObjectresolveVal(java.lang.Class<?> classType, java.lang.String persistentValue)This method is called if the type was not resolved by the getValue methodvoidsetAttributes(StorableLogEntry sle)Storable attributes settervoidsetAttributes(java.util.Map<java.lang.String,java.lang.String> attributes)Storable attributes settervoidsetCdate(java.util.Date v)Set the value of cdate.voidsetDdate(java.util.Date ddate)Sets the delete date of this storable.voidsetId(java.lang.String v)Set the value of id.voidsetMdate(java.util.Date v)Set the value of mdate.voidsetStore(Store v)Set the value of store.java.lang.StringtoXml() 
 - 
 
- 
- 
Field Detail
- 
REVISION
public static final java.lang.String REVISION
- See Also:
 - Constant Field Values
 
 
- 
cdate
protected java.util.Date cdate
 
- 
mdate
protected java.util.Date mdate
 
- 
id
protected transient java.lang.String id
 
- 
store
protected transient Store store
 
- 
ddate
protected transient java.util.Date ddate
 
- 
isStoreCache
protected transient java.lang.Boolean isStoreCache
 
 - 
 
- 
Constructor Detail
- 
BasicStorable
public BasicStorable()
Creates a new BasicStorable 
- 
BasicStorable
public BasicStorable(BasicStorable other)
Creates a new BasicStorable by cloning- Parameters:
 other- the BasicStorable to clone
 
 - 
 
- 
Method Detail
- 
toXml
public java.lang.String toXml()
 
- 
hashCode
public int hashCode()
This method return the HashCode of a storable using the storable id's hashcode if id is not null.- Overrides:
 hashCodein classjava.lang.Object- Returns:
 - int HashCode of the storable
 
 
- 
getIdComparator
public static <T extends Storable> java.util.Comparator<T> getIdComparator()
 
- 
getCdateComparator
public static <T extends Storable> java.util.Comparator<T> getCdateComparator()
 
- 
getMdateComparator
public static <T extends Storable> java.util.Comparator<T> getMdateComparator()
 
- 
setAttributes
public void setAttributes(java.util.Map<java.lang.String,java.lang.String> attributes)
Storable attributes setter- Parameters:
 attributes- the attributes to set:
Key=AttName(String) Value=persistent representation(String)
 
- 
setAttributes
public void setAttributes(StorableLogEntry sle)
Storable attributes setter- Specified by:
 setAttributesin interfaceStorable- Parameters:
 sle- the StorableLogEntry that contains the attributes to set:
Key=AttName(String) Value=persistent representation(String)
 
- 
getAttributes
public java.util.Map<java.lang.String,java.lang.String> getAttributes()
Returns a map containing all the attributs of this Storable- Specified by:
 getAttributesin interfaceStorable- Returns:
 - the attributes of the storable with the mapping: Key=Name(String) Value=persistent representation(String)
 
 
- 
getAttribute
public java.lang.String getAttribute(java.lang.Object attVal)
Returns a persistent representation of an attribute from its name- Specified by:
 getAttributein interfaceStorable- Parameters:
 attVal- the attribute value- Returns:
 - the persistent representation of the attribute
 
 
- 
resolveAtt
public java.lang.String resolveAtt(java.lang.Object attVal)
This method is called if the type was not resolved by the getAttribute method- Specified by:
 resolveAttin interfaceStorable- Parameters:
 attVal- the attribute value- Returns:
 - the persistent representation of the attribute
 
 
- 
resolveVal
public java.lang.Object resolveVal(java.lang.Class<?> classType, java.lang.String persistentValue)This method is called if the type was not resolved by the getValue method- Specified by:
 resolveValin interfaceStorable- Parameters:
 classType- the class typepersistentValue- the persistent value- Returns:
 - the object from its class type and persistent value
 
 
- 
clone
public java.lang.Object clone()
 
- 
clearId
public void clearId()
Clear the ID of this storable. Use this method with care. 
- 
hasBeenUpdated
public boolean hasBeenUpdated()
Check if this storable has been updated- Returns:
 - true if cdate != mdate (or cdate/mdate is null)
 
 
- 
getUrid
public java.lang.String getUrid()
Returns the URID where this Storable has been created (ie return the urid of this id). Return an empty String, if id is null- Returns:
 - the URID where this Storable has been created
 - Since:
 - jcms-4.1
 
 
- 
isStored
public boolean isStored()
Check if this storable is registered in the store.- Returns:
 - true if this storable is registered in the store.
 - Since:
 - jcms-5.0.2
 
 
- 
resetInternalCaches
public void resetInternalCaches()
Description copied from interface:StorableReset internal caches (like isStoredCache for example)- Specified by:
 resetInternalCachesin interfaceStorable
 
- 
compareTo
public int compareTo(BasicStorable other)
- Specified by:
 compareToin interfacejava.lang.Comparable<BasicStorable>
 
- 
equals
public boolean equals(java.lang.Object obj)
- Overrides:
 equalsin classjava.lang.Object
 
- 
getId
public java.lang.String getId()
Get the value of id. 
- 
setId
public void setId(java.lang.String v)
Set the value of id. 
- 
getStore
public Store getStore()
Get the value of store. 
- 
setStore
public void setStore(Store v)
Set the value of store. 
- 
getCdate
public java.util.Date getCdate()
Get the value of cdate. 
- 
setCdate
public void setCdate(java.util.Date v)
Set the value of cdate. 
- 
getMdate
public java.util.Date getMdate()
Get the value of mdate. 
- 
setMdate
public void setMdate(java.util.Date v)
Set the value of mdate. 
- 
getDdate
public java.util.Date getDdate()
Returns the delete date of this storable. 
 - 
 
 -