com.karmasphere.share.persist
Class PersistentContainer<T extends PersistentRecord>

java.lang.Object
  extended by com.karmasphere.share.persist.Persistent
      extended by com.karmasphere.share.persist.PersistentContainer<T>
Direct Known Subclasses:
Feed

public abstract class PersistentContainer<T extends PersistentRecord>
extends Persistent

A persistent container.

A container "contains" a set of PersistentRecords of type T. A container may be uniquely identified on a node by its type and name. hashCode() and equals(Object) therefore consider only the advert type and keyname.

Each container has a version and delta number. Modifications to either the container metadata or the records will cause an increment of the delta number. Periodically, the container will be committed, which causes the version to be incremented and the delta to be reset.

Each record in the container may be uniquely identified by its container and its PersistentRecord.getPersistenceKey().


Constructor Summary
PersistentContainer(String keyname, int version, int delta)
           
 
Method Summary
 boolean equals(Object o)
           
abstract  String getAdvertType()
          Returns the 'advert type' for this container class.
 int getDelta()
          Returns the delta number of this container.
 String getKeyname()
          Returns the keyname of this container.
 int getVersion()
          Returns the version number of this container.
 int hashCode()
           
 int nextDelta()
          Atomically increments the delta number of this container.
 int nextVersion()
          Atomically increments the version number of this container.
 void setDelta(int delta)
          Sets the delta number of this container.
 void setKeyname(String keyname)
          Sets the keyname of this container.
 void setVersion(int version)
          Sets the version number of this container.
 String toString()
          Returns a simple String representation of this Persistent.
protected  void toStringDetails(StringBuilder buf)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PersistentContainer

public PersistentContainer(String keyname,
                           int version,
                           int delta)
Method Detail

getAdvertType

public abstract String getAdvertType()
Returns the 'advert type' for this container class. This must be a string of lowercase letters without spaces or punctuation, suitable for use as a filename component. The type and the keyname uniquely identify the container.


setKeyname

public void setKeyname(String keyname)
Sets the keyname of this container. The type and the keyname uniquely identify the container.

See Also:
getAdvertType(), getKeyname()

getKeyname

public String getKeyname()
Returns the keyname of this container. The type and the keyname uniquely identify the container.

See Also:
getAdvertType(), setKeyname(String)

setVersion

public void setVersion(int version)
Sets the version number of this container. This method also resets the delta to zero. This method is synchronized.


getVersion

public int getVersion()
Returns the version number of this container.


nextVersion

public int nextVersion()
Atomically increments the version number of this container. This method also resets the delta to zero. This method is synchronized.


setDelta

public void setDelta(int delta)
Sets the delta number of this container.


getDelta

public int getDelta()
Returns the delta number of this container.


nextDelta

public int nextDelta()
Atomically increments the delta number of this container.


hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

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

toStringDetails

protected void toStringDetails(StringBuilder buf)

toString

public String toString()
Description copied from class: Persistent
Returns a simple String representation of this Persistent.

Overrides:
toString in class Persistent


Copyright © 2004-2005 Karamsphere. All Rights Reserved.