Skip to content

Commit 148bbba

Browse files
author
tjann
committed
Adding an OOP analogue for StringUtils.splitPreserveAllTokens
1 parent 05879a2 commit 148bbba

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/main/java/org/cactoos/func/BiFuncSplitPreserve.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
public class BiFuncSplitPreserve implements BiFunc<String, String, Collection<String>> {
3333
@Override
34-
public Collection<String> apply(String str, String regex) throws Exception {
34+
public Collection<String> apply(final String str, final String regex) throws Exception {
3535
ListOf<String> ret = new ListOf<>();
3636
int start = 0;
3737
int pos = str.indexOf(regex);

src/main/java/org/cactoos/text/SplitPreserveAllTokens.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public final class SplitPreserveAllTokens extends IterableEnvelope<Text> {
4545
* @param text The text
4646
* @see String#split(String)
4747
*/
48+
4849
public SplitPreserveAllTokens(final CharSequence text) {
4950
this(new TextOf(text), new TextOf(" "));
5051
}
@@ -58,13 +59,15 @@ public SplitPreserveAllTokens(final CharSequence text) {
5859
public SplitPreserveAllTokens(final Text text) {
5960
this(text, new TextOf(" "));
6061
}
62+
6163
/**
6264
* Ctor.
6365
*
6466
* @param text The text
6567
* @param lmt The limit
6668
* @see String#split(String, int)
6769
*/
70+
6871
public SplitPreserveAllTokens(final CharSequence text, final int lmt) {
6972
this(new TextOf(text), new TextOf(" "), lmt);
7073
}
@@ -76,16 +79,19 @@ public SplitPreserveAllTokens(final CharSequence text, final int lmt) {
7679
* @param lmt The limit
7780
* @see String#split(String, int)
7881
*/
82+
7983
public SplitPreserveAllTokens(final Text text, final int lmt) {
8084
this(text, new TextOf(" "), lmt);
8185
}
86+
8287
/**
8388
* Ctor.
8489
*
8590
* @param text The text
8691
* @param rgx The regex
8792
* @see String#split(String)
8893
*/
94+
8995
public SplitPreserveAllTokens(final CharSequence text, final CharSequence rgx) {
9096
this(new TextOf(text), new TextOf(rgx));
9197
}
@@ -98,6 +104,7 @@ public SplitPreserveAllTokens(final CharSequence text, final CharSequence rgx) {
98104
* @param lmt The limit
99105
* @see String#split(String, int)
100106
*/
107+
101108
public SplitPreserveAllTokens(final CharSequence text, final CharSequence rgx, final int lmt) {
102109
this(new TextOf(text), new TextOf(rgx), lmt);
103110
}
@@ -108,6 +115,7 @@ public SplitPreserveAllTokens(final CharSequence text, final CharSequence rgx, f
108115
* @param rgx The regex
109116
* @see String#split(String)
110117
*/
118+
111119
public SplitPreserveAllTokens(final CharSequence text, final Text rgx) {
112120
this(new TextOf(text), rgx);
113121
}
@@ -119,6 +127,7 @@ public SplitPreserveAllTokens(final CharSequence text, final Text rgx) {
119127
* @param lmt The limit
120128
* @see String#split(String, int)
121129
*/
130+
122131
public SplitPreserveAllTokens(final CharSequence text, final Text rgx, final int lmt) {
123132
this(new TextOf(text), rgx, lmt);
124133
}
@@ -129,6 +138,7 @@ public SplitPreserveAllTokens(final CharSequence text, final Text rgx, final int
129138
* @param rgx The regex
130139
* @see String#split(String)
131140
*/
141+
132142
public SplitPreserveAllTokens(final Text text, final CharSequence rgx) {
133143
this(text, new TextOf(rgx));
134144
}
@@ -140,6 +150,7 @@ public SplitPreserveAllTokens(final Text text, final CharSequence rgx) {
140150
* @param lmt The limit
141151
* @see String#split(String, int)
142152
*/
153+
143154
public SplitPreserveAllTokens(final Text text, final CharSequence rgx, final int lmt) {
144155
this(text, new TextOf(rgx), lmt);
145156
}
@@ -150,6 +161,7 @@ public SplitPreserveAllTokens(final Text text, final CharSequence rgx, final int
150161
* @param rgx The regex
151162
* @see String#split(String)
152163
*/
164+
153165
public SplitPreserveAllTokens(final Text text, final Text rgx) {
154166
this(text, rgx, 0);
155167
}
@@ -161,6 +173,7 @@ public SplitPreserveAllTokens(final Text text, final Text rgx) {
161173
* @param lmt The limit
162174
* @see String#split(String, int)
163175
*/
176+
164177
public SplitPreserveAllTokens(
165178
final Text text, final Text rgx, final int lmt
166179
) {

0 commit comments

Comments
 (0)