You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2020/11/10 11:05:02 UTC
[GitHub] [commons-lang] arturobernalg opened a new pull request #645: [LANG-1614] - Split fixed-length elements
arturobernalg opened a new pull request #645:
URL: https://github.com/apache/commons-lang/pull/645
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [commons-lang] coveralls edited a comment on pull request #645: [LANG-1614] - Split fixed-length elements
Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on pull request #645:
URL: https://github.com/apache/commons-lang/pull/645#issuecomment-724649495
[](https://coveralls.io/builds/35027848)
Coverage increased (+0.01%) to 95.001% when pulling **051ba42d3423f0a3ea214d4112930c419f30c428 on arturobernalg:feature/LANG-1614** into **61e82e832e31037810cec0c526ecd83fbeb62227 on apache:master**.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [commons-lang] arturobernalg commented on a change in pull request #645: [LANG-1614] - Split fixed-length elements
Posted by GitBox <gi...@apache.org>.
arturobernalg commented on a change in pull request #645:
URL: https://github.com/apache/commons-lang/pull/645#discussion_r528168674
##########
File path: src/main/java/org/apache/commons/lang3/StringUtils.java
##########
@@ -7731,6 +7731,48 @@ public static String rotate(final String str, final int shift) {
return substrings.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
}
+ /**
+ * Split a {@link String} into a {@code String []} of fixed-length elements.
+ *
+ * <pre>
+ * StringUtils.splitEvery("test1",10) = ["test1"]
+ * StringUtils.splitEvery("test2", 4) = ["test","2"]
+ * StringUtils.splitEvery("testAbgTestsABG", -2) = ["testAbgTestsABG"]
+ * StringUtils.splitEvery("",10) = [""]
+ * StringUtils.splitEvery(null,4) = {@code null}
+ * StringUtils.splitEvery("testAbgTestsABG",2) = ["te","st","Ab","gT","es","ts","AB","G"]
+ * </pre>
+ *
+ * @param str {@link String} to split into fixed length elements.
+ * @param length length of the elements into which the String will be divided.
+ * @return a {@code String []} of fixed-length elements.
+ */
+ public static String[] splitEvery( final String str, final int length ) {
Review comment:
Hi
usually in the others method return null . An. example of that -->
` public static String abbreviateMiddle(final String str, final String middle, final int length) {
if (isAnyEmpty(str, middle) || length >= str.length() || length < middle.length()+2) {
return str;
}`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [commons-lang] arturobernalg closed pull request #645: [LANG-1614] - Split fixed-length elements
Posted by GitBox <gi...@apache.org>.
arturobernalg closed pull request #645:
URL: https://github.com/apache/commons-lang/pull/645
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [commons-lang] coveralls commented on pull request #645: [LANG-1614] - Split fixed-length elements
Posted by GitBox <gi...@apache.org>.
coveralls commented on pull request #645:
URL: https://github.com/apache/commons-lang/pull/645#issuecomment-724649495
[](https://coveralls.io/builds/34852760)
Coverage increased (+0.005%) to 94.951% when pulling **a11dcae478e274bd35668f81af6847d4326273b5 on arturobernalg:feature/LANG-1614** into **6b3f258ed7f8737740a22599458c0c468864b837 on apache:master**.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [GitHub] [commons-lang] aakashgupta96 commented on a change in
pull request #645: [LANG-1614] - Split fixed-length elements
Posted by Gary Gregory <ga...@gmail.com>.
I think we need to think about defining what kind of boundary we want
between Commons Lang and Commons Text before StringUtils becomes even more
of a kitchen sink.
Gary
On Fri, Nov 20, 2020, 08:20 GitBox <gi...@apache.org> wrote:
>
> aakashgupta96 commented on a change in pull request #645:
> URL: https://github.com/apache/commons-lang/pull/645#discussion_r527685407
>
>
>
> ##########
> File path: src/main/java/org/apache/commons/lang3/StringUtils.java
> ##########
> @@ -7731,6 +7731,48 @@ public static String rotate(final String str, final
> int shift) {
> return substrings.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
> }
>
> + /**
> + * Split a {@link String} into a {@code String []} of fixed-length
> elements.
> + *
> + * <pre>
> + * StringUtils.splitEvery("test1",10) = ["test1"]
> + * StringUtils.splitEvery("test2", 4) = ["test","2"]
> + * StringUtils.splitEvery("testAbgTestsABG", -2) =
> ["testAbgTestsABG"]
> + * StringUtils.splitEvery("",10) = [""]
> + * StringUtils.splitEvery(null,4) = {@code null}
> + * StringUtils.splitEvery("testAbgTestsABG",2) =
> ["te","st","Ab","gT","es","ts","AB","G"]
> + * </pre>
> + *
> + * @param str {@link String} to split into fixed length elements.
> + * @param length length of the elements into which the String will be
> divided.
> + * @return a {@code String []} of fixed-length elements.
> + */
> + public static String[] splitEvery( final String str, final int length
> ) {
>
> Review comment:
> I think it'll be better to throw `IllegalArgumentException` in case
> `length <1 || length > str.length()`. @arturobernalg Thoughts?
>
>
>
>
> ----------------------------------------------------------------
> This is an automated message from the Apache Git Service.
> To respond to the message, please log on to GitHub and use the
> URL above to go to the specific comment.
>
> For queries about this service, please contact Infrastructure at:
> users@infra.apache.org
>
>
>
[GitHub] [commons-lang] aakashgupta96 commented on a change in pull request #645: [LANG-1614] - Split fixed-length elements
Posted by GitBox <gi...@apache.org>.
aakashgupta96 commented on a change in pull request #645:
URL: https://github.com/apache/commons-lang/pull/645#discussion_r527685407
##########
File path: src/main/java/org/apache/commons/lang3/StringUtils.java
##########
@@ -7731,6 +7731,48 @@ public static String rotate(final String str, final int shift) {
return substrings.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
}
+ /**
+ * Split a {@link String} into a {@code String []} of fixed-length elements.
+ *
+ * <pre>
+ * StringUtils.splitEvery("test1",10) = ["test1"]
+ * StringUtils.splitEvery("test2", 4) = ["test","2"]
+ * StringUtils.splitEvery("testAbgTestsABG", -2) = ["testAbgTestsABG"]
+ * StringUtils.splitEvery("",10) = [""]
+ * StringUtils.splitEvery(null,4) = {@code null}
+ * StringUtils.splitEvery("testAbgTestsABG",2) = ["te","st","Ab","gT","es","ts","AB","G"]
+ * </pre>
+ *
+ * @param str {@link String} to split into fixed length elements.
+ * @param length length of the elements into which the String will be divided.
+ * @return a {@code String []} of fixed-length elements.
+ */
+ public static String[] splitEvery( final String str, final int length ) {
Review comment:
I think it'll be better to throw `IllegalArgumentException` in case `length <1 || length > str.length()`. @arturobernalg Thoughts?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org