Interface JBBPArraySizeLimiter

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface JBBPArraySizeLimiter
Interface describing an object which provides limit to read array items.
Since:
2.1.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Read arrays without limits.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Get allowed size of array to read.
    static boolean
    Check number of read items for whole stream array and return flag if read should be stopped or throw exception if required.
  • Field Details

    • NO_LIMIT_FOR_ARRAY_SIZE

      static final JBBPArraySizeLimiter NO_LIMIT_FOR_ARRAY_SIZE
      Read arrays without limits.
  • Method Details

    • isBreakReadWholeStream

      static boolean isBreakReadWholeStream(int readItems, JBBPArraySizeLimiter limiter)
      Check number of read items for whole stream array and return flag if read should be stopped or throw exception if required.
      Parameters:
      readItems - number of currently read array items
      limiter - limiter provides number of allowed items, must not be null
      Returns:
      true if read must be stopped immediately, false otherwise
      Throws:
      JBBPReachedArraySizeLimitException - it will be thrown if reach of limit is not allowed
    • getArrayItemsLimit

      int getArrayItemsLimit()
      Get allowed size of array to read.
      Returns:
      0 means no limit, positive value means allowed number of items with exception throwing if read more items, negative value means number of read values and stop read if exceeded.