diff --git a/src/main/java/org/cactoos/text/Abbreviated.java b/src/main/java/org/cactoos/text/Abbreviated.java index 536b4a3f0..02f6997e1 100644 --- a/src/main/java/org/cactoos/text/Abbreviated.java +++ b/src/main/java/org/cactoos/text/Abbreviated.java @@ -53,9 +53,9 @@ public final class Abbreviated extends TextEnvelope { * *

By default, the max line width is 80 characters. * - * @param text The Text + * @param text The CharSequence */ - public Abbreviated(final String text) { + public Abbreviated(final CharSequence text) { this(new TextOf(text)); } diff --git a/src/main/java/org/cactoos/text/Base64Decoded.java b/src/main/java/org/cactoos/text/Base64Decoded.java index 5f1f61f46..e34ed6c2a 100644 --- a/src/main/java/org/cactoos/text/Base64Decoded.java +++ b/src/main/java/org/cactoos/text/Base64Decoded.java @@ -37,9 +37,9 @@ public final class Base64Decoded extends TextEnvelope { /** * Ctor. * - * @param input The String + * @param input The CharSequence */ - public Base64Decoded(final String input) { + public Base64Decoded(final CharSequence input) { this(new TextOf(input)); } diff --git a/src/main/java/org/cactoos/text/Base64Encoded.java b/src/main/java/org/cactoos/text/Base64Encoded.java index 05852b6d3..84ac8741a 100644 --- a/src/main/java/org/cactoos/text/Base64Encoded.java +++ b/src/main/java/org/cactoos/text/Base64Encoded.java @@ -38,9 +38,9 @@ public final class Base64Encoded extends TextEnvelope { /** * Ctor. * - * @param input The String + * @param input The CharSequence */ - public Base64Encoded(final String input) { + public Base64Encoded(final CharSequence input) { this(new TextOf(input)); } diff --git a/src/main/java/org/cactoos/text/Capitalized.java b/src/main/java/org/cactoos/text/Capitalized.java index 00042e832..dcadd6cf6 100644 --- a/src/main/java/org/cactoos/text/Capitalized.java +++ b/src/main/java/org/cactoos/text/Capitalized.java @@ -42,7 +42,7 @@ public final class Capitalized extends TextEnvelope { * * @param text The text */ - public Capitalized(final String text) { + public Capitalized(final CharSequence text) { this(new TextOf(text)); } diff --git a/src/main/java/org/cactoos/text/Concatenated.java b/src/main/java/org/cactoos/text/Concatenated.java index 562547d53..f0ceab96b 100644 --- a/src/main/java/org/cactoos/text/Concatenated.java +++ b/src/main/java/org/cactoos/text/Concatenated.java @@ -46,9 +46,9 @@ public Concatenated(final Text... txts) { /** * Ctor. - * @param strs Strings to be concatenated + * @param strs CharSequences to be concatenated */ - public Concatenated(final String... strs) { + public Concatenated(final CharSequence... strs) { this( new Mapped<>( TextOf::new, diff --git a/src/main/java/org/cactoos/text/Contains.java b/src/main/java/org/cactoos/text/Contains.java index 92a36a5bb..a096a1f76 100644 --- a/src/main/java/org/cactoos/text/Contains.java +++ b/src/main/java/org/cactoos/text/Contains.java @@ -48,7 +48,7 @@ public final class Contains implements Scalar { * @param origin The origin * @param other The other */ - public Contains(final String origin, final String other) { + public Contains(final CharSequence origin, final CharSequence other) { this(new TextOf(origin), new TextOf(other)); } @@ -57,7 +57,7 @@ public Contains(final String origin, final String other) { * @param origin The origin * @param other The other */ - public Contains(final String origin, final Text other) { + public Contains(final CharSequence origin, final Text other) { this(new TextOf(origin), other); } diff --git a/src/main/java/org/cactoos/text/EndsWith.java b/src/main/java/org/cactoos/text/EndsWith.java index a9da4705a..1b3376c5b 100644 --- a/src/main/java/org/cactoos/text/EndsWith.java +++ b/src/main/java/org/cactoos/text/EndsWith.java @@ -48,7 +48,7 @@ public final class EndsWith implements Scalar { * @param origin The origin * @param suffix The suffix */ - public EndsWith(final Text origin, final String suffix) { + public EndsWith(final Text origin, final CharSequence suffix) { this(origin, new TextOf(suffix)); } diff --git a/src/main/java/org/cactoos/text/FormattedText.java b/src/main/java/org/cactoos/text/FormattedText.java index 293aa6244..64be149d5 100644 --- a/src/main/java/org/cactoos/text/FormattedText.java +++ b/src/main/java/org/cactoos/text/FormattedText.java @@ -94,7 +94,7 @@ public FormattedText( * @param ptn Pattern * @param arguments Arguments */ - public FormattedText(final String ptn, final Collection arguments) { + public FormattedText(final CharSequence ptn, final Collection arguments) { this(ptn, Locale.getDefault(Locale.Category.FORMAT), arguments); } @@ -116,7 +116,7 @@ public FormattedText(final Text ptn, final Collection arguments) { * @param arguments Arguments */ public FormattedText( - final String ptn, + final CharSequence ptn, final Locale locale, final Collection arguments ) { diff --git a/src/main/java/org/cactoos/text/Joined.java b/src/main/java/org/cactoos/text/Joined.java index db9744981..0cebaca5e 100644 --- a/src/main/java/org/cactoos/text/Joined.java +++ b/src/main/java/org/cactoos/text/Joined.java @@ -42,7 +42,7 @@ public final class Joined extends TextEnvelope { * @param delimit Delimit among strings * @param strs Strings to be joined */ - public Joined(final String delimit, final String... strs) { + public Joined(final CharSequence delimit, final CharSequence... strs) { this(delimit, new IterableOf<>(strs)); } @@ -51,7 +51,7 @@ public Joined(final String delimit, final String... strs) { * @param delimit Delimit among strings * @param strs Strings to be joined */ - public Joined(final String delimit, final Iterable strs) { + public Joined(final CharSequence delimit, final Iterable strs) { this( new TextOf(delimit), new Mapped<>(TextOf::new, strs) diff --git a/src/main/java/org/cactoos/text/Lowered.java b/src/main/java/org/cactoos/text/Lowered.java index 3042faa07..47562a0fb 100644 --- a/src/main/java/org/cactoos/text/Lowered.java +++ b/src/main/java/org/cactoos/text/Lowered.java @@ -39,7 +39,7 @@ public final class Lowered extends TextEnvelope { * Ctor. * @param text The text */ - public Lowered(final String text) { + public Lowered(final CharSequence text) { this(new TextOf(text)); } diff --git a/src/main/java/org/cactoos/text/Mapped.java b/src/main/java/org/cactoos/text/Mapped.java index 9dbfc71a2..f4064c167 100644 --- a/src/main/java/org/cactoos/text/Mapped.java +++ b/src/main/java/org/cactoos/text/Mapped.java @@ -39,7 +39,7 @@ public final class Mapped extends TextEnvelope { * @param fnc Function to apply * @param txt Original text */ - public Mapped(final Func fnc, final Text txt) { + public Mapped(final Func fnc, final Text txt) { super(new TextOf(() -> fnc.apply(txt.asString()))); } diff --git a/src/main/java/org/cactoos/text/Normalized.java b/src/main/java/org/cactoos/text/Normalized.java index f86754ce8..06c7fd484 100644 --- a/src/main/java/org/cactoos/text/Normalized.java +++ b/src/main/java/org/cactoos/text/Normalized.java @@ -37,7 +37,7 @@ public final class Normalized extends TextEnvelope { * Ctor. * @param text A Text */ - public Normalized(final String text) { + public Normalized(final CharSequence text) { this(new TextOf(text)); } @@ -55,4 +55,3 @@ public Normalized(final Text text) { ); } } - diff --git a/src/main/java/org/cactoos/text/PrefixOf.java b/src/main/java/org/cactoos/text/PrefixOf.java index 33ed6e6c2..643dd2235 100644 --- a/src/main/java/org/cactoos/text/PrefixOf.java +++ b/src/main/java/org/cactoos/text/PrefixOf.java @@ -24,8 +24,6 @@ package org.cactoos.text; import org.cactoos.Text; -import org.cactoos.func.FuncOf; -import org.cactoos.scalar.Constant; import org.cactoos.scalar.ScalarOf; import org.cactoos.scalar.Ternary; @@ -40,10 +38,10 @@ public final class PrefixOf extends TextEnvelope { /** * Ctor. - * @param text Text representing the text value - * @param boundary String to which text will be split + * @param text CharSequence representing the text value + * @param boundary CharSequence to which text will be split */ - public PrefixOf(final String text, final String boundary) { + public PrefixOf(final CharSequence text, final CharSequence boundary) { this(new TextOf(text), boundary); } @@ -52,13 +50,13 @@ public PrefixOf(final String text, final String boundary) { * @param text Text representing the text value * @param boundary String to which text will be split */ - public PrefixOf(final Text text, final String boundary) { + public PrefixOf(final Text text, final CharSequence boundary) { super( new Flattened( new Ternary<>( new ScalarOf<>(() -> new Sticky(text)), - (Text t) -> t.asString().indexOf(boundary) >= 0, - t -> new Sub(t, 0, s -> s.indexOf(boundary)), + (Text t) -> t.asString().contains(boundary.toString()), + t -> new Sub(t, 0, s -> s.indexOf(boundary.toString())), t -> t ) ) diff --git a/src/main/java/org/cactoos/text/Repeated.java b/src/main/java/org/cactoos/text/Repeated.java index 515738c42..2dec6e3ea 100644 --- a/src/main/java/org/cactoos/text/Repeated.java +++ b/src/main/java/org/cactoos/text/Repeated.java @@ -39,7 +39,7 @@ public final class Repeated extends TextEnvelope { * @param text A String * @param count How many times repeat the Text */ - public Repeated(final String text, final int count) { + public Repeated(final CharSequence text, final int count) { this(new TextOf(text), count); } diff --git a/src/main/java/org/cactoos/text/Split.java b/src/main/java/org/cactoos/text/Split.java index 2ed80241b..6a5637f07 100644 --- a/src/main/java/org/cactoos/text/Split.java +++ b/src/main/java/org/cactoos/text/Split.java @@ -44,7 +44,7 @@ public final class Split extends IterableEnvelope { * @param rgx The regex * @see String#split(String) */ - public Split(final String text, final String rgx) { + public Split(final CharSequence text, final CharSequence rgx) { this(new TextOf(text), new TextOf(rgx)); } @@ -56,7 +56,7 @@ public Split(final String text, final String rgx) { * @param lmt The limit * @see String#split(String, int) */ - public Split(final String text, final String rgx, final int lmt) { + public Split(final CharSequence text, final CharSequence rgx, final int lmt) { this(new TextOf(text), new TextOf(rgx), lmt); } @@ -66,7 +66,7 @@ public Split(final String text, final String rgx, final int lmt) { * @param rgx The regex * @see String#split(String) */ - public Split(final String text, final Text rgx) { + public Split(final CharSequence text, final Text rgx) { this(new TextOf(text), rgx); } @@ -87,7 +87,7 @@ public Split(final String text, final Text rgx, final int lmt) { * @param rgx The regex * @see String#split(String) */ - public Split(final Text text, final String rgx) { + public Split(final Text text, final CharSequence rgx) { this(text, new TextOf(rgx)); } diff --git a/src/main/java/org/cactoos/text/StartsWith.java b/src/main/java/org/cactoos/text/StartsWith.java index 4ed2022a8..822aaab88 100644 --- a/src/main/java/org/cactoos/text/StartsWith.java +++ b/src/main/java/org/cactoos/text/StartsWith.java @@ -62,7 +62,7 @@ public StartsWith(final Text text, final Text prefix) { * @param text The text * @param prefix The prefix */ - public StartsWith(final String text, final String prefix) { + public StartsWith(final CharSequence text, final CharSequence prefix) { this(new TextOf(text), new TextOf(prefix)); } diff --git a/src/main/java/org/cactoos/text/Sub.java b/src/main/java/org/cactoos/text/Sub.java index ae708aa25..5683547e4 100644 --- a/src/main/java/org/cactoos/text/Sub.java +++ b/src/main/java/org/cactoos/text/Sub.java @@ -42,7 +42,7 @@ public final class Sub extends TextEnvelope { * @param text The String * @param strt Start position in the text */ - public Sub(final String text, final int strt) { + public Sub(final CharSequence text, final int strt) { this(new TextOf(text), strt); } @@ -52,7 +52,7 @@ public Sub(final String text, final int strt) { * @param strt Start position in the text * @param finish End position in the text */ - public Sub(final String text, final int strt, final int finish) { + public Sub(final CharSequence text, final int strt, final int finish) { this(new TextOf(text), strt, finish); } diff --git a/src/main/java/org/cactoos/text/SuffixOf.java b/src/main/java/org/cactoos/text/SuffixOf.java index 42acaec47..dae8954a3 100644 --- a/src/main/java/org/cactoos/text/SuffixOf.java +++ b/src/main/java/org/cactoos/text/SuffixOf.java @@ -24,6 +24,7 @@ package org.cactoos.text; import org.cactoos.Text; +import org.cactoos.scalar.LengthOf; import org.cactoos.scalar.ScalarOf; import org.cactoos.scalar.Ternary; @@ -41,7 +42,7 @@ public final class SuffixOf extends TextEnvelope { * @param text Text representing the text value * @param boundary String after which text will be split */ - public SuffixOf(final String text, final String boundary) { + public SuffixOf(final CharSequence text, final CharSequence boundary) { this(new TextOf(text), boundary); } @@ -50,15 +51,16 @@ public SuffixOf(final String text, final String boundary) { * @param text Text representing the text value * @param boundary String after which text will be split */ - public SuffixOf(final Text text, final String boundary) { + public SuffixOf(final Text text, final CharSequence boundary) { super( new Flattened( new Ternary<>( new ScalarOf<>(() -> new Sticky(text)), - (Text t) -> t.asString().indexOf(boundary) >= 0, + (Text t) -> t.asString().contains(boundary.toString()), t -> new Sub( t, - s -> s.indexOf(boundary) + boundary.length() + s -> s.indexOf(boundary.toString()) + + boundary.length() ), t -> new TextOf("") ) diff --git a/src/main/java/org/cactoos/text/TextOf.java b/src/main/java/org/cactoos/text/TextOf.java index 42ed8209c..4e1a52865 100644 --- a/src/main/java/org/cactoos/text/TextOf.java +++ b/src/main/java/org/cactoos/text/TextOf.java @@ -169,20 +169,20 @@ public TextOf(final Reader rdr, final int max, final Charset cset) { /** * Ctor. * - * @param builder The String builder + * @param str The CharSequence */ - public TextOf(final CharSequence builder) { - this(new BytesOf(builder)); + public TextOf(final CharSequence str) { + this(new BytesOf(str)); } /** * Ctor. * - * @param builder The String builder + * @param str The CharSequence * @param cset The Charset */ - public TextOf(final CharSequence builder, final Charset cset) { - this(new BytesOf(builder, cset), cset); + public TextOf(final CharSequence str, final Charset cset) { + this(new BytesOf(str, cset), cset); } /** @@ -368,7 +368,7 @@ public TextOf(final InputStream input) { * * @param scalar The Scalar of String */ - public TextOf(final Scalar scalar) { + public TextOf(final Scalar scalar) { this(new TextOfScalar(scalar)); } diff --git a/src/main/java/org/cactoos/text/TextOfScalar.java b/src/main/java/org/cactoos/text/TextOfScalar.java index 42d9ed31c..12a4a6e22 100644 --- a/src/main/java/org/cactoos/text/TextOfScalar.java +++ b/src/main/java/org/cactoos/text/TextOfScalar.java @@ -39,22 +39,22 @@ public final class TextOfScalar implements Text { /** - * String value of the envelope. + * Value of the envelope. */ - private final Scalar origin; + private final Scalar origin; /** * Ctor. * - * @param scalar The Scalar of String + * @param scalar The scalar of CharSequence */ - public TextOfScalar(final Scalar scalar) { + public TextOfScalar(final Scalar scalar) { this.origin = scalar; } @Override public String asString() throws Exception { - return this.origin.value(); + return this.origin.value().toString(); } @Override diff --git a/src/main/java/org/cactoos/text/Upper.java b/src/main/java/org/cactoos/text/Upper.java index 4615ae274..5443d73c7 100644 --- a/src/main/java/org/cactoos/text/Upper.java +++ b/src/main/java/org/cactoos/text/Upper.java @@ -40,7 +40,7 @@ public final class Upper extends TextEnvelope { * Ctor. * @param text The text */ - public Upper(final String text) { + public Upper(final CharSequence text) { this(new TextOf(text)); }