Class 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
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Date cdate  
      protected java.util.Date ddate  
      protected java.lang.String id  
      protected java.lang.Boolean isStoreCache  
      protected java.util.Date mdate  
      static java.lang.String REVISION  
      protected Store store  
    • 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 name
      java.util.Map<java.lang.String,​java.lang.String> getAttributes()
      Returns a map containing all the attributs of this Storable
      java.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 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.
      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 method
      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
      void setAttributes​(StorableLogEntry sle)
      Storable attributes setter
      void setAttributes​(java.util.Map<java.lang.String,​java.lang.String> attributes)
      Storable attributes setter
      void 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()  
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • 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 class java.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 interface Storable
        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 interface Storable
        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 interface Storable
        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 interface Storable
        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 interface Storable
        Parameters:
        classType - the class type
        persistentValue - the persistent value
        Returns:
        the object from its class type and persistent value
      • clone

        public java.lang.Object clone()
        Specified by:
        clone in interface Storable
        Overrides:
        clone in class java.lang.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 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 interface Storable
      • compareTo

        public int compareTo​(BasicStorable other)
        Specified by:
        compareTo in interface java.lang.Comparable<BasicStorable>
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • getId

        public java.lang.String getId()
        Get the value of id.
        Specified by:
        getId in interface Storable
        Returns:
        Value of id.
      • setId

        public void setId​(java.lang.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 java.util.Date getCdate()
        Get the value of cdate.
        Specified by:
        getCdate in interface Storable
        Returns:
        Value of cdate.
      • setCdate

        public void setCdate​(java.util.Date v)
        Set the value of cdate.
        Specified by:
        setCdate in interface Storable
        Parameters:
        v - Value to assign to cdate.
      • getMdate

        public java.util.Date getMdate()
        Get the value of mdate.
        Specified by:
        getMdate in interface Storable
        Returns:
        Value of mdate.
      • setMdate

        public void setMdate​(java.util.Date v)
        Set the value of mdate.
        Specified by:
        setMdate in interface Storable
        Parameters:
        v - Value to assign to mdate.
      • getDdate

        public java.util.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​(java.util.Date ddate)
        Sets the delete date of this storable.
        Specified by:
        setDdate in interface Storable
        Parameters:
        ddate -
        Since:
        jcms-5.5.0