Re: [SITE] Adopting the new ASF Logo

2016-01-28 Thread Loic Guibert
OK, thanks Benedikt.
I've attached the PNG files and the source SVG.
I've made 4 versions to see what kind of style is the most appreciate...
Hoping you will appreciate one of them... ;-)

Loic Guibert
PGP : 0x65EB4F33

Le 28/01/2016 17:39, Benedikt Ritter a écrit :
> Hello Loic,
>
> 2016-01-28 14:35 GMT+01:00 Loic Guibert <lguib...@apache.org>:
>
>> Yes, good idea.
>> Are you creating it ?
>>
> Here is the ticket [1]
>
> Regards,
> Benedikt
>
> [1] https://issues.apache.org/jira/browse/COMMONSSITE-86
>
>
>> I'll be able to push the PNG format of my first shot ;-)
>>
>> Loic Guibert
>> PGP : 0x65EB4F33
>>
>> Le 28/01/2016 17:02, Benedikt Ritter a écrit :
>>> Hi Loic,
>>>
>>> very good! Would probably be best to create a ticket for the COMMONSSITE
>>> project in jira to track this.
>>>
>>> Benedikt
>>>
>>> 2016-01-28 13:13 GMT+01:00 Loic Guibert <lguib...@apache.org>:
>>>
>>>> Hi,
>>>> I can try and make propositions.
>>>> I'll get the logo sources...
>>>>
>>>> Loic Guibert
>>>> PGP : 0x65EB4F33
>>>>
>>>> Le 28/01/2016 16:01, Benedikt Ritter a écrit :
>>>>> Hi all,
>>>>>
>>>>> we're still using the "old" Feather logo throughout our websites. Is
>>>>> anybody capable of creating a logo based on the new Feather logo?
>>>>>
>>>>> Regards,
>>>>> Benedikt
>>>>>
>>>> -
>>>> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
>>>> For additional commands, e-mail: dev-h...@commons.apache.org
>>>>
>>>>
>>
>> -
>> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
>> For additional commands, e-mail: dev-h...@commons.apache.org
>>
>>
>


-
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org



Re: [SITE] Adopting the new ASF Logo

2016-01-28 Thread Loic Guibert
I just do a quick shot.
I use DejaVu fonts. It's a free derivative work of Bitstream and Arev fonts.

But i'm not sure we can use them for create logo without name the
authors of the font and/or original font.
I'm not very good at licences ;-)

http://dejavu-fonts.org/wiki/Main_Page
http://dejavu-fonts.org/wiki/License


Loic Guibert
PGP : 0x65EB4F33

Le 28/01/2016 16:13, Loic Guibert a écrit :
> Hi,
> I can try and make propositions.
> I'll get the logo sources...
>
> Loic Guibert
> PGP : 0x65EB4F33
>
> Le 28/01/2016 16:01, Benedikt Ritter a écrit :
>> Hi all,
>>
>> we're still using the "old" Feather logo throughout our websites. Is
>> anybody capable of creating a logo based on the new Feather logo?
>>
>> Regards,
>> Benedikt
>>
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
> For additional commands, e-mail: dev-h...@commons.apache.org
>


-
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Re: [SITE] Adopting the new ASF Logo

2016-01-28 Thread Loic Guibert
Ah,
I sent 2 files, the PNG and the SVG format but only the SVG is shown in
the mail I received from the mail list...
I try again...

Loic Guibert
PGP : 0x65EB4F33

Le 28/01/2016 17:12, Loic Guibert a écrit :
> I just do a quick shot.
> I use DejaVu fonts. It's a free derivative work of Bitstream and Arev fonts.
>
> But i'm not sure we can use them for create logo without name the
> authors of the font and/or original font.
> I'm not very good at licences ;-)
>
> http://dejavu-fonts.org/wiki/Main_Page
> http://dejavu-fonts.org/wiki/License
>
>
> Loic Guibert
> PGP : 0x65EB4F33
>
> Le 28/01/2016 16:13, Loic Guibert a écrit :
>> Hi,
>> I can try and make propositions.
>> I'll get the logo sources...
>>
>> Loic Guibert
>> PGP : 0x65EB4F33
>>
>> Le 28/01/2016 16:01, Benedikt Ritter a écrit :
>>> Hi all,
>>>
>>> we're still using the "old" Feather logo throughout our websites. Is
>>> anybody capable of creating a logo based on the new Feather logo?
>>>
>>> Regards,
>>> Benedikt
>>>
>> -
>> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
>> For additional commands, e-mail: dev-h...@commons.apache.org
>>
>
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
> For additional commands, e-mail: dev-h...@commons.apache.org



-
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Re: [SITE] Adopting the new ASF Logo

2016-01-28 Thread Loic Guibert
Hi,
I can try and make propositions.
I'll get the logo sources...

Loic Guibert
PGP : 0x65EB4F33

Le 28/01/2016 16:01, Benedikt Ritter a écrit :
> Hi all,
>
> we're still using the "old" Feather logo throughout our websites. Is
> anybody capable of creating a logo based on the new Feather logo?
>
> Regards,
> Benedikt
>


-
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org



Re: [SITE] Adopting the new ASF Logo

2016-01-28 Thread Loic Guibert
Yes, good idea.
Are you creating it ?

I'll be able to push the PNG format of my first shot ;-)

Loic Guibert
PGP : 0x65EB4F33

Le 28/01/2016 17:02, Benedikt Ritter a écrit :
> Hi Loic,
>
> very good! Would probably be best to create a ticket for the COMMONSSITE
> project in jira to track this.
>
> Benedikt
>
> 2016-01-28 13:13 GMT+01:00 Loic Guibert <lguib...@apache.org>:
>
>> Hi,
>> I can try and make propositions.
>> I'll get the logo sources...
>>
>> Loic Guibert
>> PGP : 0x65EB4F33
>>
>> Le 28/01/2016 16:01, Benedikt Ritter a écrit :
>>> Hi all,
>>>
>>> we're still using the "old" Feather logo throughout our websites. Is
>>> anybody capable of creating a logo based on the new Feather logo?
>>>
>>> Regards,
>>> Benedikt
>>>
>>
>> -
>> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
>> For additional commands, e-mail: dev-h...@commons.apache.org
>>
>>
>


-
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org



Re: [SITE] Adopting the new ASF Logo

2016-01-28 Thread Loic Guibert
No, it's close to but not the same.
I don't known what font is used in the new ASF logo.

Loic Guibert
PGP : 0x65EB4F33

Le 28/01/2016 17:36, Emmanuel Bourg a écrit :
> Le 28/01/2016 14:12, Loic Guibert a écrit :
>> I just do a quick shot.
>> I use DejaVu fonts. It's a free derivative work of Bitstream and Arev fonts.
> Is this the same font than the one used in the new Apache logo?
>
> Emmanuel Bourg
>
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
> For additional commands, e-mail: dev-h...@commons.apache.org
>


-
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org



Re: [lang] release 3.5

2016-01-25 Thread Loic Guibert
I'm currently pretty busy at work, i don't have much time to work on
Commons-Lang too.
Sorry.
Regards,

Loic Guibert
PGP : 0x65EB4F33

