Skip to content

Commit 3c53c39

Browse files
committed
[IO-829] Don't decode and reencode characters in a potentially different
charset in AbstractOrigin.CharSequenceOrigin.getReader(Charset) Javadoc
1 parent d428a08 commit 3c53c39

1 file changed

Lines changed: 66 additions & 3 deletions

File tree

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

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ public byte[] getByteArray() {
7878
return get();
7979
}
8080

81+
/**
82+
* {@inheritDoc}
83+
* <p>
84+
* The {@code options} parameter is ignored since a {@code byte[]} does not need an {@link OpenOption} to be read.
85+
* </p>
86+
*/
8187
@Override
8288
public InputStream getInputStream(final OpenOption... options) throws IOException {
8389
return new ByteArrayInputStream(origin);
@@ -118,7 +124,7 @@ public byte[] getByteArray() {
118124
/**
119125
* {@inheritDoc}
120126
* <p>
121-
* In this case, the {@code charset} parameter is ignored, since a {@link CharSequence} does not need a {@link Charset} to be read.
127+
* The {@code charset} parameter is ignored since a {@link CharSequence} does not need a {@link Charset} to be read.
122128
* </p>
123129
*/
124130
@Override
@@ -127,6 +133,12 @@ public CharSequence getCharSequence(final Charset charset) {
127133
return get();
128134
}
129135

136+
/**
137+
* {@inheritDoc}
138+
* <p>
139+
* The {@code options} parameter is ignored since a {@link CharSequence} does not need an {@link OpenOption} to be read.
140+
* </p>
141+
*/
130142
@Override
131143
public InputStream getInputStream(final OpenOption... options) throws IOException {
132144
// TODO Pass in a Charset? Consider if call sites actually need this.
@@ -136,11 +148,11 @@ public InputStream getInputStream(final OpenOption... options) throws IOExceptio
136148
/**
137149
* {@inheritDoc}
138150
* <p>
139-
* In this case, the {@code charset} parameter is ignored, since a {@link CharSequence} does not need a {@link Charset} to be read.
151+
* The {@code charset} parameter is ignored since a {@link CharSequence} does not need a {@link Charset} to be read.
140152
* </p>
141153
*/
142154
@Override
143-
public Reader getReader(final Charset ignore) throws IOException {
155+
public Reader getReader(final Charset charset) throws IOException {
144156
return new CharSequenceReader(get());
145157
}
146158

@@ -210,6 +222,12 @@ public byte[] getByteArray() throws IOException {
210222
return IOUtils.toByteArray(origin);
211223
}
212224

225+
/**
226+
* {@inheritDoc}
227+
* <p>
228+
* The {@code options} parameter is ignored since a {@link InputStream} does not need an {@link OpenOption} to be read.
229+
* </p>
230+
*/
213231
@Override
214232
public InputStream getInputStream(final OpenOption... options) {
215233
// No conversion
@@ -240,12 +258,24 @@ public OutputStreamOrigin(final OutputStream origin) {
240258
super(origin);
241259
}
242260

261+
/**
262+
* {@inheritDoc}
263+
* <p>
264+
* The {@code options} parameter is ignored since a {@link OutputStream} does not need an {@link OpenOption} to be written.
265+
* </p>
266+
*/
243267
@Override
244268
public OutputStream getOutputStream(final OpenOption... options) {
245269
// No conversion
246270
return get();
247271
}
248272

273+
/**
274+
* {@inheritDoc}
275+
* <p>
276+
* The {@code options} parameter is ignored since a {@link OutputStream} does not need an {@link OpenOption} to be written.
277+
* </p>
278+
*/
249279
@Override
250280
public Writer getWriter(final Charset charset, final OpenOption... options) throws IOException {
251281
return new OutputStreamWriter(origin, charset);
@@ -312,17 +342,35 @@ public byte[] getByteArray() throws IOException {
312342
return IOUtils.toByteArray(origin, Charset.defaultCharset());
313343
}
314344

345+
/**
346+
* {@inheritDoc}
347+
* <p>
348+
* The {@code charset} parameter is ignored since a {@link Reader} does not need a {@link Charset} to be read.
349+
* </p>
350+
*/
315351
@Override
316352
public CharSequence getCharSequence(final Charset charset) throws IOException {
317353
return IOUtils.toString(origin);
318354
}
319355

356+
/**
357+
* {@inheritDoc}
358+
* <p>
359+
* The {@code options} parameter is ignored since a {@link Reader} does not need an {@link OpenOption} to be read.
360+
* </p>
361+
*/
320362
@Override
321363
public InputStream getInputStream(final OpenOption... options) throws IOException {
322364
// TODO Pass in a Charset? Consider if call sites actually need this.
323365
return ReaderInputStream.builder().setReader(origin).setCharset(Charset.defaultCharset()).get();
324366
}
325367

368+
/**
369+
* {@inheritDoc}
370+
* <p>
371+
* The {@code charset} parameter is ignored since a {@link Reader} does not need a {@link Charset} to be read.
372+
* </p>
373+
*/
326374
@Override
327375
public Reader getReader(final Charset charset) throws IOException {
328376
// No conversion
@@ -373,12 +421,27 @@ public WriterOrigin(final Writer origin) {
373421
super(origin);
374422
}
375423

424+
/**
425+
* {@inheritDoc}
426+
* <p>
427+
* The {@code options} parameter is ignored since a {@link Writer} does not need an {@link OpenOption} to be written.
428+
* </p>
429+
*/
376430
@Override
377431
public OutputStream getOutputStream(final OpenOption... options) throws IOException {
378432
// TODO Pass in a Charset? Consider if call sites actually need this.
379433
return WriterOutputStream.builder().setWriter(origin).setCharset(Charset.defaultCharset()).get();
380434
}
381435

436+
/**
437+
* {@inheritDoc}
438+
* <p>
439+
* The {@code charset} parameter is ignored since a {@link Writer} does not need a {@link Charset} to be written.
440+
* </p>
441+
* <p>
442+
* The {@code options} parameter is ignored since a {@link Writer} does not need an {@link OpenOption} to be written.
443+
* </p>
444+
*/
382445
@Override
383446
public Writer getWriter(final Charset charset, final OpenOption... options) throws IOException {
384447
// No conversion

0 commit comments

Comments
 (0)