Skip to content

Commit d357d9d

Browse files
fix checkstyle violations by adding javadoc
1 parent cdc90d7 commit d357d9d

3 files changed

Lines changed: 50 additions & 2 deletions

File tree

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,16 @@
3131
*/
3232
public class MessageDigestCalculatingInputStream extends ObservableInputStream {
3333

34+
/**
35+
* Maintains the message digest.
36+
*/
3437
public static class MessageDigestMaintainingObserver extends Observer {
3538
private final MessageDigest md;
3639

40+
/**
41+
* Creates an MessageDigestMaintainingObserver for the given MessageDigest.
42+
* @param pMd the message digest to use
43+
*/
3744
public MessageDigestMaintainingObserver(MessageDigest pMd) {
3845
md = pMd;
3946
}
@@ -53,6 +60,8 @@ void data(byte[] pBuffer, int pOffset, int pLength) throws IOException {
5360

5461
/** Creates a new instance, which calculates a signature on the given stream,
5562
* using the given {@link MessageDigest}.
63+
* @param pStream the stream to calculate the message digest for
64+
* @param pDigest the message digest to use
5665
*/
5766
public MessageDigestCalculatingInputStream(InputStream pStream, MessageDigest pDigest) {
5867
super(pStream);
@@ -62,13 +71,18 @@ public MessageDigestCalculatingInputStream(InputStream pStream, MessageDigest pD
6271

6372
/** Creates a new instance, which calculates a signature on the given stream,
6473
* using a {@link MessageDigest} with the given algorithm.
74+
* @param pStream the stream to calculate the message digest for
75+
* @param pAlgorithm the name of the algorithm to use
76+
* @throws NoSuchAlgorithmException if no Provider supports a MessageDigestSpi implementation for the specified algorithm.
6577
*/
6678
public MessageDigestCalculatingInputStream(InputStream pStream, String pAlgorithm) throws NoSuchAlgorithmException {
6779
this(pStream, MessageDigest.getInstance(pAlgorithm));
6880
}
6981

7082
/** Creates a new instance, which calculates a signature on the given stream,
7183
* using a {@link MessageDigest} with the "MD5" algorithm.
84+
* @param pStream the stream to calculate the message digest for
85+
* @throws NoSuchAlgorithmException if no Provider supports a MessageDigestSpi implementation for the specified algorithm.
7286
*/
7387
public MessageDigestCalculatingInputStream(InputStream pStream) throws NoSuchAlgorithmException {
7488
this(pStream, MessageDigest.getInstance("MD5"));
@@ -80,6 +94,7 @@ public MessageDigestCalculatingInputStream(InputStream pStream) throws NoSuchAlg
8094
* This is probably not, what you expect. Make sure, that the complete data has been
8195
* read, if that is what you want. The easiest way to do so is by invoking
8296
* {@link #consume()}.
97+
* @return the message digest used
8398
*/
8499
public MessageDigest getMessageDigest() {
85100
return messageDigest;

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

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import java.io.IOException;
2020
import java.io.InputStream;
21-
import java.security.MessageDigest;
2221
import java.util.ArrayList;
2322
import java.util.List;
2423

@@ -36,51 +35,77 @@
3635
* @see MessageDigestCalculatingInputStream
3736
*/
3837
public class ObservableInputStream extends ProxyInputStream {
38+
3939
public static abstract class Observer {
40+
4041
/** Called to indicate, that {@link InputStream#read()} has been invoked
4142
* on the {@link ObservableInputStream}, and will return a value.
4243
* @param pByte The value, which is being returned. This will never be -1 (EOF),
4344
* because, in that case, {@link #finished()} will be invoked instead.
45+
* @throws IOException if an i/o-error occurs
4446
*/
4547
void data(int pByte) throws IOException {}
48+
4649
/** Called to indicate, that {@link InputStream#read(byte[])}, or
4750
* {@link InputStream#read(byte[], int, int)} have been called, and are about to
4851
* invoke data.
4952
* @param pBuffer The byte array, which has been passed to the read call, and where
5053
* data has been stored.
5154
* @param pOffset The offset within the byte array, where data has been stored.
5255
* @param pLength The number of bytes, which have been stored in the byte array.
56+
* @throws IOException if an i/o-error occurs
5357
*/
5458
void data(byte[] pBuffer, int pOffset, int pLength) throws IOException {}
59+
5560
/** Called to indicate, that EOF has been seen on the underlying stream.
5661
* This method may be called multiple times, if the reader keeps invoking
5762
* either of the read methods, and they will consequently keep returning
5863
* EOF.
64+
* @throws IOException if an i/o-error occurs
5965
*/
6066
void finished() throws IOException {}
67+
6168
/** Called to indicate, that the {@link ObservableInputStream} has been closed.
69+
* @throws IOException if an i/o-error occurs
6270
*/
6371
void closed() throws IOException {}
72+
6473
/**
6574
* Called to indicate, that an error occurred on the underlying stream.
75+
* @throws IOException if an i/o-error occurs
6676
*/
6777
void error(IOException pException) throws IOException { throw pException; }
6878
}
6979

7080
private final List<Observer> observers = new ArrayList<>();
71-
81+
82+
/**
83+
* Creates a new ObservableInputStream for the given InputStream.
84+
* @param pProxy the input stream to proxy
85+
*/
7286
public ObservableInputStream(InputStream pProxy) {
7387
super(pProxy);
7488
}
7589

90+
/**
91+
* Adds an Observer.
92+
* @param pObserver the observer to add
93+
*/
7694
public void add(Observer pObserver) {
7795
observers.add(pObserver);
7896
}
7997

98+
/**
99+
* Removes an Observer.
100+
* @param pObserver the observer to remove
101+
*/
80102
public void remove(Observer pObserver) {
81103
observers.remove(pObserver);
82104
}
83105

106+
/**
107+
* Removes all Observers.
108+
*/
84109
public void removeAllObservers() {
85110
observers.clear();
86111
}
@@ -201,6 +226,9 @@ protected void noteClosed() throws IOException {
201226
}
202227
}
203228

229+
/** Gets all currently registered observers.
230+
* @return a list of the currently registered observers
231+
*/
204232
protected List<Observer> getObservers() {
205233
return observers;
206234
}

src/main/java/org/apache/commons/io/output/WriterOutputStream.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,11 @@ private void flushOutput() throws IOException {
310310
}
311311
}
312312

313+
/**
314+
* Check if the JDK in use properly supports the given charset.
315+
*
316+
* @param charset the charset to check the support for
317+
*/
313318
private static void checkIbmJdkWithBrokenUTF16(Charset charset){
314319
if (!"UTF-16".equals(charset.name())) {
315320
return;

0 commit comments

Comments
 (0)