tot.util
类 FloodControl

java.lang.Object
  继承者 tot.util.FloodControl

public class FloodControl
extends java.lang.Object


方法摘要
static void ensureNotReachMaximum(java.lang.Integer action, java.lang.String strIP)
          This is a utility method to ensure that the action has not reached the mamximum.
static int getActionsPerHour(java.lang.Integer action)
           
static void increaseCount(java.lang.Integer action, java.lang.String strIP)
          Increase the number of action.
static boolean reachMaximum(java.lang.Integer action, java.lang.String strIP)
          Check that an action of an IP has reach the maximum number of allowed times
static void resetActionHistory(java.lang.Integer action, java.lang.String strIP)
          Reset the action history.
static void setOption(java.lang.Integer action, int actionsPerHour)
          To set the mamximum number of actions per hour for an action.
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

方法详细信息

setOption

public static void setOption(java.lang.Integer action,
                             int actionsPerHour)
To set the mamximum number of actions per hour for an action. If the caller does not call this method, the the action has no limit

参数:
action - Integer the action that want to set the option
actionsPerHour - int the maximum number of actions per hour

getActionsPerHour

public static int getActionsPerHour(java.lang.Integer action)

reachMaximum

public static boolean reachMaximum(java.lang.Integer action,
                                   java.lang.String strIP)
Check that an action of an IP has reach the maximum number of allowed times

参数:
action - Integer the action to check
strIP - String the IP to check
返回:
boolean true if it has reached the maximum

ensureNotReachMaximum

public static void ensureNotReachMaximum(java.lang.Integer action,
                                         java.lang.String strIP)
                                  throws FloodException
This is a utility method to ensure that the action has not reached the mamximum. It calls the method reachMaximum and throw an exception if it reached the maximum. A program could use this method to use the default error message, otherwise it has to use reachMaximum

参数:
action - Integer the action to ensure
strIP - String the IP to ensure
抛出:
FloodException - if it reached the maximum
另请参见:
reachMaximum(Integer, String)

increaseCount

public static void increaseCount(java.lang.Integer action,
                                 java.lang.String strIP)
Increase the number of action. This method should be called the the program has done this action. Forget to call this method will void the reachMaximum method.

参数:
action - Integer the action to increase the number of times
strIP - String the IP to increase the number of times

resetActionHistory

public static void resetActionHistory(java.lang.Integer action,
                                      java.lang.String strIP)
Reset the action history. This method is useful in such a case in the login process that after login successfully, the value should be reset. Please note that this is just an example and usually no need to use this method.

参数:
action - Integer
strIP - String