Le 18/01/2016 15:52, Benedikt Ritter a écrit :
> Hi,
>
> 2016-01-16 6:41 GMT+01:00 Loic Guibert <lguib...@apache.org>:
>
>> Hi, great !
>>
>> There are some ticket/PR open and handled by committers.
>> Perhaps we can resolve those can be done quickly before releasing ?
>>
> I currently don't have the time to work on [lang]. Please feel free to fix
> any issues I have assigned to myself.
>
> Regards,
> Benedikt
>
>
>> AFAIAC, i've this one on which we have to discuss about some
>> implementation points :
>> https://github.com/apache/commons-lang/pull/75
>> https://issues.apache.org/jira/browse/LANG-1124
>>
>> Regards,
>>
>> Loic Guibert
>> PGP : 0x65EB4F33
>>
>> Le 16/01/2016 04:21, Gary Gregory a écrit :
>>> Shall we have a go at releasing 3.5? There is quite a change set to push
>>> out :-)
>>>
>>> Gary
>>>
>>
>> -
>> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
>> For additional commands, e-mail: dev-h...@commons.apache.org
>>
>>
>


-
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org



Re: [lang] release 3.5

2016-01-15 Thread Loic Guibert
Hi, great !

There are some ticket/PR open and handled by committers.
Perhaps we can resolve those can be done quickly before releasing ?

AFAIAC, i've this one on which we have to discuss about some
implementation points :
https://github.com/apache/commons-lang/pull/75
https://issues.apache.org/jira/browse/LANG-1124

Regards,

Loic Guibert
PGP : 0x65EB4F33

Le 16/01/2016 04:21, Gary Gregory a écrit :
> Shall we have a go at releasing 3.5? There is quite a change set to push
> out :-)
>
> Gary
>


-
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org



[LANG] Add StringUtils methods to compare a string to multiple strings

2015-11-05 Thread Loic Guibert
Hello,
there are 2 tickets on JIRA on this same new feature:
Add StringUtils methods to compare a string to multiple strings
(equalsAny, equalsAnyIgnoreCase)

  https://issues.apache.org/jira/browse/LANG-704
  https://issues.apache.org/jira/browse/LANG-1169

