Package net.sf.eBus.util
Class IndexCache.Index
- java.lang.Object
-
- net.sf.eBus.util.IndexCache.Index
-
- Enclosing class:
- IndexCache
public static final class IndexCache.Index extends Object
Tracks the individual index parameters and its location within the cache file.Indexinstances are accessed viaIndexCache.getIndex(String). This index is incremented by the methodnextIndex(). This index can be reset to its initial value by the methodresetIndex().
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longcurrentIndex()Returns the current cached index.voidcurrentIndex(long index)Sets the current index to the given value.booleandoesResetUponFinalIndex()Returnstrueif the cache automatically resets to the initial index once the final index is reached.longfinalIndex()Returns the maximum cached index.longincrement()Returns the increment used to obtain the next cached index.longinitialIndex()Returns the initial cache index.Stringname()Returns the index name.longnextIndex()Returns the current index value.longresetIndex()Resets the current index to the initial value and returns the new current index.StringtoString()Returns the textual representation of this index.
-
-
-
Method Detail
-
name
public String name()
Returns the index name.- Returns:
- the index name.
-
initialIndex
public long initialIndex()
Returns the initial cache index.- Returns:
- initial cache index.
-
increment
public long increment()
Returns the increment used to obtain the next cached index.- Returns:
- index increment.
-
finalIndex
public long finalIndex()
Returns the maximum cached index.- Returns:
- maximum cached index.
-
currentIndex
public long currentIndex()
Returns the current cached index.- Returns:
- current cached index.
-
doesResetUponFinalIndex
public boolean doesResetUponFinalIndex()
Returnstrueif the cache automatically resets to the initial index once the final index is reached.- Returns:
trueif the cache automatically resets to the initial index.
-
nextIndex
public long nextIndex()
Returns the current index value. If the current index value exceeds the final index value and if the "reset upon final index" flag istrue, then the initial index value is returned. If the flag isfalse, anIndexOutOfBoundsExceptionis thrown. Otherwise the current index is incremented prior to returning but this incremented value is not returned.- Returns:
- the current index value.
- Throws:
IndexOutOfBoundsException- if the incremented index exceeds the final index value and the index does not reset back to the initial value.
-
currentIndex
public void currentIndex(long index)
Sets the current index to the given value.- Parameters:
index- the new current index.- Throws:
IllegalArgumentException- ifindexis not between the index initial and final values.
-
resetIndex
public long resetIndex()
Resets the current index to the initial value and returns the new current index.- Returns:
- the newly reset current index.
-
-