Skip to content

Commit d2ce428

Browse files
committed
[IO-793] Add StringInputStream.
- StringInputStream.java should be in main source folder. - Bump version from 2.12.1-SNAPSHOT to 2.13.0-SNAPSHOT
1 parent efcd0e7 commit d2ce428

4 files changed

Lines changed: 40 additions & 16 deletions

File tree

pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<modelVersion>4.0.0</modelVersion>
2525
<groupId>commons-io</groupId>
2626
<artifactId>commons-io</artifactId>
27-
<version>2.12.1-SNAPSHOT</version>
27+
<version>2.13.0-SNAPSHOT</version>
2828
<name>Apache Commons IO</name>
2929

3030
<inceptionYear>2002</inceptionYear>
@@ -52,7 +52,7 @@ file comparators, endian transformation classes, and much more.
5252
<connection>scm:git:https://gitbox.apache.org/repos/asf/commons-io.git</connection>
5353
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/commons-io.git</developerConnection>
5454
<url>https://gitbox.apache.org/repos/asf?p=commons-io.git</url>
55-
<tag>rel/commons-io-2.12.0</tag>
55+
<tag>rel/commons-io-2.13.0</tag>
5656
</scm>
5757

5858
<developers>
@@ -293,9 +293,9 @@ file comparators, endian transformation classes, and much more.
293293
<maven.compiler.target>1.8</maven.compiler.target>
294294
<commons.componentid>io</commons.componentid>
295295
<commons.module.name>org.apache.commons.io</commons.module.name>
296-
<commons.rc.version>RC2</commons.rc.version>
297-
<commons.bc.version>2.11.0</commons.bc.version>
298-
<commons.release.version>2.12.0</commons.release.version>
296+
<commons.rc.version>RC1</commons.rc.version>
297+
<commons.bc.version>2.12.0</commons.bc.version>
298+
<commons.release.version>2.13.0</commons.release.version>
299299
<commons.release.desc>(requires Java 8)</commons.release.desc>
300300
<commons.jira.id>IO</commons.jira.id>
301301
<commons.jira.pid>12310477</commons.jira.pid>

src/changes/changes.xml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,14 @@ The <action> type attribute can be add,update,fix,remove.
4747
</properties>
4848

4949
<body>
50-
<release version="2.12.1" date="2023-MM-DD" description="Java 8 required.">
50+
<release version="2.13.0" date="2023-MM-DD" description="Java 8 required.">
5151
<!-- FIX -->
5252
<action issue="IO-791" dev="ggregory" type="fix" due-to="Chad Wilson, Gary Gregory">
53-
Regression in FileUtils.touch - no longer creates parent directories.
53+
Regression in FileUtils.touch() - no longer creates parent directories.
54+
</action>
55+
<!-- ADD -->
56+
<action issue="IO-793" dev="ggregory" type="add" due-to="Gary Gregory, K P">
57+
Add StringInputStream. StringInputStream.java should be in main source folder.
5458
</action>
5559
</release>
5660
<release version="2.12.0" date="2023-05-13" description="Java 8 required.">
@@ -255,9 +259,6 @@ The <action> type attribute can be add,update,fix,remove.
255259
<action dev="ggregory" type="add" due-to="Gary Gregory">
256260
Add UncheckedFilterWriter.
257261
</action>
258-
<action dev="ggregory" type="add" due-to="Gary Gregory">
259-
Add StringInputStream.
260-
</action>
261262
<action dev="ggregory" type="add" due-to="Gary Gregory">
262263
Add UncheckedFilterInputStream.
263264
</action>

src/test/java/org/apache/commons/io/input/StringInputStream.java renamed to src/main/java/org/apache/commons/io/input/StringInputStream.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.io.InputStream;
2121
import java.io.StringReader;
2222
import java.nio.charset.Charset;
23+
import java.util.Objects;
2324

2425
import org.apache.commons.io.build.AbstractStreamBuilder;
2526

@@ -28,13 +29,14 @@
2829
*
2930
* @since 2.13.0
3031
*/
31-
public class StringInputStream extends ReaderInputStream {
32+
public final class StringInputStream extends ReaderInputStream {
3233

3334
/**
3435
* Builds a new {@link StringInputStream} instance.
3536
* <p>
3637
* For example:
3738
* </p>
39+
*
3840
* <pre>{@code
3941
* ReaderInputStream s = new StringInputStream.Builder()
4042
* .setString("String")
@@ -57,18 +59,26 @@ public StringInputStream get() {
5759
return new StringInputStream(string, getCharset());
5860
}
5961

60-
public Builder setString(final String string) {
61-
this.string = string;
62+
/**
63+
* Sets the non-null string.
64+
*
65+
* @param source The source string, MUST not be null.
66+
* @return this.
67+
*/
68+
public Builder setString(final String source) {
69+
this.string = Objects.requireNonNull(source, "source");
6270
return this;
6371
}
6472

6573
}
74+
6675
/**
6776
* Creates a new instance on a String for a Charset.
6877
*
69-
* @param source The source string, MUST not be null.
70-
* @param charset The source charset, MUST not be null.
78+
* @param source The source string, MUST not be null.
79+
* @param charset The source charset, null defaults to {@link Charset#defaultCharset()}.
7180
*/
81+
@SuppressWarnings("deprecation")
7282
private StringInputStream(final String source, final Charset charset) {
7383
super(new StringReader(source), charset);
7484
}

src/site/xdoc/index.xml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,19 @@ There are six main areas included:
8585
<!-- ================================================== -->
8686
<section name="Releases">
8787

88+
<subsection name="Commons IO 2.13.0 (requires Java 8)">
89+
<p>
90+
Commons IO 2.13.0 requires a minimum of Java 8 -
91+
<a href="https://commons.apache.org/io/download_io.cgi">Download now!</a>
92+
</p>
93+
<p>
94+
View the
95+
<a href="changes-report.html">Release Notes</a>
96+
and
97+
<a href="apidocs/index.html">Javadoc API documents</a>
98+
</p>
99+
</subsection>
100+
88101
<subsection name="Commons IO 2.12.0 (requires Java 8)">
89102
<p>
90103
Commons IO 2.12.0 requires a minimum of Java 8 -
@@ -94,7 +107,7 @@ There are six main areas included:
94107
View the
95108
<a href="changes-report.html">Release Notes</a>
96109
and
97-
<a href="apidocs/index.html">Javadoc API documents</a>
110+
<a href="https://javadoc.io/doc/commons-io/commons-io/2.12.0/index.html">Javadoc API documents</a>
98111
</p>
99112
</subsection>
100113

0 commit comments

Comments
 (0)