com.jalios.jstore
Class StampTable

java.lang.Object
  extended by com.jalios.jstore.StampTable
All Implemented Interfaces:
Cloneable

public class StampTable
extends Object
implements Cloneable

This class contains a set of stamp (one per urid). It is typically used to maintain progress tables. A progress table represents the advancement of a replica according the other replica of the group.

Version:
$Revision: 28011 $
Author:
Olivier Dedieu

Field Summary
static String REVISION
           
 
Constructor Summary
StampTable()
           
StampTable(StampTable other)
           
 
Method Summary
 Object clone()
           
 int compareLogEntry(LogEntry logEntry)
          Compares the given stamp of the logEntry with the ones in the table.
 int compareStamp(Stamp stamp)
          Compares the given stamp with the ones in the table.
 boolean equals(Object obj)
           
 Stamp getBehindStamp(StampTable st)
          Gets the most behind stamp of this StampTable according the given StampTable.
 Stamp getBehindStamp(StampTable st, boolean useRealStamp)
          Gets the most behind stamp of this StampTable according the given StampTable.
 Map<String,Stamp> getMap()
           
 Stamp getMaxStamp()
          Returns the highest stamp contains in this StampTable
 Stamp getMinStamp()
          Returns the smallest stamp contains in this StampTable
 StampTable getMinTable(StampTable st)
          Build a new StampTable for this one and the given one.
 Stamp getRealStamp(String urid)
          Returns the stamps to which this StampTable maps the specified urid.
 Stamp getStamp(String urid)
          Returns the stamps to which this StampTable maps the specified urid.
 boolean isGreaterThan(Stamp stamp, boolean isStrict)
          Check if this StampTable contains at least one stamp greater than the given stamp.
 boolean isGreaterThan(StampTable other, boolean isStrict)
          Checks if this StampTable is greater than the given one.
 boolean isGreaterThan(StampTable other, boolean isStrict, String uridToIgnore)
          Checks if this StampTable is greater than the given one.
 boolean isGreaterThanStamp(Stamp other, boolean isStrict)
          Checks if this StampTable contains a stamp greater than the given one.
 boolean isLesserThan(Stamp stamp, boolean isStrict)
          Check if all the stamps of this StampTable are lesser than the given stamp.
 boolean isLesserThan(StampTable other, boolean isStrict)
          Checks if this StampTable is lesser than the given one.
 boolean isLesserThan(StampTable other, boolean isStrict, String uridToIgnore)
          Checks if this StampTable is lesser than the given one.
 boolean isLesserThanStamp(Stamp other, boolean isStrict)
          Checks if this StampTable contains a stamp lesser than the given one.
 boolean isPartiallyGreaterThan(StampTable other)
          Checks if this StampTable is partially greater than the given one.
 void putStamp(Stamp stamp)
          Puts this stamp in the StampTable
 String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values
Constructor Detail

StampTable

public StampTable()

StampTable

public StampTable(StampTable other)
Method Detail

getMap

public Map<String,Stamp> getMap()
Returns:
the map (urid, stamp)
Since:
jcms-4.1

clone

public Object clone()
Overrides:
clone in class Object
Returns:
the cloned StampTable
Since:
jcms-4.1

putStamp

public void putStamp(Stamp stamp)
Puts this stamp in the StampTable

Parameters:
stamp - the stamp to be added
Since:
jcms-4.1

getStamp

public Stamp getStamp(String urid)
Returns the stamps to which this StampTable maps the specified urid. Returns null if the StampTable contains no mapping for this urid.

Parameters:
urid - urid whose associated stamp is to be returned.
Returns:
the stamp associated to the given urid.
Since:
jcms-4.1

getRealStamp

public Stamp getRealStamp(String urid)
Returns the stamps to which this StampTable maps the specified urid. Returns the zero-stamp (i.e. Stamp(urid, 0)) if the StampTable contains no mapping for this

Parameters:
urid - urid whose associated stamp is to be returned.
Since:
jcms-4.1

compareStamp

public int compareStamp(Stamp stamp)
Compares the given stamp with the ones in the table.

Parameters:
stamp - the stamp to be compared
Returns:
a negative integer, zero, or a positive integer as the stamp of the table is less than, equal to, or greater than the specified stamp.
Since:
jcms-4.1

compareLogEntry

public int compareLogEntry(LogEntry logEntry)
Compares the given stamp of the logEntry with the ones in the table.

Parameters:
logEntry - the logEntry to be compared
Returns:
a negative integer, zero, or a positive integer as the stamp of the table is less than, equal to, or greater than the specified stamp.
Since:
jcms-4.1
See Also:
compareStamp(Stamp)

equals

public boolean equals(Object obj)
Overrides:
equals in class Object
Returns:
true of the given obj is StampTable with exactly the same value as this StampTable
Since:
jcms-4.1

isGreaterThan

public boolean isGreaterThan(StampTable other,
                             boolean isStrict)
Checks if this StampTable is greater than the given one.

Parameters:
other - the other table to be compared
isStrict - true if strict comparison
Returns:
true if this StampTable is greater than the given one
Since:
jcms-4.1
See Also:
isGreaterThan(StampTable,boolean,String)

isGreaterThan

public boolean isGreaterThan(StampTable other,
                             boolean isStrict,
                             String uridToIgnore)
