Package org.jboss.util
Class Counter
- java.lang.Object
-
- org.jboss.util.Counter
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
- Direct Known Subclasses:
Counter.Wrapper
public class Counter extends java.lang.Object implements java.io.Serializable, java.lang.Cloneable
An integer counter class.- Version:
- $Revision$
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
Counter.Wrapper
Base wrapper class for other wrappers.
-
Field Summary
Fields Modifier and Type Field Description private int
count
The current countprivate static long
serialVersionUID
The serialVersionUID
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
Return a cloned copy of this object.int
decrement()
Decrement the counter.boolean
equals(java.lang.Object obj)
Check if the given object is equal to this.int
getCount()
Return the current value of the counter.int
increment()
Increment the counter.static Counter
makeDirectional(Counter counter, boolean increasing)
Returns a directional counter.static Counter
makeSynchronized(Counter counter)
Return a synchronized counter.void
reset()
Reset the counter to zero.java.lang.String
toString()
Return a string representation of this.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
The serialVersionUID- See Also:
- Constant Field Values
-
count
private int count
The current count
-
-
Method Detail
-
increment
public int increment()
Increment the counter. (Optional operation)- Returns:
- The incremented value of the counter.
-
decrement
public int decrement()
Decrement the counter. (Optional operation)- Returns:
- The decremented value of the counter.
-
getCount
public int 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.- Overrides:
equals
in classjava.lang.Object
- 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.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of this.
-
clone
public java.lang.Object clone()
Return a cloned copy of this object.- Overrides:
clone
in classjava.lang.Object
- Returns:
- A cloned copy of this object.
-
makeSynchronized
public static Counter makeSynchronized(Counter counter)
Return a synchronized counter.- Parameters:
counter
- Counter to synchronize.- Returns:
- Synchronized counter.
-
-