Skip to content

Commit 8c7fe8b

Browse files
author
Niall Pemberton
committed
IO-197 Improve BoundedInputStream Javadocs
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@1002431 13f79535-47bb-0310-9956-ffa450edef68
1 parent c88a865 commit 8c7fe8b

1 file changed

Lines changed: 56 additions & 9 deletions

File tree

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

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,23 @@ public BoundedInputStream(InputStream in, long size) {
6363
this.in = in;
6464
}
6565

66+
/**
67+
* Creates a new <code>BoundedInputStream</code> that wraps the given input
68+
* stream and is unlimited.
69+
*
70+
* @param in The wrapped input stream
71+
* @param size The maximum number of bytes to return
72+
*/
6673
public BoundedInputStream(InputStream in) {
6774
this(in, -1);
6875
}
6976

7077
/**
71-
* {@inheritDoc}
78+
* Invokes the delegate's <code>read()</code> method if
79+
* the current position is less than the limit.
80+
* @return the byte read or -1 if the end of stream or
81+
* the limit has been reached.
82+
* @throws IOException if an I/O error occurs
7283
*/
7384
@Override
7485
public int read() throws IOException {
@@ -81,15 +92,25 @@ public int read() throws IOException {
8192
}
8293

8394
/**
84-
* {@inheritDoc}
95+
* Invokes the delegate's <code>read(byte[])</code> method.
96+
* @param bts the buffer to read the bytes into
97+
* @return the number of bytes read or -1 if the end of stream or
98+
* the limit has been reached.
99+
* @throws IOException if an I/O error occurs
85100
*/
86101
@Override
87102
public int read(byte[] b) throws IOException {
88103
return this.read(b, 0, b.length);
89104
}
90105

91106
/**
92-
* {@inheritDoc}
107+
* Invokes the delegate's <code>read(byte[], int, int)</code> method.
108+
* @param bts the buffer to read the bytes into
109+
* @param off The start offset
110+
* @param len The number of bytes to read
111+
* @return the number of bytes read or -1 if the end of stream or
112+
* the limit has been reached.
113+
* @throws IOException if an I/O error occurs
93114
*/
94115
@Override
95116
public int read(byte[] b, int off, int len) throws IOException {
@@ -108,7 +129,10 @@ public int read(byte[] b, int off, int len) throws IOException {
108129
}
109130

110131
/**
111-
* {@inheritDoc}
132+
* Invokes the delegate's <code>skip(long)</code> method.
133+
* @param ln the number of bytes to skip
134+
* @return the actual number of bytes skipped
135+
* @throws IOException if an I/O error occurs
112136
*/
113137
@Override
114138
public long skip(long n) throws IOException {
@@ -130,15 +154,18 @@ public int available() throws IOException {
130154
}
131155

132156
/**
133-
* {@inheritDoc}
157+
* Invokes the delegate's <code>toString()</code> method.
158+
* @return the delegate's <code>toString()</code>
134159
*/
135160
@Override
136161
public String toString() {
137162
return in.toString();
138163
}
139164

140165
/**
141-
* {@inheritDoc}
166+
* Invokes the delegate's <code>close()</code> method
167+
* if {@link #isPropagateClose()} is <code>true</code>.
168+
* @throws IOException if an I/O error occurs
142169
*/
143170
@Override
144171
public void close() throws IOException {
@@ -148,7 +175,8 @@ public void close() throws IOException {
148175
}
149176

150177
/**
151-
* {@inheritDoc}
178+
* Invokes the delegate's <code>reset()</code> method.
179+
* @throws IOException if an I/O error occurs
152180
*/
153181
@Override
154182
public synchronized void reset() throws IOException {
@@ -157,7 +185,8 @@ public synchronized void reset() throws IOException {
157185
}
158186

159187
/**
160-
* {@inheritDoc}
188+
* Invokes the delegate's <code>mark(int)</code> method.
189+
* @param readlimit read ahead limit
161190
*/
162191
@Override
163192
public synchronized void mark(int readlimit) {
@@ -166,17 +195,35 @@ public synchronized void mark(int readlimit) {
166195
}
167196

168197
/**
169-
* {@inheritDoc}
198+
* Invokes the delegate's <code>markSupported()</code> method.
199+
* @return true if mark is supported, otherwise false
170200
*/
171201
@Override
172202
public boolean markSupported() {
173203
return in.markSupported();
174204
}
175205

206+
/**
207+
* Indicates whether the {@link #close()} method
208+
* should propagate to the underling {@link InputStream}.
209+
*
210+
* @return <code>true</code> if calling {@link #close()}
211+
* propagates to the <code>close()</code> method of the
212+
* underlying stream or <code>false</code> if it does not.
213+
*/
176214
public boolean isPropagateClose() {
177215
return propagateClose;
178216
}
179217

218+
/**
219+
* Set whether the {@link #close()} method
220+
* should propagate to the underling {@link InputStream}.
221+
*
222+
* @param propagateClose <code>true</code> if calling
223+
* {@link #close()} propagates to the <code>close()</code>
224+
* method of the underlying stream or
225+
* <code>false</code> if it does not.
226+
*/
180227
public void setPropagateClose(boolean propagateClose) {
181228
this.propagateClose = propagateClose;
182229
}

0 commit comments

Comments
 (0)