Class ResourceInstaller.Budget

java.lang.Object
opennlp.tools.util.ResourceInstaller.Budget
Enclosing class:
ResourceInstaller

private static final class ResourceInstaller.Budget extends Object
A unit budget, counting bytes or archive entries: spend(long) accumulates spent units and fails once the limit is crossed.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final long
     
    private final String
     
    private long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Budget(long limit, String message)
    Creates a budget that has spent zero units.
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) long
    Returns the maximum number of units accepted.
    (package private) void
    spend(long units)
    Charges the given number of units against the budget.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • limit

      private final long limit
    • message

      private final String 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

      void spend(long units) throws IOException
      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.