public class BandwidthChecker extends Object
check(long, boolean)
Constructor and Description |
---|
BandwidthChecker(Bandwidth.Period period,
long maxBytes)
Creates an instance of the bandwidth checker.
|
Modifier and Type | Method and Description |
---|---|
long |
check(long nbBytes,
boolean write)
Check bandwidth limit.
|
long |
getMaxByteCount()
Returns the maximum allowed number of bytes to read/write per period.
|
Bandwidth.Period |
getPeriod()
Returns the bandwidth verification period.
|
String |
toString()
Returns a string representation of the object.
|
void |
update(long nbBytes)
Update bandwidth limit.
|
public BandwidthChecker(Bandwidth.Period period, long maxBytes)
If the given maxBytes
is negative then there is no bandwidth limit.
period
- the period over which the limit is applied.maxBytes
- the maximum number of bytes allowed.public long check(long nbBytes, boolean write) throws BandwidthLimitException
nbBytes
- the number of bytes to be read/written. The check is skipped is this value is negative or null.write
- a boolean flag indicating whether it is a write operation.BandwidthLimitException
- if the daily bandwidth limit is exceeded.public long getMaxByteCount()
public Bandwidth.Period getPeriod()
public String toString()
Object
toString
method returns a
string that "textually represents" this object. The result should be a concise but informative
representation that is easy for a person to read. It is recommended that all subclasses override
this method.
The toString
method for class Object
returns a string consisting of the name of
the class of which the object is an instance, the at-sign character `@
', and the unsigned
hexadecimal representation of the hash code of the object. In other words, this method returns a
string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
public void update(long nbBytes)
nbBytes
- the number of bytes actually read/written. The update is skipped is this value is negative or null.