Package opennlp.tools.util
Class ResourceInstaller.Budget
java.lang.Object
opennlp.tools.util.ResourceInstaller.Budget
- Enclosing class:
ResourceInstaller
A unit budget, counting bytes or archive entries:
spend(long) accumulates
spent units and fails once the limit is crossed.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
limit
private final long limit -
message
-
used
private long used
-
-
Constructor Details
-
Budget
Budget(long limit, String message) Creates a budget that has spent zero units.- Parameters:
limit- The largest total number of units accepted.message- The failure message raised when the limit is crossed.
-
-
Method Details
-
limit
long limit()Returns the maximum number of units accepted.- Returns:
- the maximum number of units accepted
-
spend
Charges the given number of units against the budget.- Parameters:
units- The number of units to charge.- Throws:
IOException- Thrown if the total charged units exceed the limit.
-