QJCC homepage

biz.chitec.quarterback.util
Class ValueHistoryStorage.ValueMark

java.lang.Object
  extended bybiz.chitec.quarterback.util.ValueHistoryStorage.ValueMark
All Implemented Interfaces:
java.io.Serializable
Enclosing class:
ValueHistoryStorage

public static class ValueHistoryStorage.ValueMark
extends java.lang.Object
implements java.io.Serializable

Helper class to store a value at a certain point of time. Values can be either absolute or relative. It is even possible to have absolute and relative values at the same point of time (in which case they are strored in the same ValueMark).

Author:
dh
See Also:
Serialized Form

Field Summary
private  int absvalue
          The absolute value at this point of time.
private  int relvalue
          The relative value at this point of time. 0 if unset.
 
Constructor Summary
ValueHistoryStorage.ValueMark()
          Init as unset, zero value.
ValueHistoryStorage.ValueMark(int value, boolean isabsolute)
          Init with a value, which is interpreted as absolute or relative according to second parameter.
ValueHistoryStorage.ValueMark(int av, int rv)
          Init with a certain absolute and relative value.
 
Method Summary
 int absolutify(int prevrel)
          Absolutify the ValueMark regarding a passed absolute value.
 void cumulateRelative(int cv)
          Store additional relative value.
 boolean equals(java.lang.Object o)
          Absolute and relative value must be equal for success.
 int getAbsolute()
          Return absolute value of this ValueMark.
 int getRelative()
          Return relative value of this ValueMark.
 int relativify(int prevabs)
          Relativify this ValueMark.
 void setAbsolute(int av)
          Set new absolute value.
 java.lang.String toString()
          For debug purposes.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

absvalue

private int absvalue
The absolute value at this point of time. Integer.MIN_VALUE if unset.


relvalue

private int relvalue
The relative value at this point of time. 0 if unset.

Constructor Detail

ValueHistoryStorage.ValueMark

public ValueHistoryStorage.ValueMark()
Init as unset, zero value.


ValueHistoryStorage.ValueMark

public ValueHistoryStorage.ValueMark(int av,
                                     int rv)
Init with a certain absolute and relative value.

Parameters:
av - Description of the Parameter
rv - Description of the Parameter

ValueHistoryStorage.ValueMark

public ValueHistoryStorage.ValueMark(int value,
                                     boolean isabsolute)
Init with a value, which is interpreted as absolute or relative according to second parameter.

Parameters:
value - Description of the Parameter
isabsolute - Description of the Parameter
Method Detail

setAbsolute

public void setAbsolute(int av)
Set new absolute value. The old absolute value is overwritten.

Parameters:
av - The new absolute value

cumulateRelative

public void cumulateRelative(int cv)
Store additional relative value. As semantics of relative values allow immideate cumulation of two relative values at the same point of time, this is done.

Parameters:
cv - Description of the Parameter

getAbsolute

public int getAbsolute()
Return absolute value of this ValueMark.

Returns:
The absolute value

getRelative

public int getRelative()
Return relative value of this ValueMark.

Returns:
The relative value

absolutify

public int absolutify(int prevrel)
Absolutify the ValueMark regarding a passed absolute value. Turning the data into an absolute value needs the absolute value which is valid directly before this ValueMark. That one is cumulated with the relative value of this ValueMark, the result is stored in the absolute value field and returned as new absolute value. Note that this works only if the absolute value of this() is unset.

Parameters:
prevrel - Description of the Parameter
Returns:
Description of the Return Value

relativify

public int relativify(int prevabs)
Relativify this ValueMark. Gets the absolute value valid before. If this has an absolute value, compute the difference and cumulate it to the relative value. This method works even if a relative value already exists. It simply ensures that no absolute values are set any more after executing.

Parameters:
prevabs - Description of the Parameter
Returns:
Description of the Return Value

equals

public boolean equals(java.lang.Object o)
Absolute and relative value must be equal for success.

Parameters:
o - Description of the Parameter
Returns:
Description of the Return Value

toString

public java.lang.String toString()
For debug purposes.

Returns:
Description of the Return Value

QJCC homepage