1 10 11 package org.mule.util.counters.impl; 12 13 import org.mule.util.counters.Counter; 14 import org.mule.util.counters.CounterFactory.Type; 15 16 import java.util.ArrayList ; 17 import java.util.Iterator ; 18 19 23 public abstract class AbstractCounter implements Counter 24 { 25 26 private Type type; 27 private String name; 28 private ArrayList aggregates = null; 29 30 public AbstractCounter(String name, Type type) 31 { 32 this.name = name; 33 this.type = type; 34 } 35 36 public Type getType() 37 { 38 return this.type; 39 } 40 41 public String getName() 42 { 43 return this.name; 44 } 45 46 public abstract double increment(); 47 48 public abstract double incrementBy(double value); 49 50 public abstract double decrement(); 51 52 public abstract void setRawValue(double value); 53 54 public abstract double nextValue(); 55 56 protected void addAggregate(AggregateCounter counter) 57 { 58 if (this.aggregates == null) 59 { 60 this.aggregates = new ArrayList (); 61 } 62 this.aggregates.add(counter); 63 } 64 65 protected void propagate() 66 { 67 if (this.aggregates != null) 68 { 69 Iterator it = this.aggregates.iterator(); 70 while (it.hasNext()) 71 { 72 AggregateCounter agg = (AggregateCounter)it.next(); 73 agg.compute(); 74 } 75 } 76 } 77 78 } 79 | Popular Tags |