I review the 2 proposed implementation and I think we should keep
the last one (LANG-1169 / GitHub PR #109).

In the patch submitted for LANG-704, I disagree with these results,
it sounds illogical for me :
  StringUtils.equalsAnyOf(null, null, null) = false
  StringUtils.equalsAnyOf(null, (CharSequence[]) null) = true

For the LANG-1169 / GitHub PR #109, all seems good for me
I would just add some tests (I tested them, they are OK) :
  assertFalse(StringUtils.equalsAny(null, (CharSequence[]) null));
  assertTrue(StringUtils.equalsAny(FOO, new CustomCharSequence("foo")));
  assertTrue(StringUtils.equalsAny(FOO, new StringBuilder("foo")));
  assertFalse(StringUtils.equalsAny(FOO, new CustomCharSequence("fOo")));
  assertFalse(StringUtils.equalsAny(FOO, new StringBuilder("fOo")));

  assertFalse(StringUtils.equalsAnyIgnoreCase(null, (CharSequence[]) null));
  assertTrue(StringUtils.equalsAnyIgnoreCase(FOO, new
CustomCharSequence("fOo")));
  assertTrue(StringUtils.equalsAnyIgnoreCase(FOO, new
StringBuilder("fOo")));


If nobody objects or disagree with it, I'll :
  - close LANG-704 (duplicate LANG-1169)
  - merge PR #109
  - add the supplementary tests
  - mark LANG-1169 resolved


Regards,

-- 
Loic Guibert
PGP : 0x65EB4F33


-
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org



Re: [LANG] Adding StringUtils replace by regular expression methods

2015-10-20 Thread Loic Guibert
Hello,
I proposed some time ago to add in StringUtils 2 null safe methods
to replace into a String with regular expression
and I'd like to hear opinions about that.

I opened a JIRA ticket (LANG-1139) :
https://issues.apache.org/jira/browse/LANG-1139

and an associated Pull Request (#92) :
https://github.com/apache/commons-lang/pull/92


Moreover, there is an existing method
(which add Pattern#DOTALL option by default) :
  * StringUtils.replacePattern(String source, String regex, String
replacement)
that is not null safe.

I think to modify it to follow the same behavior as the 2 new methods:
  * StringUtils.replacePattern(null, *, *) = null
  * StringUtils.replacePattern("any", null, *) = "any"
  * StringUtils.replacePattern("any", *, null) = "any"

This will impact this method :
  * removePattern(String source, String regex)
as it calls "replacePattern(source, regex, StringUtils.EMPTY);"
and it'll become null safe to.

In addition to the 2 new replace methods,
I could also add the pending remove methods :

  - String removeAll(String text, String regex);
  - String removeFirst(String text, String regex);


If nobody objects, I'll go on and commit the proposed changes.


Loic Guibert
PGP : 0x65EB4F33


Le 28/05/2015 16:42, Loic Guibert a écrit :
> Hello,
> I implemented 2 null safe methods to replace into a String with regular
> expression :
>   - String replaceAll(String text, String regex, String replacement);
>   - String replaceFirst(String text, String regex, String replacement);
>
>
> The StringUtils.replacePattern(String source, String regex, String
> replacement) method adds Pattern#DOTALL option by default which may be
> undesired. Moreover, this methods is not null safe.
>
> I think it could be added to StringUtils.
> I opened a JIRA ticket (LANG-1139) and an associated Pull Request (#92)
>
>
> There is detail :
>
> /**
>  * Replaces each substring of the text String that matches the given
> regular expression
>  * with the given replacement.
>  *
>  * This method is a {@code null} safe equivalent to:
>  * 
>  *  {@code text.replaceAll(regex, replacement)}
>  *  {@code
> Pattern.compile(regex).matcher(text).replaceAll(replacement)}
>  * 
>  *
>  * A {@code null} reference passed to this method is a no-op.
>  *
>  * Unlike in the {@link #replacePattern(String, String, String)}
> method, the {@link Pattern#DOTALL} option
>  * is NOT automatically added.
>  * To use the DOTALL option prepend "(?s)" to the regex.
>  * DOTALL is also know as single-line mode in Perl.
>  *
>  * 
>  * StringUtils.replaceAll(null, *, *)   = null
>  * StringUtils.replaceAll("any", null, *)   = "any"
>  * StringUtils.replaceAll("any", *, null)   = "any"
>  * StringUtils.replaceAll("", "", "zzz")= "zzz"
>  * StringUtils.replaceAll("", ".*", "zzz")  = "zzz"
>  * StringUtils.replaceAll("", ".+", "zzz")  = ""
>  * StringUtils.replaceAll("<__>\n<__>", "<.*>", "z")  = "z\nz"
>  * StringUtils.replaceAll("<__>\n<__>", "(?s)<.*>", "z")  = "z"
>  * StringUtils.replaceAll("ABCabc123", "[a-z]", "_")   = "ABC___123"
>  * StringUtils.replaceAll("ABCabc123", "[^A-Z0-9]+", "_")  = "ABC_123"
>  * StringUtils.replaceAll("ABCabc123", "[^A-Z0-9]+", "")   = "ABC123"
>  * StringUtils.replaceAll("Lorem ipsum  dolor   sit", "( +)([a-z]+)",
> "_$2") = "Lorem_ipsum_dolor_sit"
>  * 
>  *
>  * @param text  text to search and replace in, may be null
>  * @param regex  the regular expression to which this string is to be
> matched
>  * @param replacement  the string to be substituted for each match
>  * @return  the text with any replacements processed,
>  *  {@code null} if null String input
>  *
>  * @throws  PatternSyntaxException
>  *  if the regular expression's syntax is invalid
>  *
>  * @see String#replaceAll(String, String)
>  * @see java.util.regex.Pattern
>  * @see java.util.regex.Pattern#DOTALL
>  */
> public static String replaceAll(final String text, final String regex,
> final String replacement);
>
> /**
>  * Replaces the first substring of the text string that matches the
> given regular expression
>  * with the given replacement.
>  *
>  * This method is a {@code null} safe equivalent to:
>  * 
>  *  {@code text.replaceFirst(regex, replacement)}
>  *  {@code
>

Re: [LANG] Adding null safe compare methods in StringUtils

2015-10-20 Thread Loic Guibert
I've updated my pull request if you want to look at what I plan to do
concerning methods exclusion in
StringUtilsTest.testStringUtilsCharSequenceContract()

https://github.com/apache/commons-lang/pull/110
https://github.com/apache/commons-lang/commit/131917a0d3303ca2c38fd1d6765b9bed2c23ff89
 

Loic Guibert
PGP : 0x65EB4F33

Le 20/10/2015 17:24, Loic Guibert a écrit :
> Hi Benedikt,
> There are exactly the two options I was considering.
>
> If nobody objects, I'll go on the second way and exclude those methods in
> StringUtilsTest.testStringUtilsCharSequenceContract().
>
> This is closer to Java conception where CharSequence are not comparable and
> comparing two CharSequence of distinct nature
> (like StringBuilder & CharBuffer for exemple)
> may be undefined and can cause some problems
> (like in CharBuffer where length method return remaining char
> and not the total CharSequence length
> or charAt(int index) that return the (current position + index)th char).
>
> Loic Guibert
> PGP : 0x65EB4F33
>
>
> Le 06/10/2015 23:07, Benedikt Ritter a écrit :
>> Hi Loic,
>>
>> first of all, I like this proposal. Thank you for that!
>>
>> Regarding your question I see two options:
>> - implement compare so that is accepts CharSequences as well. That would
>> mean to implement a compare for CharSequences which compares two sequences
>> character by character
>> - exclude the compare methods
>>
>> Benedikt
>>
>> 2015-10-05 15:32 GMT+02:00 Loic Guibert <lfdummy-apa...@yahoo.fr>:
>>
>>> But i've a problem in this unit test :
>>>
>>> org.apache.commons.lang3.StringUtilsTest.testStringUtilsCharSequenceContract()
>>>
>>> It said :
>>>
>>> The method public static int
>>> org.apache.commons.lang3.StringUtils.compare(String,String,boolean) appears
>>> to be immutable in spirit and therefore must not accept a String
>>>
>>> I use String parameters instead of CharSequence because in the Java
>>> conception, only String are Comparable and not CharSequence.
>>> I call String#compareTo(String) in the implementation.
>>>
>>> So what should I do ?
>>>
>>> Loic Guibert
>>> PGP : 0x65EB4F33
>>>
>>>
>>>
>>> Le 05/10/2015 17:19, Loic Guibert a écrit :
>>>> Hello,
>>>> I've implemented null safe methods to compare 2 Strings in StringUtils :
>>>>   - public static int compare(final String str1, final String str2);
>>>>   - public static int compare(final String str1, final String str2,
>>>> final boolean nullIsLess);
>>>>   - public static int compareIgnoreCase(final String str1, final String
>>>> str2);
>>>>   - public static int compareIgnoreCase(final String str1, final String
>>>> str2, final boolean nullIsLess);
>>>>
>>>>
>>>> I opened a JIRA ticket and an associated Pull Request to add those
>>>> methods in StringUtils :
>>>>   - https://issues.apache.org/jira/browse/LANG-1171
>>>>   - https://github.com/apache/commons-lang/pull/110
>>>>
>>>>
>>>> More details :
>>>> /**
>>>>  * Compare two Strings lexicographically, as per {@link
>>>> String#compareTo(String)}, returning :
>>>>  * 
>>>>  *  {@code int = 0}, if {@code str1} is equal to {@code str2} (or
>>>> both {@code null})
>>>>  *  {@code int < 0}, if {@code str1} is less than {@code str2}
>>>>  *  {@code int > 0}, if {@code str1} is greater than {@code
>>> str2}
>>>>  * 
>>>>  *
>>>>  * This is a {@code null} safe version of :
>>>>  * str1.compareTo(str2)
>>>>  *
>>>>  * {@code null} value is considered less than non-{@code null} value.
>>>>  * Two {@code null} references are considered equal.
>>>>  *
>>>>  * 
>>>>  * StringUtils.compare(null, null)   = 0
>>>>  * StringUtils.compare(null , "a")0
>>>>  * StringUtils.compare("a", null) 0
>>>>  * StringUtils.compare("abc", "abc") = 0
>>>>  * StringUtils.compare("a", "b")  0
>>>>  * StringUtils.compare("b", "a")  0
>>>>  * StringUtils.compare("a", "B")  0
>>>>  * StringUtils.compare("ab", "abc")   0
>>>>  * 
>>>>  *
>>>>  * @see #compare(String, String, boolean)
>>>>

Re: [LANG] Adding null safe compare methods in StringUtils

2015-10-20 Thread Loic Guibert
Hi Benedikt,
There are exactly the two options I was considering.

If nobody objects, I'll go on the second way and exclude those methods in
StringUtilsTest.testStringUtilsCharSequenceContract().

This is closer to Java conception where CharSequence are not comparable and
comparing two CharSequence of distinct nature
(like StringBuilder & CharBuffer for exemple)
may be undefined and can cause some problems
(like in CharBuffer where length method return remaining char
and not the total CharSequence length
or charAt(int index) that return the (current position + index)th char).

Loic Guibert
PGP : 0x65EB4F33


Le 06/10/2015 23:07, Benedikt Ritter a écrit :
> Hi Loic,
>
> first of all, I like this proposal. Thank you for that!
>
> Regarding your question I see two options:
> - implement compare so that is accepts CharSequences as well. That would
> mean to implement a compare for CharSequences which compares two sequences
> character by character
> - exclude the compare methods
>
> Benedikt
>
> 2015-10-05 15:32 GMT+02:00 Loic Guibert <lfdummy-apa...@yahoo.fr>:
>
>> But i've a problem in this unit test :
>>
>> org.apache.commons.lang3.StringUtilsTest.testStringUtilsCharSequenceContract()
>>
>> It said :
>>
>> The method public static int
>> org.apache.commons.lang3.StringUtils.compare(String,String,boolean) appears
>> to be immutable in spirit and therefore must not accept a String
>>
>> I use String parameters instead of CharSequence because in the Java
>> conception, only String are Comparable and not CharSequence.
>> I call String#compareTo(String) in the implementation.
>>
>> So what should I do ?
>>
>> Loic Guibert
>> PGP : 0x65EB4F33
>>
>>
>>
>> Le 05/10/2015 17:19, Loic Guibert a écrit :
>>> Hello,
>>> I've implemented null safe methods to compare 2 Strings in StringUtils :
>>>   - public static int compare(final String str1, final String str2);
>>>   - public static int compare(final String str1, final String str2,
>>> final boolean nullIsLess);
>>>   - public static int compareIgnoreCase(final String str1, final String
>>> str2);
>>>   - public static int compareIgnoreCase(final String str1, final String
>>> str2, final boolean nullIsLess);
>>>
>>>
>>> I opened a JIRA ticket and an associated Pull Request to add those
>>> methods in StringUtils :
>>>   - https://issues.apache.org/jira/browse/LANG-1171
>>>   - https://github.com/apache/commons-lang/pull/110
>>>
>>>
>>> More details :
>>> /**
>>>  * Compare two Strings lexicographically, as per {@link
>>> String#compareTo(String)}, returning :
>>>  * 
>>>  *  {@code int = 0}, if {@code str1} is equal to {@code str2} (or
>>> both {@code null})
>>>  *  {@code int < 0}, if {@code str1} is less than {@code str2}
>>>  *  {@code int > 0}, if {@code str1} is greater than {@code
>> str2}
>>>  * 
>>>  *
>>>  * This is a {@code null} safe version of :
>>>  * str1.compareTo(str2)
>>>  *
>>>  * {@code null} value is considered less than non-{@code null} value.
>>>  * Two {@code null} references are considered equal.
>>>  *
>>>  * 
>>>  * StringUtils.compare(null, null)   = 0
>>>  * StringUtils.compare(null , "a")0
>>>  * StringUtils.compare("a", null) 0
>>>  * StringUtils.compare("abc", "abc") = 0
>>>  * StringUtils.compare("a", "b")  0
>>>  * StringUtils.compare("b", "a")  0
>>>  * StringUtils.compare("a", "B")  0
>>>  * StringUtils.compare("ab", "abc")   0
>>>  * 
>>>  *
>>>  * @see #compare(String, String, boolean)
>>>  * @see String#compareTo(String)
>>>  * @param str1  the String to compare from
>>>  * @param str2  the String to compare to
>>>  * @return  0, 0,  0, if {@code str1} is respectively less,
>>> equal ou greater than {@code str2}
>>>  */
>>> public static int compare(final String str1, final String str2);
>>>
>>> /**
>>>  * Compare two Strings lexicographically, as per {@link
>>> String#compareTo(String)}, returning :
>>>  * 
>>>  *  {@code int = 0}, if {@code str1} is equal to {@code str2} (or
>>> both {@code null})
>>>  *  {@code int < 0}, if {@code str1} is less than {@code str2}
>>>  *  {@code int > 0}, if {@code str1} is greater than {@code
>> s

[LANG] Adding null safe compare methods in StringUtils

2015-10-05 Thread Loic Guibert
 respectively less,
equal ou greater than {@code str2},
 *  ignoring case differences.
 */
public static int compareIgnoreCase(final String str1, final String str2);

/**
 * Compare two Strings lexicographically, ignoring case differences,
 * as per {@link String#compareToIgnoreCase(String)}, returning :
 * 
 *  {@code int = 0}, if {@code str1} is equal to {@code str2} (or
both {@code null})
 *  {@code int < 0}, if {@code str1} is less than {@code str2}
 *  {@code int > 0}, if {@code str1} is greater than {@code str2}
 * 
 *
 * This is a {@code null} safe version of :
 * str1.compareToIgnoreCase(str2)
 *
 * {@code null} inputs are handled according to the {@code
nullIsLess} parameter.
 * Two {@code null} references are considered equal.
 * Comparison is case insensitive.
 *
 * 
 * StringUtils.compareIgnoreCase(null, null, *) = 0
 * StringUtils.compareIgnoreCase(null , "a", true)   0
 * StringUtils.compareIgnoreCase(null , "a", false)  0
 * StringUtils.compareIgnoreCase("a", null, true)0
 * StringUtils.compareIgnoreCase("a", null, false)   0
 * StringUtils.compareIgnoreCase("abc", "abc", *)   = 0
 * StringUtils.compareIgnoreCase("abc", "ABC", *)   = 0
 * StringUtils.compareIgnoreCase("a", "b", *)0
 * StringUtils.compareIgnoreCase("b", "a", *)0
 * StringUtils.compareIgnoreCase("a", "B", *)    0
 * StringUtils.compareIgnoreCase("A", "b", *)0
 * StringUtils.compareIgnoreCase("ab", "abc", *) 0
 * 
 *
 * @see String#compareToIgnoreCase(String)
 * @param str1  the String to compare from
 * @param str2  the String to compare to
 * @param nullIsLess  whether consider {@code null} value less than
non-{@code null} value
 * @return  0, 0,  0, if {@code str1} is respectively less,
equal ou greater than {@code str2},
 *  ignoring case differences.
 */
public static int compareIgnoreCase(final String str1, final String
str2, final boolean nullIsLess);


-- 
Loic Guibert
PGP : 0x65EB4F33

-
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org



Re: [LANG] Adding null safe compare methods in StringUtils

2015-10-05 Thread Loic Guibert
But i've a problem in this unit test :
org.apache.commons.lang3.StringUtilsTest.testStringUtilsCharSequenceContract()

It said :

The method public static int 
org.apache.commons.lang3.StringUtils.compare(String,String,boolean) appears to 
be immutable in spirit and therefore must not accept a String

I use String parameters instead of CharSequence because in the Java
conception, only String are Comparable and not CharSequence.
I call String#compareTo(String) in the implementation.

So what should I do ?

Loic Guibert
PGP : 0x65EB4F33



Le 05/10/2015 17:19, Loic Guibert a écrit :
> Hello,
> I've implemented null safe methods to compare 2 Strings in StringUtils :
>   - public static int compare(final String str1, final String str2);
>   - public static int compare(final String str1, final String str2,
> final boolean nullIsLess);
>   - public static int compareIgnoreCase(final String str1, final String
> str2);
>   - public static int compareIgnoreCase(final String str1, final String
> str2, final boolean nullIsLess);
>
>
> I opened a JIRA ticket and an associated Pull Request to add those
> methods in StringUtils :
>   - https://issues.apache.org/jira/browse/LANG-1171
>   - https://github.com/apache/commons-lang/pull/110
>
>
> More details :
> /**
>  * Compare two Strings lexicographically, as per {@link
> String#compareTo(String)}, returning :
>  * 
>  *  {@code int = 0}, if {@code str1} is equal to {@code str2} (or
> both {@code null})
>  *  {@code int < 0}, if {@code str1} is less than {@code str2}
>  *  {@code int > 0}, if {@code str1} is greater than {@code str2}
>  * 
>  *
>  * This is a {@code null} safe version of :
>  * str1.compareTo(str2)
>  *
>  * {@code null} value is considered less than non-{@code null} value.
>  * Two {@code null} references are considered equal.
>  *
>  * 
>  * StringUtils.compare(null, null)   = 0
>  * StringUtils.compare(null , "a")0
>  * StringUtils.compare("a", null) 0
>  * StringUtils.compare("abc", "abc") = 0
>  * StringUtils.compare("a", "b")  0
>  * StringUtils.compare("b", "a")  0
>  * StringUtils.compare("a", "B")  0
>  * StringUtils.compare("ab", "abc")   0
>  * 
>  *
>  * @see #compare(String, String, boolean)
>  * @see String#compareTo(String)
>  * @param str1  the String to compare from
>  * @param str2  the String to compare to
>  * @return  0, 0,  0, if {@code str1} is respectively less,
> equal ou greater than {@code str2}
>  */
> public static int compare(final String str1, final String str2);
>
> /**
>  * Compare two Strings lexicographically, as per {@link
> String#compareTo(String)}, returning :
>  * 
>  *  {@code int = 0}, if {@code str1} is equal to {@code str2} (or
> both {@code null})
>  *  {@code int < 0}, if {@code str1} is less than {@code str2}
>  *  {@code int > 0}, if {@code str1} is greater than {@code str2}
>  * 
>  *
>  * This is a {@code null} safe version of :
>  * str1.compareTo(str2)
>  *
>  * {@code null} inputs are handled according to the {@code
> nullIsLess} parameter.
>  * Two {@code null} references are considered equal.
>  *
>  * 
>  * StringUtils.compare(null, null, *) = 0
>  * StringUtils.compare(null , "a", true)   0
>  * StringUtils.compare(null , "a", false)  0
>  * StringUtils.compare("a", null, true)0
>  * StringUtils.compare("a", null, false)   0
>  * StringUtils.compare("abc", "abc", *)   = 0
>  * StringUtils.compare("a", "b", *)0
>  * StringUtils.compare("b", "a", *)0
>  * StringUtils.compare("a", "B", *)0
>  * StringUtils.compare("ab", "abc", *) 0
>  * 
>  *
>  * @see String#compareTo(String)
>  * @param str1  the String to compare from
>  * @param str2  the String to compare to
>  * @param nullIsLess  whether consider {@code null} value less than
> non-{@code null} value
>  * @return  0, 0,  0, if {@code str1} is respectively less,
> equal ou greater than {@code str2}
>  */
> public static int compare(final String str1, final String str2, final
> boolean nullIsLess);
>
> /**
>  * Compare two Strings lexicographically, ignoring case differences,
>  * as per {@link String#compareToIgnoreCase(String)}, returning :
>  * 
>  *  {@code int = 0}, if {@code str1} is equal to {@code str2} (or
> both {@code null})
>  *  {@code int < 0}, if {@code str1} is less than {@code str2}
>  *  {@code int > 0}, if {@code str1} is greater than {@code str2}
>  * 
>  *
>  * This is a {@c

Re: [LANG] Adding StringUtils replace by regular expression methods

2015-07-28 Thread Loic Guibert
Hello Benedikt,
LANG version 3.5 being about to be released, have you had time to look
at these 2 methods ?

https://issues.apache.org/jira/browse/LANG-1139
https://github.com/apache/commons-lang/pull/92

Loic Guibert
PGP : 0x65EB4F33


Le 02/06/2015 10:24, Benedikt Ritter a écrit :
 Hello Loic,

 I really appreciate your effort to get this code into lang. Thank you very
 much!
 Sorry that I'm unable to give you timely feedback on the proposed changes.
 I'm pretty busy at work at the moment and I've almost zero time for OSS
 right now :-(
 I'll review the changes as soon as I have some more time.

 Sorry again for the inconvenience!

 Benedikt

 2015-05-28 14:42 GMT+02:00 Loic Guibert lfdummy-apa...@yahoo.fr:

 Hello,
 I implemented 2 null safe methods to replace into a String with regular
 expression :
   - String replaceAll(String text, String regex, String replacement);
   - String replaceFirst(String text, String regex, String replacement);


 The StringUtils.replacePattern(String source, String regex, String
 replacement) method adds Pattern#DOTALL option by default which may be
 undesired. Moreover, this methods is not null safe.

 I think it could be added to StringUtils.
 I opened a JIRA ticket (LANG-1139) and an associated Pull Request (#92)


 There is detail :

 /**
  * pReplaces each substring of the text String that matches the given
 regular expression
  * with the given replacement./p
  *
  * This method is a {@code null} safe equivalent to:
  * ul
  *  li{@code text.replaceAll(regex, replacement)}/li
  *  li{@code
 Pattern.compile(regex).matcher(text).replaceAll(replacement)}/li
  * /ul
  *
  * pA {@code null} reference passed to this method is a no-op./p
  *
  * pUnlike in the {@link #replacePattern(String, String, String)}
 method, the {@link Pattern#DOTALL} option
  * is NOT automatically added.
  * To use the DOTALL option prepend code(?s)/code to the regex.
  * DOTALL is also know as single-line mode in Perl./p
  *
  * pre
  * StringUtils.replaceAll(null, *, *)   = null
  * StringUtils.replaceAll(any, null, *)   = any
  * StringUtils.replaceAll(any, *, null)   = any
  * StringUtils.replaceAll(, , zzz)= zzz
  * StringUtils.replaceAll(, .*, zzz)  = zzz
  * StringUtils.replaceAll(, .+, zzz)  = 
  * StringUtils.replaceAll(__\n__, .*, z)  = z\nz
  * StringUtils.replaceAll(__\n__, (?s).*, z)  = z
  * StringUtils.replaceAll(ABCabc123, [a-z], _)   = ABC___123
  * StringUtils.replaceAll(ABCabc123, [^A-Z0-9]+, _)  = ABC_123
  * StringUtils.replaceAll(ABCabc123, [^A-Z0-9]+, )   = ABC123
  * StringUtils.replaceAll(Lorem ipsum  dolor   sit, ( +)([a-z]+),
 _$2) = Lorem_ipsum_dolor_sit
  * /pre
  *
  * @param text  text to search and replace in, may be null
  * @param regex  the regular expression to which this string is to be
 matched
  * @param replacement  the string to be substituted for each match
  * @return  the text with any replacements processed,
  *  {@code null} if null String input
  *
  * @throws  PatternSyntaxException
  *  if the regular expression's syntax is invalid
  *
  * @see String#replaceAll(String, String)
  * @see java.util.regex.Pattern
  * @see java.util.regex.Pattern#DOTALL
  */
 public static String replaceAll(final String text, final String regex,
 final String replacement);

 /**
  * pReplaces the first substring of the text string that matches the
 given regular expression
  * with the given replacement./p
  *
  * This method is a {@code null} safe equivalent to:
  * ul
  *  li{@code text.replaceFirst(regex, replacement)}/li
  *  li{@code
 Pattern.compile(regex).matcher(text).replaceFirst(replacement)}/li
  * /ul
  *
  * pA {@code null} reference passed to this method is a no-op./p
  *
  * pThe {@link Pattern#DOTALL} option is NOT automatically added.
  * To use the DOTALL option prepend code(?s)/code to the regex.
  * DOTALL is also know as single-line mode in Perl./p
  *
  * pre
  * StringUtils.replaceFirst(null, *, *)   = null
  * StringUtils.replaceFirst(any, null, *)   = any
  * StringUtils.replaceFirst(any, *, null)   = any
  * StringUtils.replaceFirst(, , zzz)= zzz
  * StringUtils.replaceFirst(, .*, zzz)  = zzz
  * StringUtils.replaceFirst(, .+, zzz)  = 
  * StringUtils.replaceFirst(__\n__, .*, z)  = z\n__
  * StringUtils.replaceFirst(__\n__, (?s).*, z)  = z
  * StringUtils.replaceFirst(ABCabc123, [a-z], _)  =
 ABC_bc123
  * StringUtils.replaceFirst(ABCabc123abc, [^A-Z0-9]+, _)  =
 ABC_123abc
  * StringUtils.replaceFirst(ABCabc123abc, [^A-Z0-9]+, )   =
 ABC123abc
  * StringUtils.replaceFirst(Lorem ipsum  dolor   sit, ( +)([a-z]+),
 _$2)  = Lorem_ipsum  dolor   sit
  * /pre
  *
  * @param text  text to search and replace in, may be null
  * @param regex  the regular expression to which this string is to be
 matched
  * @param replacement  the string to be substituted for the first match
  * @return  the text with the first replacement processed,
  *  {@code null} if null String input

Re: [LANG] Adding StringUtils split by length methods

2015-07-28 Thread Loic Guibert
Hello Benedikt,
Have you had time to look at these elements and my feedback comments on
github ?

https://github.com/apache/commons-lang/pull/75

Loic Guibert
PGP : 0x65EB4F33


Le 01/05/2015 13:47, Benedikt Ritter a écrit :
 Hey Loic,

 thank you for this proposal. I'll have a look at it this Sunday!

 Benedikt

 2015-04-30 10:08 GMT+02:00 Loic Guibert lfdummy-apa...@yahoo.fr:

 Hello,
 I've implemented 2 methods to split a String by fixed lengths :
   - public static String[] splitByLength(String str, int ... lengths)
   - public static String[] splitByLengthRepeatedly(String str, int ...
 lengths)

 I'll open a JIRA ticket and an associated Pull Request to add those
 methods in StringUtils.


 There is detail :

 /**
  * pSplit a String into an array, using an array of fixed string
 lengths./p
  *
  * pIf not null String input, the returned array size is same as
 the input lengths array./p
  *
  * pA null input String returns {@code null}.
  * A {@code null} or empty input lengths array returns an empty array.
  * A {@code 0} in the input lengths array results in en empty
 string./p
  *
  * pExtra characters are ignored (ie String length greater than
 sum of split lengths).
  * All empty substrings other than zero length requested, are
 returned {@code null}./p
  *
  * pre
  * StringUtils.splitByLength(null, *)  = null
  * StringUtils.splitByLength(abc)= []
  * StringUtils.splitByLength(abc, null)  = []
  * StringUtils.splitByLength(abc, [])= []
  * StringUtils.splitByLength(, 2, 4, 1)  = [null, null, null]
  *
  * StringUtils.splitByLength(abcdefg, 2, 4, 1) = [ab,
 cdef, g]
  * StringUtils.splitByLength(abcdefghij, 2, 4, 1)  = [ab,
 cdef, g]
  * StringUtils.splitByLength(abcdefg, 2, 4, 5) = [ab,
 cdef, g]
  * StringUtils.splitByLength(abcdef, 2, 4, 1)  = [ab,
 cdef, null]
  *
  * StringUtils.splitByLength( abcdef, 2, 4, 1) = [ a,
 bcde, f]
  * StringUtils.splitByLength(abcdef , 2, 4, 1) = [ab,
 cdef,  ]
  * StringUtils.splitByLength(abcdefg, 2, 4, 0, 1)  = [ab,
 cdef, , g]
  * StringUtils.splitByLength(abcdefg, -1)  = {@link
 IllegalArgumentException}
  * /pre
  *
  * @param str  the String to parse, may be null
  * @param lengths  the string lengths where to cut, may be null,
 must not be negative
  * @return an array of splitted Strings, {@code null} if null String
 input
  * @throws IllegalArgumentException
  * if one of the lengths is negative
  */
 public static String[] splitByLength(String str, int ... lengths);

 /**
  * pSplit a String into an array, using an array of fixed string
 lengths repeated as
  * many times as necessary to reach the String end./p
  *
  * pIf not null String input, the returned array size is a
 multiple of the input lengths array./p
  *
  * pA null input String returns {@code null}.
  * A {@code null} or empty input lengths array returns an empty array.
  * A {@code 0} in the input lengths array results in en empty
 string./p
  *
  * pAll empty substrings other than zero length requested and
 following substrings,
  * are returned {@code null}./p
  *
  * pre
  * StringUtils.splitByLengthRepeated(null, *)  = null
  * StringUtils.splitByLengthRepeated(abc)= []
  * StringUtils.splitByLengthRepeated(abc, null)  = []
  * StringUtils.splitByLengthRepeated(abc, [])= []
  * StringUtils.splitByLengthRepeated(, 2, 4, 1)  = [null, null, null]
  *
  * StringUtils.splitByLengthRepeated(abcdefghij, 2, 3) =
 [ab, cde, fg, hij]
  * StringUtils.splitByLengthRepeated(abcdefgh, 2, 3)   =
 [ab, cde, fg, h]
  * StringUtils.splitByLengthRepeated(abcdefg, 2, 3)=
 [ab, cde, fg, null]
  *
  * StringUtils.splitByLengthRepeated( abcdef, 2, 3)= [
 a, bcd, ef, null]
  * StringUtils.splitByLengthRepeated(abcdef , 2, 3)=
 [ab, cde, f , null]
  * StringUtils.splitByLengthRepeated(abcdef, 2, 3, 0, 1)   =
 [ab, cde, , f]
  * StringUtils.splitByLengthRepeated(abcdefg, 2, 3, 0, 1)  =
 [ab, cde, , f,
  *  g,
 null, null, null]
  * StringUtils.splitByLengthRepeated(abcdefgh, 2, 0, 1, 0) =
 [ab, , c, ,
  *
 de, , f, ,
  *
 gh, , null, null]
  * StringUtils.splitByLengthRepeated(abcdefg, 2, 0, 1, 0) = [ab,
 , c, ,
  *
 de, , f, ,
  *  g,
 null, null, null]
  * StringUtils.splitByLengthRepeated(abcdefg, -1)  =
 {@link IllegalArgumentException}
  * StringUtils.splitByLengthRepeated(abcdefg, 0, 0)=
 {@link IllegalArgumentException}
  * /pre
  *
  * @param str  the String to parse, may be null
  * @param lengths  the string lengths where to cut, may be null,
 must

[LANG] EnumUtils *BitVector methods issue with more than 32 values Enums

2015-06-12 Thread Loic Guibert
Hello,
I found an issue into `EnumUtils` *BitVector methods when working with
more than 32 values Enums.

This is due to a implicit `int` - `long` conversion in generating the
Enum value `long` mask.


More in detail :
/* Bad code : here `1` is an `int` value so the `` operation is
done into
 * an `int` context and then, the result is converted to a `long`
value*/
long mask = 1  32;// - mask = 1 and not 4294967296 (0x1)

/* Good code : here `1L` is a `long` value so the `` operation is done
 * into an `long` context*/
long mask = 1L  32;// - mask = 4294967296 (0x1)


I opened a JIRA ticket (LANG-1147) and an associated Pull Request (#97)

https://issues.apache.org/jira/browse/LANG-1147
https://github.com/apache/commons-lang/pull/97


Regards,

-- 
Loic Guibert
PGP : 0x65EB4F33


-
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org



[LANG] Adding StringUtils replace by regular expression methods

2015-05-28 Thread Loic Guibert
Hello,
I implemented 2 null safe methods to replace into a String with regular
expression :
  - String replaceAll(String text, String regex, String replacement);
  - String replaceFirst(String text, String regex, String replacement);


The StringUtils.replacePattern(String source, String regex, String
replacement) method adds Pattern#DOTALL option by default which may be
undesired. Moreover, this methods is not null safe.

I think it could be added to StringUtils.
I opened a JIRA ticket (LANG-1139) and an associated Pull Request (#92)


There is detail :

/**
 * pReplaces each substring of the text String that matches the given
regular expression
 * with the given replacement./p
 *
 * This method is a {@code null} safe equivalent to:
 * ul
 *  li{@code text.replaceAll(regex, replacement)}/li
 *  li{@code
Pattern.compile(regex).matcher(text).replaceAll(replacement)}/li
 * /ul
 *
 * pA {@code null} reference passed to this method is a no-op./p
 *
 * pUnlike in the {@link #replacePattern(String, String, String)}
method, the {@link Pattern#DOTALL} option
 * is NOT automatically added.
 * To use the DOTALL option prepend code(?s)/code to the regex.
 * DOTALL is also know as single-line mode in Perl./p
 *
 * pre
 * StringUtils.replaceAll(null, *, *)   = null
 * StringUtils.replaceAll(any, null, *)   = any
 * StringUtils.replaceAll(any, *, null)   = any
 * StringUtils.replaceAll(, , zzz)= zzz
 * StringUtils.replaceAll(, .*, zzz)  = zzz
 * StringUtils.replaceAll(, .+, zzz)  = 
 * StringUtils.replaceAll(__\n__, .*, z)  = z\nz
 * StringUtils.replaceAll(__\n__, (?s).*, z)  = z
 * StringUtils.replaceAll(ABCabc123, [a-z], _)   = ABC___123
 * StringUtils.replaceAll(ABCabc123, [^A-Z0-9]+, _)  = ABC_123
 * StringUtils.replaceAll(ABCabc123, [^A-Z0-9]+, )   = ABC123
 * StringUtils.replaceAll(Lorem ipsum  dolor   sit, ( +)([a-z]+),
_$2) = Lorem_ipsum_dolor_sit
 * /pre
 *
 * @param text  text to search and replace in, may be null
 * @param regex  the regular expression to which this string is to be
matched
 * @param replacement  the string to be substituted for each match
 * @return  the text with any replacements processed,
 *  {@code null} if null String input
 *
 * @throws  PatternSyntaxException
 *  if the regular expression's syntax is invalid
 *
 * @see String#replaceAll(String, String)
 * @see java.util.regex.Pattern
 * @see java.util.regex.Pattern#DOTALL
 */
public static String replaceAll(final String text, final String regex,
final String replacement);

/**
 * pReplaces the first substring of the text string that matches the
given regular expression
 * with the given replacement./p
 *
 * This method is a {@code null} safe equivalent to:
 * ul
 *  li{@code text.replaceFirst(regex, replacement)}/li
 *  li{@code
Pattern.compile(regex).matcher(text).replaceFirst(replacement)}/li
 * /ul
 *
 * pA {@code null} reference passed to this method is a no-op./p
 *
 * pThe {@link Pattern#DOTALL} option is NOT automatically added.
 * To use the DOTALL option prepend code(?s)/code to the regex.
 * DOTALL is also know as single-line mode in Perl./p
 *
 * pre
 * StringUtils.replaceFirst(null, *, *)   = null
 * StringUtils.replaceFirst(any, null, *)   = any
 * StringUtils.replaceFirst(any, *, null)   = any
 * StringUtils.replaceFirst(, , zzz)= zzz
 * StringUtils.replaceFirst(, .*, zzz)  = zzz
 * StringUtils.replaceFirst(, .+, zzz)  = 
 * StringUtils.replaceFirst(__\n__, .*, z)  = z\n__
 * StringUtils.replaceFirst(__\n__, (?s).*, z)  = z
 * StringUtils.replaceFirst(ABCabc123, [a-z], _)  =
ABC_bc123
 * StringUtils.replaceFirst(ABCabc123abc, [^A-Z0-9]+, _)  =
ABC_123abc
 * StringUtils.replaceFirst(ABCabc123abc, [^A-Z0-9]+, )   =
ABC123abc
 * StringUtils.replaceFirst(Lorem ipsum  dolor   sit, ( +)([a-z]+),
_$2)  = Lorem_ipsum  dolor   sit
 * /pre
 *
 * @param text  text to search and replace in, may be null
 * @param regex  the regular expression to which this string is to be
matched
 * @param replacement  the string to be substituted for the first match
 * @return  the text with the first replacement processed,
 *  {@code null} if null String input
 *
 * @throws  PatternSyntaxException
 *  if the regular expression's syntax is invalid
 *
 * @see String#replaceFirst(String, String)
 * @see java.util.regex.Pattern
 * @see java.util.regex.Pattern#DOTALL
 */
public static String replaceFirst(final String text, final String regex,
final String replacement);


Regards,

-- 
Loic Guibert
PGP : 0x65EB4F33


-
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org



[LANG] Adding StringUtils split by length methods

2015-04-30 Thread Loic Guibert
Hello,
I've implemented 2 methods to split a String by fixed lengths :
  - public static String[] splitByLength(String str, int ... lengths)
  - public static String[] splitByLengthRepeatedly(String str, int ...
lengths)

I'll open a JIRA ticket and an associated Pull Request to add those
methods in StringUtils.


There is detail :

/**
 * pSplit a String into an array, using an array of fixed string
lengths./p
 *
 * pIf not null String input, the returned array size is same as
the input lengths array./p
 *
 * pA null input String returns {@code null}.
 * A {@code null} or empty input lengths array returns an empty array.
 * A {@code 0} in the input lengths array results in en empty
string./p
 *
 * pExtra characters are ignored (ie String length greater than
sum of split lengths).
 * All empty substrings other than zero length requested, are
returned {@code null}./p
 *
 * pre
 * StringUtils.splitByLength(null, *)  = null
 * StringUtils.splitByLength(abc)= []
 * StringUtils.splitByLength(abc, null)  = []
 * StringUtils.splitByLength(abc, [])= []
 * StringUtils.splitByLength(, 2, 4, 1)  = [null, null, null]
 *
 * StringUtils.splitByLength(abcdefg, 2, 4, 1) = [ab,
cdef, g]
 * StringUtils.splitByLength(abcdefghij, 2, 4, 1)  = [ab,
cdef, g]
 * StringUtils.splitByLength(abcdefg, 2, 4, 5) = [ab,
cdef, g]
 * StringUtils.splitByLength(abcdef, 2, 4, 1)  = [ab,
cdef, null]
 *
 * StringUtils.splitByLength( abcdef, 2, 4, 1) = [ a,
bcde, f]
 * StringUtils.splitByLength(abcdef , 2, 4, 1) = [ab,
cdef,  ]
 * StringUtils.splitByLength(abcdefg, 2, 4, 0, 1)  = [ab,
cdef, , g]
 * StringUtils.splitByLength(abcdefg, -1)  = {@link
IllegalArgumentException}
 * /pre
 *
 * @param str  the String to parse, may be null
 * @param lengths  the string lengths where to cut, may be null,
must not be negative
 * @return an array of splitted Strings, {@code null} if null String
input
 * @throws IllegalArgumentException
 * if one of the lengths is negative
 */
public static String[] splitByLength(String str, int ... lengths);

/**
 * pSplit a String into an array, using an array of fixed string
lengths repeated as
 * many times as necessary to reach the String end./p
 *
 * pIf not null String input, the returned array size is a
multiple of the input lengths array./p
 *
 * pA null input String returns {@code null}.
 * A {@code null} or empty input lengths array returns an empty array.
 * A {@code 0} in the input lengths array results in en empty
string./p
 *
 * pAll empty substrings other than zero length requested and
following substrings,
 * are returned {@code null}./p
 *
 * pre
 * StringUtils.splitByLengthRepeated(null, *)  = null
 * StringUtils.splitByLengthRepeated(abc)= []
 * StringUtils.splitByLengthRepeated(abc, null)  = []
 * StringUtils.splitByLengthRepeated(abc, [])= []
 * StringUtils.splitByLengthRepeated(, 2, 4, 1)  = [null, null, null]
 *
 * StringUtils.splitByLengthRepeated(abcdefghij, 2, 3) =
[ab, cde, fg, hij]
 * StringUtils.splitByLengthRepeated(abcdefgh, 2, 3)   =
[ab, cde, fg, h]
 * StringUtils.splitByLengthRepeated(abcdefg, 2, 3)=
[ab, cde, fg, null]
 *
 * StringUtils.splitByLengthRepeated( abcdef, 2, 3)= [
a, bcd, ef, null]
 * StringUtils.splitByLengthRepeated(abcdef , 2, 3)=
[ab, cde, f , null]
 * StringUtils.splitByLengthRepeated(abcdef, 2, 3, 0, 1)   =
[ab, cde, , f]
 * StringUtils.splitByLengthRepeated(abcdefg, 2, 3, 0, 1)  =
[ab, cde, , f,
 *  g,
null, null, null]
 * StringUtils.splitByLengthRepeated(abcdefgh, 2, 0, 1, 0) =
[ab, , c, ,
 * 
de, , f, ,
 * 
gh, , null, null]
 * StringUtils.splitByLengthRepeated(abcdefg, 2, 0, 1, 0) = [ab,
, c, ,
 * 
de, , f, ,
 *  g,
null, null, null]
 * StringUtils.splitByLengthRepeated(abcdefg, -1)  =
{@link IllegalArgumentException}
 * StringUtils.splitByLengthRepeated(abcdefg, 0, 0)=
{@link IllegalArgumentException}
 * /pre
 *
 * @param str  the String to parse, may be null
 * @param lengths  the string lengths where to cut, may be null,
must not be negative
 * @return an array of splitted Strings, {@code null} if null String
input
 * @throws IllegalArgumentException
 * if one of the lengths is negative or if lengths sum
is less than 1
 */
public static String[] splitByLengthRepeatedly(String str, int ...
lengths);

-- 
Loic

[LANG] Contribution adding some features in StringUtils

2015-04-22 Thread Loic Guibert
) = Lorem_ipsum_dolor_sit
 *
 * @see String#replaceAll(String, String)
 * @see java.util.regex.Pattern
 */
public static String replaceAll(String pString, String pRegex, String
pReplacement);

/**
 * StringHelper.replaceFirst(null, *, *) = null
 * StringHelper.replaceFirst(*, null, *)  = {@link
NullPointerException}
 * StringHelper.replaceFirst(*, *, null)  = {@link
NullPointerException}
 * StringHelper.replaceFirst(, , abc)  = abc
 * StringHelper.replaceFirst(, .*, abc)  = abc
 * StringHelper.replaceFirst(, .+, abc)  = 
 * StringHelper.replaceFirst(ABCabc123, [a-z], _) = ABC_bc123
 * StringHelper.replaceFirst(ABCabc123abc, [^A-Z0-9]+, _) =
ABC_123abc
 * StringHelper.replaceFirst(ABCabc123abc, [^A-Z0-9]+, ) =
ABC123abc
 * StringHelper.replaceFirst(Lorem ipsum  dolor   sit, (
+)([a-z]+), _$2) = Lorem_ipsum  dolor   sit
 *
 * @see String#replaceFirst(String, String)
 * @see java.util.regex.Pattern
 */
public static String replaceFirst(String pString, String pRegex, String
pReplacement);


public static int compare(String pString1, String pString2);
public static int compareIgnoreCase(String pString1, String pString2);


/**
 * @param pAlgorithm : MD5, SHA-1,... see {@link MessageDigest}
 * @throws NoSuchAlgorithmException -
 */
public static String hash(String pString, String pAlgorithm) throws
NoSuchAlgorithmException;
public static byte[] hashBytes(String pString, String pAlgorithm) throws
NoSuchAlgorithmException;


/**
 * Convert a bytes array to an hexadecimal String represetation (big
endian)
 */
public static String toHexString(byte[] pBytes);


/**
 * @return Integer or {@code null} if pString is empty
 */
public static Integer toIntegerEmpty(String pString);


/**
 * StringHelper.splitByLength(null, *) = null
 * StringHelper.splitByLength(abc) = []
 * StringHelper.splitByLength(, 2, 4, 1) = [null, null, null]
 * StringHelper.splitByLength(abcdefg, 2, 4, 1)  = [ab, cdef, g]
 * StringHelper.splitByLength(abcdefghij, 2, 4, 1)  = [ab,
cdef, g]
 * StringHelper.splitByLength(abcdef, 2, 4, 1)  = [ab, cdef, null]
 * StringHelper.splitByLength(abcdef , 2, 4, 1)  = [ab, cdef,  ]
 * StringHelper.splitByLength( abcdefg, 2, 4, 1)  = [ a, bcde,
f]
 * StringHelper.splitByLength(abcdefg, 2, 4, 0, 1)  = [ab,
cdef, null, g]
 *
 * @return String[] or {@code null} if codepString == null/code
 */
public static String[] splitByLength(String pString, int ... pColLengths);


/**
 * Return {@link Matcher} from codepRegex.matcher(pString)/code
 * @return {@link Matcher} ou codenull/code
 */
public static Matcher matcher(CharSequence pString, Pattern pRegex);

/**
 * Return {@link Matcher} from
codePattern.compile(pRegex).matcher(pString)/code
 * @return {@link Matcher} ou codenull/code
 */
public static Matcher matcher(CharSequence pString, String pRegex);

public static boolean matches(CharSequence pString, Pattern pRegex);
public static boolean matches(CharSequence pString, String pRegex);


I will rename parameters and add final qualifier to respect your coding
practices.
I will translate the JavaDoc and comments in English.

If you are interested, I can add those to StringUtils (and associated
test cases) in my github repository.
It's my first contribution, so how would you like it to be done ?
1- make a JIRA ticket by logical group of methods and related git
pull request
2- make a single detailed JIRA ticket with all methods and a single
git pull request with one commit by logical group of methods



Best regards,

-- 
Loic Guibert



-
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org