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.- Author:
- Olivier Dedieu
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BasicStorable.CdateComparator<T extends Storable>
Compares two Storables using their Cdate in descending order (newest date first).static class
BasicStorable.IdComparator<T extends Storable>
Compares two Storables using their ID.static class
BasicStorable.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 void
clearId()
Clear the ID of this storable.java.lang.Object
clone()
int
compareTo(BasicStorable other)
boolean
equals(java.lang.Object obj)
java.lang.String
getAttribute(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.Date
getCdate()
Get the value of cdate.static <T extends Storable>
java.util.Comparator<T>getCdateComparator()
java.util.Date
getDdate()
Returns the delete date of this storable.java.lang.String
getId()
Get the value of id.static <T extends Storable>
java.util.Comparator<T>getIdComparator()
java.util.Date
getMdate()
Get the value of mdate.static <T extends Storable>
java.util.Comparator<T>getMdateComparator()
Store
getStore()
Get the value of store.java.lang.String
getUrid()
Returns the URID where this Storable has been created (ie return the urid of this id).boolean
hasBeenUpdated()
Check if this storable has been updatedint
hashCode()
This method return the HashCode of a storable using the storable id's hashcode if id is not null.boolean
isStored()
Check if this storable is registered in the store.void
resetInternalCaches()
Reset internal caches (like isStoredCache for example)java.lang.String
resolveAtt(java.lang.Object attVal)
This method is called if the type was not resolved by the getAttribute methodjava.lang.Object
resolveVal(java.lang.Class<?> classType, java.lang.String persistentValue)
This method is called if the type was not resolved by the getValue methodvoid
setAttributes(StorableLogEntry sle)
Storable attributes settervoid
setAttributes(java.util.Map<java.lang.String,java.lang.String> attributes)
Storable attributes settervoid
setCdate(java.util.Date v)
Set the value of cdate.void
setDdate(java.util.Date ddate)
Sets the delete date of this storable.void
setId(java.lang.String v)
Set the value of id.void
setMdate(java.util.Date v)
Set the value of mdate.void
setStore(Store v)
Set the value of store.java.lang.String
toXml()
-
-
-
Field Detail
-
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:
hashCode
in 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:
setAttributes
in 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:
getAttributes
in 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:
getAttribute
in 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:
resolveAtt
in 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:
resolveVal
in 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:Storable
Reset internal caches (like isStoredCache for example)- Specified by:
resetInternalCaches
in interfaceStorable
-
compareTo
public int compareTo(BasicStorable other)
- Specified by:
compareTo
in interfacejava.lang.Comparable<BasicStorable>
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in 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.
-
-