Skip to content

Commit ec3f268

Browse files
author
Gary Gregory
committed
Formatting.
1 parent a931b22 commit ec3f268

1 file changed

Lines changed: 16 additions & 23 deletions

File tree

src/main/java/org/apache/commons/io/input/BoundedReader.java

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,17 @@
2222
import java.io.Reader;
2323

2424
/**
25-
* A reader that imposes a limit to the number of characters that can be read from
26-
* an underlying reader, returning EOF when this limit is reached, regardless of state of
27-
* underlying reader.
25+
* A reader that imposes a limit to the number of characters that can be read from an underlying reader, returning EOF
26+
* when this limit is reached, regardless of state of underlying reader.
2827
*
2928
* <p>
30-
* One use case is to avoid overrunning the readAheadLimit supplied to
31-
* {@link java.io.Reader#mark(int)}, since reading too many characters removes the
32-
* ability to do a successful reset.
29+
* One use case is to avoid overrunning the readAheadLimit supplied to {@link java.io.Reader#mark(int)}, since reading
30+
* too many characters removes the ability to do a successful reset.
3331
* </p>
3432
*
3533
* @since 2.5
3634
*/
37-
public class BoundedReader
38-
extends Reader
39-
{
35+
public class BoundedReader extends Reader {
4036

4137
private static final int INVALID = -1;
4238

@@ -57,7 +53,7 @@ public class BoundedReader
5753
* @param maxCharsFromTargetReader The maximum number of characters that can be read from target
5854
* @throws IOException if mark fails
5955
*/
60-
public BoundedReader( final Reader target, final int maxCharsFromTargetReader ) throws IOException {
56+
public BoundedReader(final Reader target, final int maxCharsFromTargetReader) throws IOException {
6157
this.target = target;
6258
this.maxCharsFromTargetReader = maxCharsFromTargetReader;
6359
}
@@ -87,23 +83,20 @@ public void reset() throws IOException {
8783
/**
8884
* marks the target stream
8985
*
90-
* @param readAheadLimit The number of characters that can be read while
91-
* still retaining the ability to do #reset().
92-
* Note that this parameter is not validated with respect to
93-
* maxCharsFromTargetReader. There is no way to pass
94-
* past maxCharsFromTargetReader, even if this value is
95-
* greater.
86+
* @param readAheadLimit The number of characters that can be read while still retaining the ability to do #reset().
87+
* Note that this parameter is not validated with respect to maxCharsFromTargetReader. There
88+
* is no way to pass past maxCharsFromTargetReader, even if this value is greater.
9689
*
9790
* @throws IOException If an I/O error occurs while calling the underlying reader's mark method
9891
* @see java.io.Reader#mark(int)
9992
*/
10093
@Override
101-
public void mark( final int readAheadLimit ) throws IOException {
94+
public void mark(final int readAheadLimit) throws IOException {
10295
this.readAheadLimit = readAheadLimit - charsRead;
10396

10497
markedAt = charsRead;
10598

106-
target.mark( readAheadLimit );
99+
target.mark(readAheadLimit);
107100
}
108101

109102
/**
@@ -116,11 +109,11 @@ public void mark( final int readAheadLimit ) throws IOException {
116109
@Override
117110
public int read() throws IOException {
118111

119-
if ( charsRead >= maxCharsFromTargetReader ) {
112+
if (charsRead >= maxCharsFromTargetReader) {
120113
return -1;
121114
}
122115

123-
if ( markedAt >= 0 && ( charsRead - markedAt ) >= readAheadLimit ) {
116+
if (markedAt >= 0 && (charsRead - markedAt) >= readAheadLimit) {
124117
return -1;
125118
}
126119
charsRead++;
@@ -138,11 +131,11 @@ public int read() throws IOException {
138131
* @see java.io.Reader#read(char[], int, int)
139132
*/
140133
@Override
141-
public int read( final char[] cbuf, final int off, final int len ) throws IOException {
134+
public int read(final char[] cbuf, final int off, final int len) throws IOException {
142135
int c;
143-
for ( int i = 0; i < len; i++ ) {
136+
for (int i = 0; i < len; i++) {
144137
c = read();
145-
if ( c == -1 ) {
138+
if (c == -1) {
146139
return i == 0 ? -1 : i;
147140
}
148141
cbuf[off + i] = (char) c;

0 commit comments

Comments
 (0)