com.jalios.jstore
Class BasicStorable

java.lang.Object
  extended by com.jalios.jstore.BasicStorable
All Implemented Interfaces:
Storable, Cloneable, Comparable<BasicStorable>
Direct Known Subclasses:
Data, Test

public class BasicStorable
extends Object
implements Storable, Comparable<BasicStorable>, 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: 36529 $
Author:
Olivier Dedieu

Nested Class Summary
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).
 
Field Summary
protected  Date cdate
           
protected  Date ddate
           
protected  String id
           
protected  Date mdate
           
static String REVISION
           
protected  Store store
           
 
Constructor Summary
BasicStorable()
          Creates a new BasicStorable
BasicStorable(BasicStorable other)
          Creates a new BasicStorable by cloning
 
Method Summary
 void clearId()
          Clear the ID of this storable.
 Object clone()
           
 int compareTo(BasicStorable other)
           
 boolean equals(Object obj)
           
 String getAttribute(Object attVal)
          Returns a persistent representation of an attribute from its name
 Map<String,String> getAttributes()
          Returns a map containing all the attributs of this Storable
 Date getCdate()
          Get the value of cdate.
static
<T extends Storable>
Comparator<T>
getCdateComparator()
           
 Date getDdate()
          Returns the delete date of this storable.
 String getId()
          Get the value of id.
static
<T extends Storable>
Comparator<T>
getIdComparator()
           
 Date getMdate()
          Get the value of mdate.
static
<T extends Storable>
Comparator<T>
getMdateComparator()
           
 Store getStore()
          Get the value of store.
 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 updated
 int 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.
 String resolveAtt(Object attVal)
          This method is called if the type was not resolved by the getAttribute method
 Object resolveVal(Class<?> classType, String persistentValue)
          This method is called if the type was not resolved by the getValue method
 void setAttributes(Map<String,String> attributes)
          Storable attributes setter
 void setCdate(Date v)
          Set the value of cdate.
 void setDdate(Date ddate)
          Sets the delete date of this storable.
 void setId(String v)
          Set the value of id.
 void setMdate(Date v)
          Set the value of mdate.
 void setStore(Store v)
          Set the value of store.
 String toXml()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values

cdate

protected Date cdate

mdate

protected Date mdate

id

protected transient String id

store

protected transient Store store

ddate

protected transient Date ddate
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 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 class Object
Returns:
int HashCode of the storable

getIdComparator

public static <T extends Storable> Comparator<T> getIdComparator()

getCdateComparator

public static <T extends Storable> Comparator<T> getCdateComparator()

getMdateComparator

public static <T extends Storable> Comparator<T> getMdateComparator()

setAttributes

public void setAttributes(Map<String,String> attributes)
Storable attributes setter

Specified by:
setAttributes in interface Storable
Parameters:
attributes - the attributes to set:
Key=AttName(String) Value=persistent representation(String)

getAttributes

public Map<String,String> getAttributes()
Returns a map containing all the attributs of this Storable

Specified by:
getAttributes in interface Storable
Returns:
the attributes of the storable with the mapping: Key=Name(String) Value=persistent representation(String)

getAttribute

public String getAttribute(Object attVal)
Returns a persistent representation of an attribute from its name

Specified by:
getAttribute in interface Storable
Parameters:
attVal - the attribute value
Returns:
the persistent representation of the attribute

resolveAtt

public String resolveAtt(Object attVal)
This method is called if the type was not resolved by the getAttribute method

Specified by:
resolveAtt in interface Storable
Parameters:
attVal - the attribute value
Returns:
the persistent representation of the attribute

resolveVal

public Object resolveVal(Class<?> classType,
                         String persistentValue)
This method is called if the type was not resolved by the getValue method

Specified by:
resolveVal in interface Storable
Parameters:
classType - the class type
persistentValue - the persistent value
Returns:
the object from its class type and persistent value

clone

public Object clone()
Specified by:
clone in interface Storable
Overrides:
clone in class Object

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 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

compareTo

public int compareTo(BasicStorable other)
Specified by:
compareTo in interface Comparable<BasicStorable>

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

getId

public String getId()
Get the value of id.

Specified by:
getId in interface Storable
Returns:
Value of id.

setId

public void setId(String v)
Set the value of id.

Specified by:
setId in interface Storable
Parameters:
v - Value to assign to id.

getStore

public Store getStore()
Get the value of store.

Specified by:
getStore in interface Storable
Returns:
Value of store.

setStore

public void setStore(Store v)
Set the value of store.

Specified by:
setStore in interface Storable
Parameters:
v - Value to assign to store.

getCdate

public Date getCdate()
Get the value of cdate.

Specified by:
getCdate in interface Storable
Returns:
Value of cdate.

setCdate

public void setCdate(Date v)
Set the value of cdate.

Specified by:
setCdate in interface Storable
Parameters:
v - Value to assign to cdate.

getMdate

public Date getMdate()
Get the value of mdate.

Specified by:
getMdate in interface Storable
Returns:
Value of mdate.

setMdate

public void setMdate(Date v)
Set the value of mdate.

Specified by:
setMdate in interface Storable
Parameters:
v - Value to assign to mdate.

getDdate

public Date getDdate()
Returns the delete date of this storable.

Specified by:
getDdate in interface Storable
Returns:
the delete date of this storable.
Since:
jcms-5.5.0

setDdate

public void setDdate(Date ddate)
Sets the delete date of this storable.

Specified by:
setDdate in interface Storable
Parameters:
ddate -
Since:
jcms-5.5.0


Copyright © 2001-2010 Jalios SA. All Rights Reserved.