Skip to content

Commit c6edda8

Browse files
committed
use spaces not tabs
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@1634744 13f79535-47bb-0310-9956-ffa450edef68
1 parent 964a517 commit c6edda8

6 files changed

Lines changed: 381 additions & 366 deletions

File tree

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

Lines changed: 54 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -25,57 +25,61 @@
2525
* A reader that imposes a limit to the number of characters that can be read from
2626
* an underlying reader, returning eof when this limit is reached -regardless of state of
2727
* underlying reader.
28-
*
28+
* <p/>
2929
* One use case is to avoid overrunning the readAheadLimit supplied to
3030
* java.io.Reader#mark(int), since reading too many characters removes the
3131
* ability to do a successful reset.
3232
*
3333
* @since 2.5
3434
*/
3535
public class BoundedReader
36-
extends Reader {
36+
extends Reader
37+
{
3738

3839
private static final int INVALID = -1;
3940

40-
private final Reader target;
41+
private final Reader target;
4142

42-
int charsRead = 0;
43+
int charsRead = 0;
4344

4445
int markedAt = INVALID;
4546

46-
int readAheadLimit; // Internally, this value will never exceed the allowed size
47+
int readAheadLimit; // Internally, this value will never exceed the allowed size
4748

4849
private final int maxCharsFromTargetReader;
4950

5051
/**
5152
* Constructs a bounded reader
52-
* @param target The target stream that will be used
53+
*
54+
* @param target The target stream that will be used
5355
* @param maxCharsFromTargetReader The maximum number of characters that can be read from target
5456
* @throws IOException if mark fails
5557
*/
56-
public BoundedReader( Reader target, int maxCharsFromTargetReader ) throws IOException {
57-
this.target = target;
58+
public BoundedReader( Reader target, int maxCharsFromTargetReader ) throws IOException {
59+
this.target = target;
5860
this.maxCharsFromTargetReader = maxCharsFromTargetReader;
59-
}
61+
}
6062

6163
/**
6264
* Closes the target
65+
*
6366
* @throws IOException
6467
*/
65-
@Override
66-
public void close() throws IOException {
67-
target.close();
68-
}
68+
@Override
69+
public void close() throws IOException {
70+
target.close();
71+
}
6972

7073
/**
7174
* Resets the target to the latest mark, @see java.io.Reader#reset()
75+
*
7276
* @throws IOException
7377
*/
74-
@Override
75-
public void reset() throws IOException {
76-
charsRead = markedAt;
77-
target.reset();
78-
}
78+
@Override
79+
public void reset() throws IOException {
80+
charsRead = markedAt;
81+
target.reset();
82+
}
7983

8084
/**
8185
* marks the target stream, @see java.io.Reader#mark(int).
@@ -87,50 +91,54 @@ public void reset() throws IOException {
8791
* past maxCharsFromTargetReader, even if this value is
8892
* greater.
8993
*/
90-
@Override
91-
public void mark(int readAheadLimit) throws IOException {
92-
this.readAheadLimit = readAheadLimit -charsRead;
94+
@Override
95+
public void mark( int readAheadLimit ) throws IOException {
96+
this.readAheadLimit = readAheadLimit - charsRead;
9397

9498
markedAt = charsRead;
9599

96-
target.mark(readAheadLimit);
97-
}
100+
target.mark( readAheadLimit );
101+
}
98102

99103
/**
100104
* Reads a single character, @see java.io.Reader#read()
105+
*
101106
* @return -1 on eof or the character read
102107
* @throws IOException If an I/O error occurs
103108
*/
104-
@Override
105-
public int read() throws IOException {
109+
@Override
110+
public int read() throws IOException {
106111

107-
if ( charsRead >= maxCharsFromTargetReader) {
108-
return -1;
109-
}
112+
if ( charsRead >= maxCharsFromTargetReader ) {
113+
return -1;
114+
}
110115

111-
if ( markedAt >= 0 && (charsRead -markedAt) >= readAheadLimit) {
112-
return -1;
113-
}
114-
charsRead++;
115-
return target.read();
116-
}
116+
if ( markedAt >= 0 && ( charsRead - markedAt ) >= readAheadLimit ) {
117+
return -1;
118+
}
119+
charsRead++;
120+
return target.read();
121+
}
117122

118123
/**
119124
* Reads into an array, @see java.io.Reader#read(char[], int, int)
125+
*
120126
* @param cbuf The buffer to fill
121-
* @param off The offset
122-
* @param len The number of chars to read
127+
* @param off The offset
128+
* @param len The number of chars to read
123129
* @return the number of chars read
124130
* @throws IOException
125131
*/
126-
@Override
127-
public int read(char[] cbuf, int off, int len) throws IOException {
128-
int c;
129-
for (int i = 0; i < len; i++){
130-
c = read();
131-
if (c == -1) return i;
132-
cbuf[off + i] = (char) c;
133-
}
134-
return len;
135-
}
132+
@Override
133+
public int read( char[] cbuf, int off, int len ) throws IOException {
134+
int c;
135+
for ( int i = 0; i < len; i++ ) {
136+
c = read();
137+
if ( c == -1 ) {
138+
return i;
139+
}
140+
cbuf[off + i] = (char) c;
141+
}
142+
return len;
143+
}
136144
}

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

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -24,87 +24,87 @@
2424

2525
/**
2626
* A filtering input stream that ensures the content will have unix-style line endings, LF.
27+
*
2728
* @since 2.5
2829
*/
29-
public class UnixLineEndingInputStream
30-
extends InputStream {
30+
public class UnixLineEndingInputStream extends InputStream {
3131

32-
private boolean slashNSeen = false;
32+
private boolean slashNSeen = false;
3333

34-
private boolean eofSeen = false;
34+
private boolean eofSeen = false;
3535

36-
private final InputStream target;
36+
private final InputStream target;
3737

38-
private final boolean ensureLineFeedAtEndOfFile;
38+
private final boolean ensureLineFeedAtEndOfFile;
3939

40-
/**
41-
* Create an input stream that filters another stream
42-
*
43-
* @param in The input stream to wrap
44-
* @param ensureLineFeedAtEndOfFile true to ensure that the file ends with LF
45-
*/
46-
public UnixLineEndingInputStream(InputStream in, boolean ensureLineFeedAtEndOfFile) {
47-
this.target = in;
48-
this.ensureLineFeedAtEndOfFile = ensureLineFeedAtEndOfFile;
49-
}
40+
/**
41+
* Create an input stream that filters another stream
42+
*
43+
* @param in The input stream to wrap
44+
* @param ensureLineFeedAtEndOfFile true to ensure that the file ends with LF
45+
*/
46+
public UnixLineEndingInputStream( InputStream in, boolean ensureLineFeedAtEndOfFile ) {
47+
this.target = in;
48+
this.ensureLineFeedAtEndOfFile = ensureLineFeedAtEndOfFile;
49+
}
5050

51-
private int readWithUpdate() throws IOException {
52-
final int target = this.target.read();
53-
eofSeen = target == -1;
54-
if (eofSeen) {
55-
return target;
56-
}
57-
slashNSeen = target == '\n';
58-
return target;
59-
}
51+
private int readWithUpdate() throws IOException {
52+
final int target = this.target.read();
53+
eofSeen = target == -1;
54+
if ( eofSeen ) {
55+
return target;
56+
}
57+
slashNSeen = target == '\n';
58+
return target;
59+
}
6060

61-
/**
62-
* @inheritDoc
63-
*/
61+
/**
62+
* @inheritDoc
63+
*/
6464

65-
@Override public int read()
66-
throws IOException {
67-
if (eofSeen) {
68-
return eofGame();
69-
} else {
70-
int target = readWithUpdate();
71-
if (eofSeen) {
72-
return eofGame();
73-
}
74-
if (target == '\r') {
75-
target = readWithUpdate();
76-
}
77-
return target;
78-
}
79-
}
65+
@Override
66+
public int read() throws IOException {
67+
if ( eofSeen ) {
68+
return eofGame();
69+
}
70+
else {
71+
int target = readWithUpdate();
72+
if ( eofSeen ) {
73+
return eofGame();
74+
}
75+
if ( target == '\r' ) {
76+
target = readWithUpdate();
77+
}
78+
return target;
79+
}
80+
}
8081

81-
private int eofGame() {
82-
if (!ensureLineFeedAtEndOfFile) {
83-
return -1;
84-
}
85-
if (!slashNSeen) {
86-
slashNSeen = true;
87-
return '\n';
88-
} else {
89-
return -1;
90-
}
91-
}
82+
private int eofGame() {
83+
if ( !ensureLineFeedAtEndOfFile ) {
84+
return -1;
85+
}
86+
if ( !slashNSeen ) {
87+
slashNSeen = true;
88+
return '\n';
89+
} else {
90+
return -1;
91+
}
92+
}
9293

93-
/**
94-
* Closes the stream. Also closes the underlying stream.
95-
*/
96-
@Override
97-
public void close()
98-
throws IOException {
99-
super.close();
100-
target.close();
101-
}
94+
/**
95+
* Closes the stream. Also closes the underlying stream.
96+
*/
97+
@Override
98+
public void close() throws IOException {
99+
super.close();
100+
target.close();
101+
}
102102

103-
/**
104-
* @inheritDoc
105-
*/
106-
@Override
107-
public synchronized void mark(int readlimit) {
108-
throw new UnsupportedOperationException("Mark notsupported");
109-
}
103+
/**
104+
* @inheritDoc
105+
*/
106+
@Override
107+
public synchronized void mark( int readlimit ) {
108+
throw new UnsupportedOperationException( "Mark notsupported" );
109+
}
110110
}

0 commit comments

Comments
 (0)