Skip to content

Commit 5e3c7e8

Browse files
committed
Javadoc
1 parent 15b2ac6 commit 5e3c7e8

34 files changed

Lines changed: 580 additions & 240 deletions

src/main/java/org/apache/commons/io/build/AbstractStreamBuilder.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,36 +141,38 @@ protected Charset getCharsetDefault() {
141141
}
142142

143143
/**
144-
* Gets an input stream from the origin with open options.
144+
* Gets an InputStream from the origin with OpenOption[].
145145
*
146146
* @return An input stream
147147
* @throws IllegalStateException if the {@code origin} is {@code null}.
148148
* @throws UnsupportedOperationException if the origin cannot be converted to an {@link InputStream}.
149149
* @throws IOException if an I/O error occurs.
150150
* @see AbstractOrigin#getInputStream(OpenOption...)
151+
* @see #getOpenOptions()
151152
* @since 2.13.0
152153
*/
153154
protected InputStream getInputStream() throws IOException {
154155
return checkOrigin().getInputStream(getOpenOptions());
155156
}
156157

157158
/**
158-
* Gets the OpenOption.
159+
* Gets the OpenOption array.
159160
*
160-
* @return the OpenOption.
161+
* @return the OpenOption array.
161162
*/
162163
protected OpenOption[] getOpenOptions() {
163164
return openOptions;
164165
}
165166

