org.jboss.util
Class LongCounter

java.lang.Object
  extended byorg.jboss.util.LongCounter
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class LongCounter
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

A long integer counter class.

See Also:
Serialized Form

Constructor Summary
LongCounter()
          Construct a LongCounter.
LongCounter(long count)
          Construct a LongCounter with a starting value.
 
Method Summary
 java.lang.Object clone()
          Return a cloned copy of this object.
 long decrement()
          Decrement the counter.
 boolean equals(java.lang.Object obj)
          Check if the given object is equal to this.
 long getCount()
          Return the current value of the counter.
 long increment()
          Increment the counter.
static LongCounter (src) makeDirectional(LongCounter (src)  counter, boolean increasing)
          Returns a directional counter.
static LongCounter (src) makeSynchronized(LongCounter (src)  counter)
          Return a synchronized counter.
 void reset()
          Reset the counter to zero.
 java.lang.String toString()
          Return a string representation of this.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LongCounter

public LongCounter(long count)
Construct a LongCounter with a starting value.

Parameters:
count - Starting value for counter.

LongCounter

public LongCounter()
Construct a LongCounter.

Method Detail

increment

public long increment()
Increment the counter. (Optional operation)

Returns:
The incremented value of the counter.

decrement

public long decrement()
Decrement the counter. (Optional operation)

Returns:
The decremented value of the counter.

getCount

public long getCount()
Return the current value of the counter.

Returns:
The current value of the counter.

reset

public void reset()
Reset the counter to zero. (Optional operation)


equals

public boolean equals(java.lang.Object obj)
Check if the given object is equal to this.

Parameters:
obj - Object to test equality with.
Returns:
True if object is equal to this.

toString

public java.lang.String toString()
Return a string representation of this.

Returns:
A string representation of this.

clone

public java.lang.Object clone()
Return a cloned copy of this object.

Returns:
A cloned copy of this object.

makeSynchronized

public static LongCounter (src)  makeSynchronized(LongCounter (src)  counter)
Return a synchronized counter.

Parameters:
counter - LongCounter to synchronize.
Returns:
Synchronized counter.

makeDirectional

public static LongCounter (src)  makeDirectional(LongCounter (src)  counter,
                                          boolean increasing)
Returns a directional counter.

Parameters:
counter - LongCounter to make directional.
increasing - True to create an increasing only or false to create a decreasing only.
Returns:
A directional counter.