public class BooleanCounter extends java.lang.Object implements java.beans.PropertyChangeListener, Named
Listens for boolean PropertyChangeEvent and counts number of true and number of false values. It can be used to calculate the proportion of true (or false) properties as a proportion of the total number, or to calculate the number true/number false or number false/number true.
Like SimpleStats, this listens for a single property name.
Modifier and Type | Field and Description |
---|---|
protected int |
numberFalse |
protected int |
numberTrue |
private java.lang.String |
propertyName |
Constructor and Description |
---|
BooleanCounter(BooleanCounter counter)
Copy constructor
|
BooleanCounter(java.lang.String propName)
Instantiate a BooleanCounter listening to given property.
|
Modifier and Type | Method and Description |
---|---|
double |
getFalseOverTrue() |
java.lang.String |
getName() |
int |
getNumberFalse() |
int |
getNumberTrue() |
double |
getPercentFalse() |
double |
getPercentTrue() |
double |
getTrueOverFalse() |
void |
propertyChange(java.beans.PropertyChangeEvent e)
If propertyName is same as one we are listening to and the type
is a Boolean, update the appropriate counter.
|
void |
reset()
Clear counters
|
void |
setName(java.lang.String name) |
java.lang.String |
stateString() |
java.lang.String |
toString() |
private java.lang.String propertyName
protected int numberTrue
protected int numberFalse
public BooleanCounter(java.lang.String propName)
propName
- Name of property to listen forpublic BooleanCounter(BooleanCounter counter)
counter
- BooleanCounter we are copyingpublic void reset()
public void propertyChange(java.beans.PropertyChangeEvent e)
propertyChange
in interface java.beans.PropertyChangeListener
e
- Heard Eventpublic int getNumberTrue()
public int getNumberFalse()
public double getPercentTrue()
public double getPercentFalse()
public double getTrueOverFalse()
public double getFalseOverTrue()
public java.lang.String getName()
public void setName(java.lang.String name)
public java.lang.String stateString()
public java.lang.String toString()
toString
in class java.lang.Object