Skip to content

Commit bfc75fe

Browse files
committed
#44 added JBBPArraySizeLimiter into JBBPBitInputStream
1 parent 97ad0eb commit bfc75fe

File tree

4 files changed

+696
-124
lines changed

4 files changed

+696
-124
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.igormaznitsa.jbbp.exceptions;
2+
3+
/**
4+
* Exception thrown if reached limit of items for whole stream array.
5+
*
6+
* @since 2.1.0
7+
*/
8+
public class JBBPReachedArraySizeLimitException extends JBBPIOException {
9+
10+
private final int readSize;
11+
private final int limitSize;
12+
13+
public JBBPReachedArraySizeLimitException(final String message, final int readSize,
14+
final int limitSize) {
15+
super(message);
16+
this.readSize = readSize;
17+
this.limitSize = limitSize;
18+
}
19+
20+
public int getReadSize() {
21+
return this.readSize;
22+
}
23+
24+
public int getLimitSize() {
25+
return this.limitSize;
26+
}
27+
28+
@Override
29+
public String toString() {
30+
return JBBPReachedArraySizeLimitException.class.getSimpleName() + '{' +
31+
"readSize=" + this.readSize +
32+
", limitSize=" + this.limitSize +
33+
'}';
34+
}
35+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.igormaznitsa.jbbp.io;
2+
3+
/**
4+
* Interface describing an object which provides limit to read array items.
5+
*
6+
* @since 2.1.0
7+
*/
8+
@FunctionalInterface
9+
public interface JBBPArraySizeLimiter {
10+
/**
11+
* Get allowed size of array to read.
12+
*
13+
* @return 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.
14+
*/
15+
int getArrayItemsLimit();
16+
}

0 commit comments

Comments
 (0)