166167
/**
167-
* Gets an OutputStream from the origin with open options.
168+
* Gets an OutputStream from the origin with OpenOption[].
168169
*
169170
* @return An OutputStream
170171
* @throws IllegalStateException if the {@code origin} is {@code null}.
171172
* @throws UnsupportedOperationException if the origin cannot be converted to an {@link OutputStream}.
172173
* @throws IOException if an I/O error occurs.
173174
* @see AbstractOrigin#getOutputStream(OpenOption...)
175+
* @see #getOpenOptions()
174176
* @since 2.13.0
175177
*/
176178
protected OutputStream getOutputStream() throws IOException {
@@ -191,13 +193,14 @@ protected Path getPath() {
191193
}
192194

193195
/**
194-
* Gets an writer from the origin with open options.
196+
* Gets a Writer from the origin with OpenOption[].
195197
*
196198
* @return An writer.
197199
* @throws IllegalStateException if the {@code origin} is {@code null}.
198200
* @throws UnsupportedOperationException if the origin cannot be converted to a {@link Writer}.
199201
* @throws IOException if an I/O error occurs.
200202
* @see AbstractOrigin#getOutputStream(OpenOption...)
203+
* @see #getOpenOptions()
201204
* @since 2.13.0
202205
*/
203206
protected Writer getWriter() throws IOException {

src/main/java/org/apache/commons/io/filefilter/WildcardFileFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
* command lines. The check is case-sensitive by default. See {@link FilenameUtils#wildcardMatchOnSystem(String,String)} for more information.
4141
* </p>
4242
* <p>
43-
* To build an instance, see {@link Builder}.
43+
* To build an instance, use {@link Builder}.
4444
* </p>
4545
* <p>
4646
* For example:

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

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,52 +24,57 @@
2424
import org.apache.commons.io.build.AbstractStreamBuilder;
2525

2626
/**
27-
* Proxy stream that closes and discards the underlying stream as soon as the
28-
* end of input has been reached or when the stream is explicitly closed.
29-
* Not even a reference to the underlying stream is kept after it has been
30-
* closed, so any allocated in-memory buffers can be freed even if the
31-
* client application still keeps a reference to the proxy stream.
27+
* Proxy stream that closes and discards the underlying stream as soon as the end of input has been reached or when the stream is explicitly closed. Not even a
28+
* reference to the underlying stream is kept after it has been closed, so any allocated in-memory buffers can be freed even if the client application still
29+
* keeps a reference to the proxy stream.
3230
* <p>
33-
* This class is typically used to release any resources related to an open
34-
* stream as soon as possible even if the client application (by not explicitly
35-
* closing the stream when no longer needed) or the underlying stream (by not
36-
* releasing resources once the last byte has been read) do not do that.
31+
* This class is typically used to release any resources related to an open stream as soon as possible even if the client application (by not explicitly closing
32+
* the stream when no longer needed) or the underlying stream (by not releasing resources once the last byte has been read) do not do that.
33+
* </p>
34+
* <p>
35+
* To build an instance, use {@link Builder}.
3736
* </p>
3837
*
3938
* @since 1.4
39+
* @see Builder
4040
*/
4141
public class AutoCloseInputStream extends ProxyInputStream {
4242

43+
// @formatter:off
4344
/**
4445
* Builds a new {@link AutoCloseInputStream} instance.
46+
*
4547
* <p>
4648
* For example:
4749
* </p>
48-
*
4950
* <pre>{@code
5051
* AutoCloseInputStream s = AutoCloseInputStream.builder()
5152
* .setPath(path)
5253
* .get();}
5354
* </pre>
54-
*
5555
* <pre>{@code
5656
* AutoCloseInputStream s = AutoCloseInputStream.builder()
5757
* .setInputStream(inputStream)
5858
* .get();}
5959
* </pre>
6060
*
61+
* @see #get()
6162
* @since 2.13.0
6263
*/
64+
// @formatter:on
6365
public static class Builder extends AbstractStreamBuilder<AutoCloseInputStream, Builder> {
6466

6567
/**
66-
* Constructs a new instance.
68+
* Builds a new {@link AutoCloseInputStream}.
6769
* <p>
68-
* You must provide an origin that supports calling {@link #getInputStream()} on this builder, otherwise, this method throws an exception.
70+
* You must set input that supports {@link #getInputStream()}, otherwise, this method throws an exception.
6971
* </p>
7072
* <p>
71-
* This builder use the aspects InputStream, OpenOption[], include, and ByteOrderMark[].
73+
* This builder use the following aspects:
7274
* </p>
75+
* <ul>
76+
* <li>{@link #getInputStream()}</li>
77+
* </ul>
7378
*
7479
* @return a new instance.
7580
* @throws IllegalStateException if the {@code origin} is {@code null}.
@@ -121,15 +126,14 @@ protected void afterRead(final int n) throws IOException {
121126
}
122127

123128
/**
124-
* Closes the underlying input stream and replaces the reference to it
125-
* with a {@link ClosedInputStream} instance.
129+
* Closes the underlying input stream and replaces the reference to it with a {@link ClosedInputStream} instance.
126130
* <p>
127-
* This method is automatically called by the read methods when the end
128-
* of input has been reached.
131+
* This method is automatically called by the read methods when the end of input has been reached.
132+
* </p>
129133
* <p>
130-
* Note that it is safe to call this method any number of times. The original
131-
* underlying input stream is closed and discarded only once when this
132-
* method is first called.
134+
* Note that it is safe to call this method any number of times. The original underlying input stream is closed and discarded only once when this method is
135+
* first called.
136+
* </p>
133137
*
134138
* @throws IOException if the underlying input stream can not be closed
135139
*/
@@ -140,9 +144,9 @@ public void close() throws IOException {
140144
}
141145

142146
/**
143-
* Ensures that the stream is closed before it gets garbage-collected.
144-
* As mentioned in {@link #close()}, this is a no-op if the stream has
145-
* already been closed.
147+
* Ensures that the stream is closed before it gets garbage-collected. As mentioned in {@link #close()}, this is a no-op if the stream has already been
148+
* closed.
149+
*
146150
* @throws Throwable if an error occurs
147151
*/
148152
@Override

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

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
* <li>UTF-32LE - {@link ByteOrderMark#UTF_32BE}</li>
4747
* </ul>
4848
* <p>
49-
* To build an instance, see {@link Builder}.
49+
* To build an instance, use {@link Builder}.
5050
* </p>
5151
* <h2>Example 1 - Detecting and excluding a UTF-8 BOM</h2>
5252
*
@@ -89,15 +89,20 @@
8989
* // has a UTF-32BE BOM
9090
* }
9191
* </pre>
92+
* <p>
93+
* To build an instance, use {@link Builder}.
94+
* </p>
9295
*
96+
* @see Builder
9397
* @see org.apache.commons.io.ByteOrderMark
9498
* @see <a href="https://en.wikipedia.org/wiki/Byte_order_mark">Wikipedia - Byte Order Mark</a>
9599
* @since 2.0
96100
*/
97101
public class BOMInputStream extends ProxyInputStream {
98102

103+
// @formatter:off
99104
/**
100-
* Builds a new {@link BOMInputStream} instance.
105+
* Builds a new {@link BOMInputStream}.
101106
*
102107
* <h2>Using NIO</h2>
103108
* <pre>{@code
@@ -116,8 +121,10 @@ public class BOMInputStream extends ProxyInputStream {
116121
* .get();}
117122
* </pre>
118123
*
124+
* @see #get()
119125
* @since 2.12.0
120126
*/
127+
// @formatter:on
121128
public static class Builder extends AbstractStreamBuilder<BOMInputStream, Builder> {
122129

123130
private static final ByteOrderMark[] DEFAULT = { ByteOrderMark.UTF_8 };
@@ -136,13 +143,21 @@ static ByteOrderMark getDefaultByteOrderMark() {
136143
private boolean include;
137144

138145
/**
139-
* Constructs a new instance.
146+
* Builds a new {@link BOMInputStream}.
147+
* <p>
148+
* You must set input that supports {@link #getInputStream()}, otherwise, this method throws an exception.
149+
* </p>
140150
* <p>
141-
* You must provide an origin that supports calling {@link #getInputStream()} on this builder, otherwise, this method throws an exception.
151+
* This builder use the following aspects: InputStream, OpenOption[], include, and ByteOrderMark[].
142152
* </p>
143153
* <p>
144-
* This builder use the aspects InputStream, OpenOption[], include, and ByteOrderMark[].
154+
* This builder use the following aspects:
145155
* </p>
156+
* <ul>
157+
* <li>{@link #getInputStream()}</li>
158+
* <li>include}</li>
159+
* <li>byteOrderMarks</li>
160+
* </ul>
146161
*
147162
* @return a new instance.
148163
* @throws IllegalStateException if the {@code origin} is {@code null}.

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

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,44 @@
3131
* doesn't know whether the content hasn't arrived yet or whether the content has finished. So, one of these, initialized with the {@code Content-Length} sent
3232
* in the {@code ServletInputStream}'s header, will stop it blocking, providing it's been sent with a correct content length.
3333
* </p>
34+
* <p>
35+
* To build an instance, use {@link Builder}.
36+
* </p>
3437
*
38+
* @see Builder
3539
* @since 2.0
3640
*/
3741
public class BoundedInputStream extends ProxyInputStream {
3842

3943
// TODO For 3.0, extend CountingInputStream. Or, add a max feature to CountingInputStream.
4044

45+
//@formatter:off
4146
/**
42-
* Builds a new {@link BoundedInputStream} instance.
47+
* Builds a new {@link BoundedInputStream}.
4348
*
4449
* <h2>Using NIO</h2>
45-
*
4650
* <pre>{@code
47-
* BoundedInputStream s = BoundedInputStream.builder().setPath(Paths.get("MyFile.xml")).setMaxCount(1024).setPropagateClose(false).get();
51+
* BoundedInputStream s = BoundedInputStream.builder()
52+
* .setPath(Paths.get("MyFile.xml"))
53+
* .setMaxCount(1024)
54+
* .setPropagateClose(false)
55+
* .get();
4856
* }
4957
* </pre>
50-
*
5158
* <h2>Using IO</h2>
52-
*
5359
* <pre>{@code
54-
* BoundedInputStream s = BoundedInputStream.builder().setFile(new File("MyFile.xml")).setMaxCount(1024).setPropagateClose(false).get();
60+
* BoundedInputStream s = BoundedInputStream.builder()
61+
* .setFile(new File("MyFile.xml"))
62+
* .setMaxCount(1024)
63+
* .setPropagateClose(false)
64+
* .get();
5565
* }
5666
* </pre>
5767
*
68+
* @see #get()
5869
* @since 2.16.0
5970
*/
71+
//@formatter:on
6072
public static class Builder extends AbstractStreamBuilder<BoundedInputStream, Builder> {
6173

6274
/** The max count of bytes to read. */
@@ -66,10 +78,18 @@ public static class Builder extends AbstractStreamBuilder<BoundedInputStream, Bu
6678
private boolean propagateClose = true;
6779

6880
/**
69-
* Constructs a new instance.
81+
* Builds a new {@link BoundedInputStream}.
82+
* <p>
83+
* You must set input that supports {@link #getInputStream()}, otherwise, this method throws an exception.
84+
* </p>
7085
* <p>
71-
* You must provide an origin that supports calling {@link #getInputStream()} on this builder, otherwise, this method throws an exception.
86+
* This builder use the following aspects:
7287
* </p>
88+
* <ul>
89+
* <li>{@link #getInputStream()}</li>
90+
* <li>maxCount</li>
91+
* <li>propagateClose</li>
92+
* </ul>
7393
*
7494
* @return a new instance.
7595
* @throws IllegalStateException if the {@code origin} is {@code null}.

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,24 @@
3232
* using {@link java.io.BufferedInputStream}. Unfortunately, this is not something already available in JDK, {@code sun.nio.ch.ChannelInputStream} supports
3333
* reading a file using NIO, but does not support buffering.
3434
* <p>
35-
* To build an instance, see {@link Builder}.
35+
* To build an instance, use {@link Builder}.
3636
* </p>
3737
* <p>
3838
* This class was ported and adapted from Apache Spark commit 933dc6cb7b3de1d8ccaf73d124d6eb95b947ed19 where it was called {@code NioBufferedFileInputStream}.
3939
* </p>
4040
*
41+
* @see Builder
4142
* @since 2.9.0
4243
*/
4344
public final class BufferedFileChannelInputStream extends InputStream {
4445

46+
// @formatter:off
4547
/**
46-
* Builds a new {@link BufferedFileChannelInputStream} instance.
48+
* Builds a new {@link BufferedFileChannelInputStream}.
49+
*
4750
* <p>
4851
* Using File IO:
4952
* </p>
50-
*
5153
* <pre>{@code
5254
* BufferedFileChannelInputStream s = BufferedFileChannelInputStream.builder()
5355
* .setFile(file)
@@ -57,24 +59,31 @@ public final class BufferedFileChannelInputStream extends InputStream {
5759
* <p>
5860
* Using NIO Path:
5961
* </p>
60-
*
6162
* <pre>{@code
6263
* BufferedFileChannelInputStream s = BufferedFileChannelInputStream.builder()
6364
* .setPath(path)
6465
* .setBufferSize(4096)
6566
* .get();}
6667
* </pre>
6768
*
69+
* @see #get()
6870
* @since 2.12.0
6971
*/
72+
// @formatter:on
7073
public static class Builder extends AbstractStreamBuilder<BufferedFileChannelInputStream, Builder> {
7174

7275
/**
73-
* Constructs a new instance.
76+
* Builds a new {@link BufferedFileChannelInputStream}.
77+
* <p>
78+
* You must set input that supports {@link #getInputStream()}, otherwise, this method throws an exception.
79+
* </p>
7480
* <p>
75-
* You must provide an origin that supports calling {@link #getPath()} and {@link #getBufferSize()} on this builder, otherwise, this method throws an
76-
* exception.
81+
* This builder use the following aspects:
7782
* </p>
83+
* <ul>
84+
* <li>{@link #getInputStream()}</li>
85+
* <li>{@link #getBufferSize()}</li>
86+
* </ul>
7887
*
7988
* @return a new instance.
8089
* @throws IllegalStateException if the {@code origin} is {@code null}.

0 commit comments

Comments
 (0)