Checks if this StampTable is greater than the given one.
ST1 is greater than ST2 if ST1 not equals to ST2 and foreach urid in ST2, there exists a stamp in ST1 greater or equals than the one in ST2.
ST1 is stricly greater than ST2 if foreach urid in ST2, there exists a stamp in ST1 strictly greater than the one in ST2.

Parameters:
other - the other table to be compared
isStrict - true if strict comparison
uridToIgnore - this urid will be ignored for the comparison (can be null)
Returns:
true if this StampTable is greater than the given one
Since:
jcms-4.1

isLesserThan

public boolean isLesserThan(StampTable other,
                            boolean isStrict)
Checks if this StampTable is lesser than the given one.

Parameters:
other - the other table to be compared
isStrict - true if strict comparison
Returns:
true if this StampTable is lesser than the given one
Since:
jcms-4.1
See Also:
isGreaterThan(StampTable,boolean,String)

isLesserThan

public boolean isLesserThan(StampTable other,
                            boolean isStrict,
                            String uridToIgnore)
Checks if this StampTable is lesser than the given one.

Parameters:
other - the other table to be compared
isStrict - true if strict comparison
uridToIgnore - this urid will be ignored for the comparison (can be null)
Returns:
true if this StampTable is lesser than the given one
Since:
jcms-4.1
See Also:
isGreaterThan(StampTable,boolean,String)

isGreaterThan

public boolean isGreaterThan(Stamp stamp,
                             boolean isStrict)
Check if this StampTable contains at least one stamp greater than the given stamp.

Parameters:
stamp - the stamp to be compared
isStrict - true if strict comparison
Returns:
true if this StampTable contains at least one stamp greater than the given stamp.
Since:
jcms-5.0.0
See Also:
isLesserThan(Stamp,boolean)

isLesserThan

public boolean isLesserThan(Stamp stamp,
                            boolean isStrict)
Check if all the stamps of this StampTable are lesser than the given stamp.

Parameters:
stamp - the stamp to be compared
isStrict - true if strict comparison
Returns:
true if all the stamps of this StampTable are lesser than the given stamp.
Since:
jcms-5.0.0
See Also:
isGreaterThan(Stamp,boolean)

isPartiallyGreaterThan

public boolean isPartiallyGreaterThan(StampTable other)
Checks if this StampTable is partially greater than the given one.
ST1 is partially greater than ST2 if at least one stamp of ST1 is greater than the one in ST2.

Parameters:
other - the other table to be compared
Returns:
true if this StampTable is partially greater than the given one
Since:
jcms-5.0.1

isGreaterThanStamp

public boolean isGreaterThanStamp(Stamp other,
                                  boolean isStrict)
Checks if this StampTable contains a stamp greater than the given one.

Parameters:
other - the stamp to be compared
isStrict - true if strict comparison
Returns:
true if this StampTable contains a stamp greater than the given one.
Since:
jcms-5.0.2
See Also:
isLesserThanStamp(Stamp,boolean)

isLesserThanStamp

public boolean isLesserThanStamp(Stamp other,
                                 boolean isStrict)
Checks if this StampTable contains a stamp lesser than the given one.

Parameters:
other - the stamp to be compared
isStrict - true if strict comparison
Returns:
true if this StampTable contains a stamp lesser than the given one.
Since:
jcms-5.0.2
See Also:
isGreaterThanStamp(Stamp,boolean)

getMinStamp

public Stamp getMinStamp()
Returns the smallest stamp contains in this StampTable

Returns:
the smallest stamp
Since:
jcms-4.1
See Also:
Stamp.min(Stamp,Stamp)

getMaxStamp

public Stamp getMaxStamp()
Returns the highest stamp contains in this StampTable

Returns:
the smallest stamp
Since:
jcms-5.0.5
See Also:
Stamp.max(Stamp,Stamp)

getBehindStamp

public Stamp getBehindStamp(StampTable st)
Gets the most behind stamp of this StampTable according the given StampTable. This stamp may be null if all stamps of the given StampTable are lesser or equals to ones of the this StampTable. May return a fake stamp (urid, 0), if the given StampTable has got a stamp.urid unknown for this StampTable.

Parameters:
st - the StampTable to compare with
Returns:
a most behind stamp.
Since:
jcms-4.1

getBehindStamp

public Stamp getBehindStamp(StampTable st,
                            boolean useRealStamp)
Gets the most behind stamp of this StampTable according the given StampTable. This stamp may be null if all stamps of the given StampTable are lesser or equals to ones of the this StampTable. If useRealStamp is true, missing stamp are considered as fake stamp (urid, 0). So, it may return a fake stamp (urid, 0), if the given StampTable has got a stamp.urid unknown for this StampTable.

Parameters:
st - the StampTable to compare with
useRealStamp - if true, considere missing stamp as (urid, 0)
Returns:
a most behind stamp.
Since:
jcms-4.1

getMinTable

public StampTable getMinTable(StampTable st)
Build a new StampTable for this one and the given one. For each urid contains in these 2 tables, the new StampTable contains the smallest real stamp. If an urid is missing in one the two tables, the zero-stamp is added.

Parameters:
st - the StampTable to used
Returns:
a StampTable
Since:
jcms-4.1
See Also:
getRealStamp(String)

toString

public String toString()
Overrides:
toString in class Object


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