first commit
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package net.sf.jasperreports.engine.fill;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
class DistinctCountHolder {
|
||||
private Set distinctValues = null;
|
||||
|
||||
private Object lastValue = null;
|
||||
|
||||
public DistinctCountHolder() {
|
||||
this.distinctValues = new HashSet();
|
||||
}
|
||||
|
||||
public DistinctCountHolder(Set distinctValues) {
|
||||
this.distinctValues = distinctValues;
|
||||
}
|
||||
|
||||
public DistinctCountHolder(DistinctCountHolder holder, Object lastValue) {
|
||||
this.distinctValues = holder.getDistinctValues();
|
||||
this.lastValue = lastValue;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
this.distinctValues = new HashSet();
|
||||
}
|
||||
|
||||
public Set getDistinctValues() {
|
||||
return this.distinctValues;
|
||||
}
|
||||
|
||||
public Object getLastValue() {
|
||||
return this.lastValue;
|
||||
}
|
||||
|
||||
public void addLastValue() {
|
||||
if (this.lastValue != null)
|
||||
this.distinctValues.add(this.lastValue);
|
||||
this.lastValue = null;
|
||||
}
|
||||
|
||||
public long getCount() {
|
||||
return (this.distinctValues.size() + ((this.lastValue == null || this.distinctValues.contains(this.lastValue)) ? 0 : 1));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user