net.sf.jabb.util.stat
Class FrequencyCounter

java.lang.Object
  extended by net.sf.jabb.util.stat.FrequencyCounter
Direct Known Subclasses:
BasicFrequencyCounter, PackagedFrequencyCounter

public abstract class FrequencyCounter
extends Object

频次计数器的基类,它实现了一些公共的方法,并留出具体实现方法给子类去实现。

Author:
Zhengmao HU (James)

Constructor Summary
FrequencyCounter()
           
 
Method Summary
 void count()
          记录在当前时间发生了一次
 void count(Date when)
          记录在某个时间发生了一次
 void count(Date when, int times)
          记录在某个时间发生了几次
 void count(int times)
          记录在当前时间发生了几次
 void count(long when)
          记录在某个时间发生了一次
abstract  void count(long when, int times)
          记录在某时刻发生了多少次
 long getCount(Date when)
          获得某个时间的计数
 long getCount(Date fromWhen, Date toWhen)
          获得某时间区间的计数
 long getCount(Date fromWhen, Date toWhen, boolean fromInclusive, boolean toInclusive)
          获得某时间区间的计数
 long getCount(Date toWhen, long period, TimeUnit unit)
          获得某时间区间的计数
abstract  long getCount(long when)
          获得某时刻的统计数
 long getCount(long fromWhen, long toWhen)
          获得某时间区间的计数
abstract  long getCount(long fromWhen, long toWhen, boolean fromInclusive, boolean toInclusive)
          获得在某时段内的总统计数
 long getCount(long toWhen, long period, TimeUnit unit)
          获得某时间区间的计数
 long getCount(long period, TimeUnit unit)
          获得最近一段时间的计数
 void purge(Date tillWhen)
          删除掉早于一定时间的记录
 void purge(Date baseTime, long periodBefore, TimeUnit unit)
          删除掉早于一定时间的记录
abstract  void purge(long tillWhen)
          清除过旧的历史数据
 void purge(long baseTime, long periodBefore, TimeUnit unit)
          删除掉早于一定时间的记录
 void purge(long periodBefore, TimeUnit unit)
          删除掉早于一定时间的记录
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FrequencyCounter

public FrequencyCounter()
Method Detail

count

public abstract void count(long when,
                           int times)
记录在某时刻发生了多少次

Parameters:
when - 发生的时刻
times - 发生的次数

getCount

public abstract long getCount(long when)
获得某时刻的统计数

Parameters:
when - 时刻
Returns:
统计数

getCount

public abstract long getCount(long fromWhen,
                              long toWhen,
                              boolean fromInclusive,
                              boolean toInclusive)
获得在某时段内的总统计数

Parameters:
fromWhen - 开始时间
toWhen - 结束时间
fromInclusive - 是否包含开始时间
toInclusive - 是否包含结束时间
Returns:
统计数

purge

public abstract void purge(long tillWhen)
清除过旧的历史数据

Parameters:
tillWhen - 清除到哪个时间点为止

count

public void count(Date when,
                  int times)
记录在某个时间发生了几次

Parameters:
when - 发生时间
times - 发生次数

count

public void count(long when)
记录在某个时间发生了一次

Parameters:
when - 发生的时间

count

public void count()
记录在当前时间发生了一次


count

public void count(int times)
记录在当前时间发生了几次

Parameters:
times - 发生的次数

count

public void count(Date when)
记录在某个时间发生了一次

Parameters:
when - 发生的时间

getCount

public long getCount(Date when)
获得某个时间的计数

Parameters:
when - 时刻
Returns:
统计数

getCount

public long getCount(long fromWhen,
                     long toWhen)
获得某时间区间的计数

Parameters:
fromWhen - 开始时间
toWhen - 结束时间
Returns:
统计数

getCount

public long getCount(Date fromWhen,
                     Date toWhen,
                     boolean fromInclusive,
                     boolean toInclusive)
获得某时间区间的计数

Parameters:
fromWhen - 开始时间
toWhen - 结束时间
fromInclusive - 是否包含开始时间
toInclusive - 是否包含结束时间
Returns:
统计数

getCount

public long getCount(Date fromWhen,
                     Date toWhen)
获得某时间区间的计数

Parameters:
fromWhen - 开始时间
toWhen - 结束时间
Returns:
统计数

getCount

public long getCount(long toWhen,
                     long period,
                     TimeUnit unit)
获得某时间区间的计数

Parameters:
toWhen - 到某个时间为止
period - 向前推多少时间
unit - 向前推多少时间的单位
Returns:
统计数

getCount

public long getCount(Date toWhen,
                     long period,
                     TimeUnit unit)
获得某时间区间的计数

Parameters:
toWhen - 到某个时间为止
period - 向前推多少时间
unit - 向前推多少时间的单位
Returns:
统计数

getCount

public long getCount(long period,
                     TimeUnit unit)
获得最近一段时间的计数

Parameters:
period - 向前推多少时间
unit - 向前推多少时间的单位
Returns:
统计数

purge

public void purge(Date tillWhen)
删除掉早于一定时间的记录

Parameters:
tillWhen - 清除到哪个时间点为止

purge

public void purge(long baseTime,
                  long periodBefore,
                  TimeUnit unit)
删除掉早于一定时间的记录

Parameters:
baseTime - 从什么时间算起
periodBefore - 多少时间之前的要删掉
unit - 时间单位

purge

public void purge(Date baseTime,
                  long periodBefore,
                  TimeUnit unit)
删除掉早于一定时间的记录

Parameters:
baseTime - 从什么时间算起
periodBefore - 多少时间之前的要删掉
unit - 时间单位

purge

public void purge(long periodBefore,
                  TimeUnit unit)
删除掉早于一定时间的记录

Parameters:
periodBefore - 从现在算起,多少时间之前
unit - 时间单位


Copyright © 2012. All Rights Reserved.