net.lucidviews.util
Class Counter

java.lang.Object
  extended by java.lang.Number
      extended by net.lucidviews.util.VariableNumber
          extended by net.lucidviews.util.VariableLong
              extended by net.lucidviews.util.Counter
All Implemented Interfaces:
Serializable

public class Counter
extends VariableLong

A number object used for counting.

Since:
1.1
Version:
$Revision: 1.1 $
Author:
Stephen Battey
See Also:
VariableLong, Serialized Form

Constructor Summary
Counter()
          Create a new counter.
Counter(long value)
          Create a new counter with a given initial value.
Counter(Number value)
          Create a new counter with a given initial value.
 
Method Summary
 void decrement()
          Decrement the value of this counter.
 void increment()
          Increment the value of this counter.
 
Methods inherited from class net.lucidviews.util.VariableLong
doubleValue, equals, floatValue, hashCode, intValue, longValue, setValueInternal, setValueInternal, setValueInternal, setValueInternal, toString
 
Methods inherited from class net.lucidviews.util.VariableNumber
isSecure, secure, setValue, setValue, setValue, setValue, setValue, setValue, setValueInternal, setValueInternal, verifyNotSecure
 
Methods inherited from class java.lang.Number
byteValue, shortValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Counter

public Counter()
Create a new counter.
The counter is initialised with a zero value.


Counter

public Counter(long value)
Create a new counter with a given initial value.

Parameters:
value - the initial value

Counter

public Counter(Number value)
Create a new counter with a given initial value.

Parameters:
value - the initial value
Throws:
NullPointerException - if the initial value is null
Method Detail

increment

public void increment()
Increment the value of this counter.
If the number is secure an exception will be thrown.

Throws:
IllegalStateException - if this number is no longer in a variable state
See Also:
VariableNumber.secure, VariableNumber.secure()

decrement

public void decrement()
Decrement the value of this counter.
If the number is secure an exception will be thrown.

Throws:
IllegalStateException - if this number is no longer in a variable state
See Also:
VariableNumber.secure, VariableNumber.secure()