Package com.jalios.jstore
Class StampTable
- java.lang.Object
-
- com.jalios.jstore.StampTable
-
- All Implemented Interfaces:
java.lang.Cloneable
public class StampTable extends java.lang.Object implements java.lang.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.- Author:
- Olivier Dedieu
-
-
Constructor Summary
Constructors Constructor Description StampTable()
StampTable(Stamp... stamps)
StampTable(StampTable other)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.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(java.lang.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.Stamp
getGreatestBehindStamp(Stamp stamp)
java.util.Map<java.lang.String,Stamp>
getMap()
Stamp
getMaxStamp()
Returns the highest stamp contains in this StampTableStamp
getMinStamp()
Returns the smallest stamp contains in this StampTableStampTable
getMinTable(StampTable st)
Build a new StampTable for this one and the given one.Stamp
getRealStamp(java.lang.String urid)
Returns the stamp to which this StampTable maps the specified urid.Stamp
getStamp(java.lang.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, java.lang.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, java.lang.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 StampTablejava.lang.String
toString()
-
-
-
Constructor Detail
-
StampTable
public StampTable()
-
StampTable
public StampTable(StampTable other)
-
StampTable
public StampTable(Stamp... stamps)
-
-
Method Detail
-
getMap
public java.util.Map<java.lang.String,Stamp> getMap()
- Returns:
- the map (urid, stamp)
- Since:
- jcms-4.1
-
clone
public java.lang.Object clone()
- Overrides:
clone
in classjava.lang.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(java.lang.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(java.lang.String urid)
Returns the stamp 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.- Returns:
- the stamp to which this StampTable maps the specified urid
- 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(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.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 comparedisStrict
- 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, java.lang.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 comparedisStrict
- true if strict comparisonuridToIgnore
- 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 comparedisStrict
- 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, java.lang.String uridToIgnore)
Checks if this StampTable is lesser than the given one.- Parameters:
other
- the other table to be comparedisStrict
- true if strict comparisonuridToIgnore
- 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 comparedisStrict
- 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 comparedisStrict
- 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 comparedisStrict
- 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 comparedisStrict
- 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 withuseRealStamp
- 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 java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-