Skip to content

Commit 88f75b8

Browse files
author
Gary Gregory
committed
[IO-617] Add classes Added TaggedReader, ClosedReader and BrokenReader.
#85. - Javadoc: Close HTML tags. - Format: Line width 120.
1 parent fab5ff6 commit 88f75b8

4 files changed

Lines changed: 22 additions & 29 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* <p>
2626
* This class is mostly useful for testing error handling in code that uses a
2727
* reader.
28+
* </p>
2829
*
2930
* @since 2.7
3031
*/

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@
2222
import java.io.Reader;
2323

2424
/**
25-
* Closed reader. This reader returns EOF to all attempts to read
26-
* something from it.
25+
* Closed reader. This reader returns EOF to all attempts to read something from it.
2726
* <p>
28-
* Typically uses of this class include testing for corner cases in methods
29-
* that accept readers and acting as a sentinel value instead of a
30-
* {@code null} reader.
27+
* Typically uses of this class include testing for corner cases in methods that accept readers and acting as a sentinel
28+
* value instead of a {@code null} reader.
3129
* </p>
3230
*
3331
* @since 2.7
@@ -43,8 +41,8 @@ public class ClosedReader extends Reader {
4341
* Returns -1 to indicate that the stream is closed.
4442
*
4543
* @param cbuf ignored
46-
* @param off ignored
47-
* @param len ignored
44+
* @param off ignored
45+
* @param len ignored
4846
* @return always -1
4947
*/
5048
@Override

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

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
import org.apache.commons.io.TaggedIOException;
2525

2626
/**
27-
* A reader decorator that tags potential exceptions so that the
28-
* reader that caused the exception can easily be identified. This is
29-
* done by using the {@link TaggedIOException} class to wrap all thrown
30-
* {@link IOException}s. See below for an example of using this class.
27+
* A reader decorator that tags potential exceptions so that the reader that caused the exception can easily be
28+
* identified. This is done by using the {@link TaggedIOException} class to wrap all thrown {@link IOException}s. See
29+
* below for an example of using this class.
30+
*
3131
* <pre>
3232
* TaggedReader reader = new TaggedReader(...);
3333
* try {
@@ -44,10 +44,10 @@
4444
* }
4545
* </pre>
4646
* <p>
47-
* Alternatively, the {@link #throwIfCauseOf(Throwable)} method can be
48-
* used to let higher levels of code handle the exception caused by this
49-
* reader while other processing errors are being taken care of at this
50-
* lower level.
47+
* Alternatively, the {@link #throwIfCauseOf(Throwable)} method can be used to let higher levels of code handle the
48+
* exception caused by this reader while other processing errors are being taken care of at this lower level.
49+
* </p>
50+
*
5151
* <pre>
5252
* TaggedReader reader = new TaggedReader(...);
5353
* try {
@@ -81,19 +81,16 @@ public TaggedReader(final Reader proxy) {
8181
* Tests if the given exception was caused by this reader.
8282
*
8383
* @param exception an exception
84-
* @return {@code true} if the exception was thrown by this reader,
85-
* {@code false} otherwise
84+
* @return {@code true} if the exception was thrown by this reader, {@code false} otherwise
8685
*/
8786
public boolean isCauseOf(final Throwable exception) {
8887
return TaggedIOException.isTaggedWith(exception, tag);
8988
}
9089

9190
/**
92-
* Re-throws the original exception thrown by this reader. This method
93-
* first checks whether the given exception is a {@link TaggedIOException}
94-
* wrapper created by this decorator, and then unwraps and throws the
95-
* original wrapped exception. Returns normally if the exception was
96-
* not thrown by this reader.
91+
* Re-throws the original exception thrown by this reader. This method first checks whether the given exception is a
92+
* {@link TaggedIOException} wrapper created by this decorator, and then unwraps and throws the original wrapped
93+
* exception. Returns normally if the exception was not thrown by this reader.
9794
*
9895
* @param throwable an exception
9996
* @throws IOException original exception, if any, thrown by this reader

src/test/java/org/apache/commons/io/input/TaggedReaderTest.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
/**
3333
* JUnit Test Case for {@link TaggedReader}.
3434
*/
35-
public class TaggedReaderTest {
35+
public class TaggedReaderTest {
3636

3737
@Test
3838
public void testEmptyReader() throws IOException {
@@ -61,8 +61,7 @@ public void testNormalReader() throws IOException {
6161
@Test
6262
public void testBrokenReader() {
6363
final IOException exception = new IOException("test exception");
64-
final TaggedReader reader =
65-
new TaggedReader(new BrokenReader(exception));
64+
final TaggedReader reader = new TaggedReader(new BrokenReader(exception));
6665

6766
// Test the ready() method
6867
try {
@@ -114,13 +113,11 @@ public void testOtherException() throws Exception {
114113
final TaggedReader reader = new TaggedReader(closed);
115114

116115
assertFalse(reader.isCauseOf(exception));
117-
assertFalse(reader.isCauseOf(
118-
new TaggedIOException(exception, UUID.randomUUID())));
116+
assertFalse(reader.isCauseOf(new TaggedIOException(exception, UUID.randomUUID())));
119117

120118
reader.throwIfCauseOf(exception);
121119

122-
reader.throwIfCauseOf(
123-
new TaggedIOException(exception, UUID.randomUUID()));
120+
reader.throwIfCauseOf(new TaggedIOException(exception, UUID.randomUUID()));
124121
reader.close();
125122
}
126123

0 commit comments

Comments
 (0)