You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by arunvinudss <gi...@git.apache.org> on 2017/06/11 11:37:23 UTC

[GitHub] commons-text pull request #46: TEXT-85:Added CaseUtils class with camel case...

GitHub user arunvinudss opened a pull request:

    https://github.com/apache/commons-text/pull/46

    TEXT-85:Added CaseUtils class with camel case conversion support

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/arunvinudss/commons-text TEXT-85

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/commons-text/pull/46.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #46
    
----
commit 5b8c5ea3b7e39a49a9ee66588a2d8fbc5d8cc6e7
Author: Arun Vinud <ar...@capitalone.com>
Date:   2017-06-11T11:36:21Z

    TEXT-85:Added CaseUtils class with camel case conversion

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] commons-text issue #46: TEXT-85:Added CaseUtils class with camel case conver...

Posted by chtompki <gi...@git.apache.org>.
Github user chtompki commented on the issue:

    https://github.com/apache/commons-text/pull/46
  
    Will try to get to this today.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] commons-text issue #46: TEXT-85:Added CaseUtils class with camel case conver...

Posted by sebbASF <gi...@git.apache.org>.
Github user sebbASF commented on the issue:

    https://github.com/apache/commons-text/pull/46
  
    I've just realised: this issue is about adding CaseUtils.toCamelCase.
    Problems with WordUtils belong in a separate issue or JIRA


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] commons-text pull request #46: TEXT-85:Added CaseUtils class with camel case...

Posted by chtompki <gi...@git.apache.org>.
Github user chtompki commented on a diff in the pull request:

    https://github.com/apache/commons-text/pull/46#discussion_r121374329
  
    --- Diff: src/main/java/org/apache/commons/text/CaseUtils.java ---
    @@ -0,0 +1,140 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *      http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.commons.text;
    +
    +import org.apache.commons.lang3.StringUtils;
    +
    +import java.util.HashSet;
    +import java.util.Set;
    +
    +/**
    + * <p>Case manipulation operations on Strings that contain words.</p>
    + *
    + * <p>This class tries to handle <code>null</code> input gracefully.
    + * An exception will not be thrown for a <code>null</code> input.
    + * Each method documents its behaviour in more detail.</p>
    + *
    + * @since 1.0
    + */
    +public class CaseUtils {
    +
    +    /**
    +     * <p><code>CaseUtils</code> instances should NOT be constructed in
    +     * standard programming. Instead, the class should be used as
    +     * <code>CaseUtils.toCamelCase("foo bar", true, new char[]{'-'});</code>.</p>
    +     * <p>
    +     * <p>This constructor is public to permit tools that require a JavaBean
    +     * instance to operate.</p>
    +     */
    +    public CaseUtils() {
    --- End diff --
    
    You could make the constructor `private`, but I do like the consistency with [`org.apache.commons.lang3.StringUtils.java`](https://github.com/apache/commons-lang/blob/master/src/main/java/org/apache/commons/lang3/StringUtils.java#L176-L186)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] commons-text issue #46: TEXT-85:Added CaseUtils class with camel case conver...

Posted by chtompki <gi...@git.apache.org>.
Github user chtompki commented on the issue:

    https://github.com/apache/commons-text/pull/46
  
    Regarding the `WordUtils.capitalizeFully`, let's open that discussion up in a new Jira. I'll do that now. I think those questions are quite valid.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] commons-text issue #46: TEXT-85:Added CaseUtils class with camel case conver...

Posted by sebbASF <gi...@git.apache.org>.
Github user sebbASF commented on the issue:

    https://github.com/apache/commons-text/pull/46
  
    An empty delimiter array means the caller does not want any delimiters to be used.
    But I would expect the output to capitalise the first letter:
    
    WordUtils.capitalizeFully("i am fine", new char[]{}) --> I am fine
    
    Likewise if the specified delimiters are not found in the input the first letter should be capitalised.
    Does it not do so?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] commons-text issue #46: TEXT-85:Added CaseUtils class with camel case conver...

Posted by arunvinudss <gi...@git.apache.org>.
Github user arunvinudss commented on the issue:

    https://github.com/apache/commons-text/pull/46
  
    @chtompki The current implementation is based on these assumptions.
    
    - All delimiters are stripped off .
    - Space(32) is added as the default delimiter for all scenarios including null and empty delimiter array.
    - The boolean parameter for capitalizeFirstCharacter gets higher precedence than delimiters. For ex if '-' is the delimiter then -abc will give Abc  as output if true is set for capitalizeFirstCharacter. 
    - A string with no alphabets and only delimiters will return back the input with no changes. 
    
    Just made logical conclusions let me know if need any changes .



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] commons-text pull request #46: TEXT-85:Added CaseUtils class with camel case...

Posted by chtompki <gi...@git.apache.org>.
Github user chtompki commented on a diff in the pull request:

    https://github.com/apache/commons-text/pull/46#discussion_r121380327
  
    --- Diff: src/main/java/org/apache/commons/text/CaseUtils.java ---
    @@ -0,0 +1,140 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *      http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.commons.text;
    +
    +import org.apache.commons.lang3.StringUtils;
    +
    +import java.util.HashSet;
    +import java.util.Set;
    +
    +/**
    + * <p>Case manipulation operations on Strings that contain words.</p>
    + *
    + * <p>This class tries to handle <code>null</code> input gracefully.
    + * An exception will not be thrown for a <code>null</code> input.
    + * Each method documents its behaviour in more detail.</p>
    + *
    + * @since 1.0
    + */
    +public class CaseUtils {
    +
    +    /**
    +     * <p><code>CaseUtils</code> instances should NOT be constructed in
    +     * standard programming. Instead, the class should be used as
    +     * <code>CaseUtils.toCamelCase("foo bar", true, new char[]{'-'});</code>.</p>
    +     * <p>
    +     * <p>This constructor is public to permit tools that require a JavaBean
    +     * instance to operate.</p>
    +     */
    +    public CaseUtils() {
    +        super();
    +    }
    +
    +    // Camel Case
    +    //-----------------------------------------------------------------------
    +    /**
    +     * <p>Converts all the delimiter separated words in a String into camelCase,
    +     * that is each word is made up of a titlecase character and then a series of
    +     * lowercase characters. The  </p>
    +     *
    +     * <p>The delimiters represent a set of characters understood to separate words.
    +     * The first non-delimiter character after a delimiter will be capitalized. The first String
    +     * character may or may not be capitalized and it's determined by the user input for capitalizeFirstLetter
    +     * variable.</p>
    +     *
    +     * <p>A <code>null</code> input String returns <code>null</code>.
    +     * Capitalization uses the Unicode title case, normally equivalent to
    +     * upper case.</p>
    +     *
    +     * <pre>
    +     * CaseUtils.toCamelCase(null, false)                                 = null
    +     * CaseUtils.toCamelCase("", false, *)                                = ""
    +     * CaseUtils.toCamelCase(*, false, null)                              = *
    +     * CaseUtils.toCamelCase(*, true, new char[0])                        = *
    +     * CaseUtils.toCamelCase("To.Camel.Case", false, new char[]{'.'})     = "toCamelCase"
    +     * CaseUtils.toCamelCase(" to @ Camel case", true, new char[]{'@'})   = "toCamelCase"
    +     * CaseUtils.toCamelCase(" @to @ Camel case", false, new char[]{'@'}) = "toCamelCase"
    +     * </pre>
    +     *
    +     * @param str  the String to be converted to camelCase, may be null
    +     * @param capitalizeFirstLetter boolean that determines if the first character of first word should be title case.
    +     * @param delimiters  set of characters to determine capitalization, null and/or empty array means whitespace
    +     * @return camelCase of String, <code>null</code> if null String input
    +     */
    +    public static String toCamelCase(String str, boolean capitalizeFirstLetter, final char... delimiters) {
    +        if (StringUtils.isEmpty(str)) {
    +            return str;
    +        }
    +        str = str.toLowerCase();
    +        int strLen = str.length();
    +        int [] newCodePoints = new int[strLen];
    +        int outOffset = 0;
    +        Set<Integer> delimiterSet = generateDelimiterSet(delimiters);
    +        boolean capitalizeNext = false;
    +        if (capitalizeFirstLetter) {
    +            capitalizeNext = true;
    +        }
    +        for (int index = 0; index < strLen;) {
    +            final int codePoint = str.codePointAt(index);
    +
    +            if (delimiterSet.contains(codePoint)) {
    +                capitalizeNext = true;
    +                if (outOffset == 0) {
    +                    capitalizeNext = false;
    +                }
    +                index += Character.charCount(codePoint);
    +            } else if (capitalizeNext || (outOffset == 0 && capitalizeFirstLetter)) {
    +                int titleCaseCodePoint = Character.toTitleCase(codePoint);
    --- End diff --
    
    +1 on operating on `int`s.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] commons-text issue #46: TEXT-85:Added CaseUtils class with camel case conver...

Posted by arunvinudss <gi...@git.apache.org>.
Github user arunvinudss commented on the issue:

    https://github.com/apache/commons-text/pull/46
  
    @chtompki Updated with the changes you suggested .


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] commons-text issue #46: TEXT-85:Added CaseUtils class with camel case conver...

Posted by arunvinudss <gi...@git.apache.org>.
Github user arunvinudss commented on the issue:

    https://github.com/apache/commons-text/pull/46
  
    @chtompki Just wondering why space is added as a default delimiter for null delimiter arrays but not for empty delimiter array in WordUtils.capitalizeFully .
    
    WordUtils.capitalizeFully("i am fine") --> I Am Fine
    WordUtils.capitalizeFully("i am fine", null) --> I Am Fine
    WordUtils.capitalizeFully("i am fine", new char[]{}) --> i am fine
    
    I do understand why it happens but not sure if it was intentional ? 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] commons-text pull request #46: TEXT-85:Added CaseUtils class with camel case...

Posted by chtompki <gi...@git.apache.org>.
Github user chtompki commented on a diff in the pull request:

    https://github.com/apache/commons-text/pull/46#discussion_r121380270
  
    --- Diff: src/main/java/org/apache/commons/text/CaseUtils.java ---
    @@ -0,0 +1,140 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *      http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.commons.text;
    +
    +import org.apache.commons.lang3.StringUtils;
    +
    +import java.util.HashSet;
    +import java.util.Set;
    +
    +/**
    + * <p>Case manipulation operations on Strings that contain words.</p>
    + *
    + * <p>This class tries to handle <code>null</code> input gracefully.
    + * An exception will not be thrown for a <code>null</code> input.
    + * Each method documents its behaviour in more detail.</p>
    + *
    + * @since 1.0
    + */
    +public class CaseUtils {
    +
    +    /**
    +     * <p><code>CaseUtils</code> instances should NOT be constructed in
    +     * standard programming. Instead, the class should be used as
    +     * <code>CaseUtils.toCamelCase("foo bar", true, new char[]{'-'});</code>.</p>
    +     * <p>
    +     * <p>This constructor is public to permit tools that require a JavaBean
    +     * instance to operate.</p>
    +     */
    +    public CaseUtils() {
    +        super();
    +    }
    +
    +    // Camel Case
    +    //-----------------------------------------------------------------------
    +    /**
    +     * <p>Converts all the delimiter separated words in a String into camelCase,
    +     * that is each word is made up of a titlecase character and then a series of
    +     * lowercase characters. The  </p>
    +     *
    +     * <p>The delimiters represent a set of characters understood to separate words.
    +     * The first non-delimiter character after a delimiter will be capitalized. The first String
    +     * character may or may not be capitalized and it's determined by the user input for capitalizeFirstLetter
    +     * variable.</p>
    +     *
    +     * <p>A <code>null</code> input String returns <code>null</code>.
    +     * Capitalization uses the Unicode title case, normally equivalent to
    +     * upper case.</p>
    +     *
    --- End diff --
    
    I wonder if, like in [`Character.toUpperCase`](https://docs.oracle.com/javase/8/docs/api/java/lang/Character.html#toUpperCase-char-), we should document that we are not locale based which I support. Adding in `Locale` to the mix throws added complexity that may not be needed. Or document that we're relying on `Character.toTitleCase` which has no `Locale` based analogue in `String`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] commons-text issue #46: TEXT-85:Added CaseUtils class with camel case conver...

Posted by arunvinudss <gi...@git.apache.org>.
Github user arunvinudss commented on the issue:

    https://github.com/apache/commons-text/pull/46
  
    @sebbASF  Nope the first letter is not capitalized and I expected the same . It seems to happen if the specified delimiters are not available on the input though .


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] commons-text pull request #46: TEXT-85:Added CaseUtils class with camel case...

Posted by chtompki <gi...@git.apache.org>.
Github user chtompki commented on a diff in the pull request:

    https://github.com/apache/commons-text/pull/46#discussion_r121376797
  
    --- Diff: src/main/java/org/apache/commons/text/CaseUtils.java ---
    @@ -0,0 +1,140 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *      http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.commons.text;
    +
    +import org.apache.commons.lang3.StringUtils;
    +
    +import java.util.HashSet;
    +import java.util.Set;
    +
    +/**
    + * <p>Case manipulation operations on Strings that contain words.</p>
    + *
    + * <p>This class tries to handle <code>null</code> input gracefully.
    + * An exception will not be thrown for a <code>null</code> input.
    + * Each method documents its behaviour in more detail.</p>
    + *
    + * @since 1.0
    + */
    +public class CaseUtils {
    +
    +    /**
    +     * <p><code>CaseUtils</code> instances should NOT be constructed in
    +     * standard programming. Instead, the class should be used as
    +     * <code>CaseUtils.toCamelCase("foo bar", true, new char[]{'-'});</code>.</p>
    +     * <p>
    +     * <p>This constructor is public to permit tools that require a JavaBean
    +     * instance to operate.</p>
    +     */
    +    public CaseUtils() {
    +        super();
    +    }
    +
    +    // Camel Case
    +    //-----------------------------------------------------------------------
    +    /**
    +     * <p>Converts all the delimiter separated words in a String into camelCase,
    +     * that is each word is made up of a titlecase character and then a series of
    +     * lowercase characters. The  </p>
    +     *
    +     * <p>The delimiters represent a set of characters understood to separate words.
    +     * The first non-delimiter character after a delimiter will be capitalized. The first String
    +     * character may or may not be capitalized and it's determined by the user input for capitalizeFirstLetter
    +     * variable.</p>
    +     *
    +     * <p>A <code>null</code> input String returns <code>null</code>.
    +     * Capitalization uses the Unicode title case, normally equivalent to
    +     * upper case.</p>
    +     *
    +     * <pre>
    +     * CaseUtils.toCamelCase(null, false)                                 = null
    +     * CaseUtils.toCamelCase("", false, *)                                = ""
    +     * CaseUtils.toCamelCase(*, false, null)                              = *
    +     * CaseUtils.toCamelCase(*, true, new char[0])                        = *
    +     * CaseUtils.toCamelCase("To.Camel.Case", false, new char[]{'.'})     = "toCamelCase"
    +     * CaseUtils.toCamelCase(" to @ Camel case", true, new char[]{'@'})   = "toCamelCase"
    +     * CaseUtils.toCamelCase(" @to @ Camel case", false, new char[]{'@'}) = "toCamelCase"
    +     * </pre>
    +     *
    +     * @param str  the String to be converted to camelCase, may be null
    +     * @param capitalizeFirstLetter boolean that determines if the first character of first word should be title case.
    +     * @param delimiters  set of characters to determine capitalization, null and/or empty array means whitespace
    +     * @return camelCase of String, <code>null</code> if null String input
    +     */
    +    public static String toCamelCase(String str, boolean capitalizeFirstLetter, final char... delimiters) {
    --- End diff --
    
    I think that we'll want:
    ```java
    public static String toCamelCase(final String str, final boolean capitalizeFirstLetter, final char... delimiters)
    ```
    but I see that you've fiddled with the `str` variable below. So I'm open to discussion on that point.
    
    Generally, I'm torn on whether to have the signature be:
    ```java
    public static String toCamelCase(final String str, final boolean capitalizeFirstLetter, final char... delimiters);
    ```
    or
    ```java
    public static String toCamelCase(final CharSequence str, final boolean capitalizeFirstLetter, final char... delimiters);
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] commons-text pull request #46: TEXT-85:Added CaseUtils class with camel case...

Posted by chtompki <gi...@git.apache.org>.
Github user chtompki commented on a diff in the pull request:

    https://github.com/apache/commons-text/pull/46#discussion_r121376091
  
    --- Diff: src/main/java/org/apache/commons/text/CaseUtils.java ---
    @@ -0,0 +1,140 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *      http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.commons.text;
    +
    +import org.apache.commons.lang3.StringUtils;
    +
    +import java.util.HashSet;
    +import java.util.Set;
    +
    +/**
    + * <p>Case manipulation operations on Strings that contain words.</p>
    + *
    + * <p>This class tries to handle <code>null</code> input gracefully.
    + * An exception will not be thrown for a <code>null</code> input.
    + * Each method documents its behaviour in more detail.</p>
    + *
    + * @since 1.0
    + */
    +public class CaseUtils {
    +
    +    /**
    +     * <p><code>CaseUtils</code> instances should NOT be constructed in
    +     * standard programming. Instead, the class should be used as
    +     * <code>CaseUtils.toCamelCase("foo bar", true, new char[]{'-'});</code>.</p>
    +     * <p>
    +     * <p>This constructor is public to permit tools that require a JavaBean
    +     * instance to operate.</p>
    +     */
    +    public CaseUtils() {
    +        super();
    +    }
    +
    +    // Camel Case
    +    //-----------------------------------------------------------------------
    +    /**
    +     * <p>Converts all the delimiter separated words in a String into camelCase,
    +     * that is each word is made up of a titlecase character and then a series of
    +     * lowercase characters. The  </p>
    +     *
    +     * <p>The delimiters represent a set of characters understood to separate words.
    +     * The first non-delimiter character after a delimiter will be capitalized. The first String
    +     * character may or may not be capitalized and it's determined by the user input for capitalizeFirstLetter
    +     * variable.</p>
    +     *
    +     * <p>A <code>null</code> input String returns <code>null</code>.
    +     * Capitalization uses the Unicode title case, normally equivalent to
    +     * upper case.</p>
    +     *
    +     * <pre>
    +     * CaseUtils.toCamelCase(null, false)                                 = null
    +     * CaseUtils.toCamelCase("", false, *)                                = ""
    +     * CaseUtils.toCamelCase(*, false, null)                              = *
    +     * CaseUtils.toCamelCase(*, true, new char[0])                        = *
    +     * CaseUtils.toCamelCase("To.Camel.Case", false, new char[]{'.'})     = "toCamelCase"
    +     * CaseUtils.toCamelCase(" to @ Camel case", true, new char[]{'@'})   = "toCamelCase"
    +     * CaseUtils.toCamelCase(" @to @ Camel case", false, new char[]{'@'}) = "toCamelCase"
    +     * </pre>
    +     *
    +     * @param str  the String to be converted to camelCase, may be null
    +     * @param capitalizeFirstLetter boolean that determines if the first character of first word should be title case.
    +     * @param delimiters  set of characters to determine capitalization, null and/or empty array means whitespace
    +     * @return camelCase of String, <code>null</code> if null String input
    +     */
    +    public static String toCamelCase(String str, boolean capitalizeFirstLetter, final char... delimiters) {
    +        if (StringUtils.isEmpty(str)) {
    +            return str;
    +        }
    +        str = str.toLowerCase();
    +        int strLen = str.length();
    +        int [] newCodePoints = new int[strLen];
    +        int outOffset = 0;
    +        Set<Integer> delimiterSet = generateDelimiterSet(delimiters);
    +        boolean capitalizeNext = false;
    +        if (capitalizeFirstLetter) {
    +            capitalizeNext = true;
    +        }
    +        for (int index = 0; index < strLen;) {
    +            final int codePoint = str.codePointAt(index);
    +
    +            if (delimiterSet.contains(codePoint)) {
    +                capitalizeNext = true;
    +                if (outOffset == 0) {
    +                    capitalizeNext = false;
    +                }
    +                index += Character.charCount(codePoint);
    +            } else if (capitalizeNext || (outOffset == 0 && capitalizeFirstLetter)) {
    --- End diff --
    
    PMD complains about the useless parentheses (capitalizeNext || __(__ outOffset == 0 && capitalizeFirstLetter __)__ ). Order of operations is `&&` then `||`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] commons-text issue #46: TEXT-85:Added CaseUtils class with camel case conver...

Posted by arunvinudss <gi...@git.apache.org>.
Github user arunvinudss commented on the issue:

    https://github.com/apache/commons-text/pull/46
  
    @chtompki Using HashSets for checking delimiters it reduces the time complexity from O(nk) to O(n) . I feel it's more efficient . 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] commons-text pull request #46: TEXT-85:Added CaseUtils class with camel case...

Posted by chtompki <gi...@git.apache.org>.
Github user chtompki commented on a diff in the pull request:

    https://github.com/apache/commons-text/pull/46#discussion_r121378617
  
    --- Diff: src/main/java/org/apache/commons/text/CaseUtils.java ---
    @@ -0,0 +1,140 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *      http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.commons.text;
    +
    +import org.apache.commons.lang3.StringUtils;
    +
    +import java.util.HashSet;
    +import java.util.Set;
    +
    +/**
    + * <p>Case manipulation operations on Strings that contain words.</p>
    + *
    + * <p>This class tries to handle <code>null</code> input gracefully.
    + * An exception will not be thrown for a <code>null</code> input.
    + * Each method documents its behaviour in more detail.</p>
    + *
    + * @since 1.0
    + */
    +public class CaseUtils {
    +
    +    /**
    +     * <p><code>CaseUtils</code> instances should NOT be constructed in
    +     * standard programming. Instead, the class should be used as
    +     * <code>CaseUtils.toCamelCase("foo bar", true, new char[]{'-'});</code>.</p>
    +     * <p>
    +     * <p>This constructor is public to permit tools that require a JavaBean
    +     * instance to operate.</p>
    +     */
    +    public CaseUtils() {
    +        super();
    +    }
    +
    +    // Camel Case
    +    //-----------------------------------------------------------------------
    +    /**
    +     * <p>Converts all the delimiter separated words in a String into camelCase,
    +     * that is each word is made up of a titlecase character and then a series of
    +     * lowercase characters. The  </p>
    +     *
    +     * <p>The delimiters represent a set of characters understood to separate words.
    +     * The first non-delimiter character after a delimiter will be capitalized. The first String
    +     * character may or may not be capitalized and it's determined by the user input for capitalizeFirstLetter
    +     * variable.</p>
    +     *
    +     * <p>A <code>null</code> input String returns <code>null</code>.
    +     * Capitalization uses the Unicode title case, normally equivalent to
    +     * upper case.</p>
    +     *
    +     * <pre>
    +     * CaseUtils.toCamelCase(null, false)                                 = null
    +     * CaseUtils.toCamelCase("", false, *)                                = ""
    +     * CaseUtils.toCamelCase(*, false, null)                              = *
    +     * CaseUtils.toCamelCase(*, true, new char[0])                        = *
    +     * CaseUtils.toCamelCase("To.Camel.Case", false, new char[]{'.'})     = "toCamelCase"
    +     * CaseUtils.toCamelCase(" to @ Camel case", true, new char[]{'@'})   = "toCamelCase"
    +     * CaseUtils.toCamelCase(" @to @ Camel case", false, new char[]{'@'}) = "toCamelCase"
    +     * </pre>
    +     *
    +     * @param str  the String to be converted to camelCase, may be null
    +     * @param capitalizeFirstLetter boolean that determines if the first character of first word should be title case.
    +     * @param delimiters  set of characters to determine capitalization, null and/or empty array means whitespace
    +     * @return camelCase of String, <code>null</code> if null String input
    +     */
    +    public static String toCamelCase(String str, boolean capitalizeFirstLetter, final char... delimiters) {
    +        if (StringUtils.isEmpty(str)) {
    +            return str;
    +        }
    +        str = str.toLowerCase();
    +        int strLen = str.length();
    +        int [] newCodePoints = new int[strLen];
    +        int outOffset = 0;
    +        Set<Integer> delimiterSet = generateDelimiterSet(delimiters);
    +        boolean capitalizeNext = false;
    +        if (capitalizeFirstLetter) {
    +            capitalizeNext = true;
    +        }
    +        for (int index = 0; index < strLen;) {
    +            final int codePoint = str.codePointAt(index);
    --- End diff --
    
    If we decide to go with `CharSequence` here, this becomes a tougher move. We have to begin worrying about UTF-16 and "surrogate pairs' of characters. See [docs here](https://docs.oracle.com/javase/8/docs/api/java/lang/Character.html#unicode)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] commons-text pull request #46: TEXT-85:Added CaseUtils class with camel case...

Posted by arunvinudss <gi...@git.apache.org>.
Github user arunvinudss commented on a diff in the pull request:

    https://github.com/apache/commons-text/pull/46#discussion_r121408959
  
    --- Diff: src/main/java/org/apache/commons/text/CaseUtils.java ---
    @@ -0,0 +1,140 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *      http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.commons.text;
    +
    +import org.apache.commons.lang3.StringUtils;
    +
    +import java.util.HashSet;
    +import java.util.Set;
    +
    +/**
    + * <p>Case manipulation operations on Strings that contain words.</p>
    + *
    + * <p>This class tries to handle <code>null</code> input gracefully.
    + * An exception will not be thrown for a <code>null</code> input.
    + * Each method documents its behaviour in more detail.</p>
    + *
    + * @since 1.0
    + */
    +public class CaseUtils {
    +
    +    /**
    +     * <p><code>CaseUtils</code> instances should NOT be constructed in
    +     * standard programming. Instead, the class should be used as
    +     * <code>CaseUtils.toCamelCase("foo bar", true, new char[]{'-'});</code>.</p>
    +     * <p>
    +     * <p>This constructor is public to permit tools that require a JavaBean
    +     * instance to operate.</p>
    +     */
    +    public CaseUtils() {
    +        super();
    +    }
    +
    +    // Camel Case
    +    //-----------------------------------------------------------------------
    +    /**
    +     * <p>Converts all the delimiter separated words in a String into camelCase,
    +     * that is each word is made up of a titlecase character and then a series of
    +     * lowercase characters. The  </p>
    +     *
    +     * <p>The delimiters represent a set of characters understood to separate words.
    +     * The first non-delimiter character after a delimiter will be capitalized. The first String
    +     * character may or may not be capitalized and it's determined by the user input for capitalizeFirstLetter
    +     * variable.</p>
    +     *
    +     * <p>A <code>null</code> input String returns <code>null</code>.
    +     * Capitalization uses the Unicode title case, normally equivalent to
    +     * upper case.</p>
    +     *
    +     * <pre>
    +     * CaseUtils.toCamelCase(null, false)                                 = null
    +     * CaseUtils.toCamelCase("", false, *)                                = ""
    +     * CaseUtils.toCamelCase(*, false, null)                              = *
    +     * CaseUtils.toCamelCase(*, true, new char[0])                        = *
    +     * CaseUtils.toCamelCase("To.Camel.Case", false, new char[]{'.'})     = "toCamelCase"
    +     * CaseUtils.toCamelCase(" to @ Camel case", true, new char[]{'@'})   = "toCamelCase"
    +     * CaseUtils.toCamelCase(" @to @ Camel case", false, new char[]{'@'}) = "toCamelCase"
    +     * </pre>
    +     *
    +     * @param str  the String to be converted to camelCase, may be null
    +     * @param capitalizeFirstLetter boolean that determines if the first character of first word should be title case.
    +     * @param delimiters  set of characters to determine capitalization, null and/or empty array means whitespace
    +     * @return camelCase of String, <code>null</code> if null String input
    +     */
    +    public static String toCamelCase(String str, boolean capitalizeFirstLetter, final char... delimiters) {
    --- End diff --
    
    Yes the boolean should be final not sure why I missed that . The input string is not final as you mentioned  I change it to lower case inside the method .


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] commons-text pull request #46: TEXT-85:Added CaseUtils class with camel case...

Posted by arunvinudss <gi...@git.apache.org>.
Github user arunvinudss commented on a diff in the pull request:

    https://github.com/apache/commons-text/pull/46#discussion_r121417851
  
    --- Diff: src/main/java/org/apache/commons/text/CaseUtils.java ---
    @@ -0,0 +1,140 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *      http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.commons.text;
    +
    +import org.apache.commons.lang3.StringUtils;
    +
    +import java.util.HashSet;
    +import java.util.Set;
    +
    +/**
    + * <p>Case manipulation operations on Strings that contain words.</p>
    + *
    + * <p>This class tries to handle <code>null</code> input gracefully.
    + * An exception will not be thrown for a <code>null</code> input.
    + * Each method documents its behaviour in more detail.</p>
    + *
    + * @since 1.0
    + */
    +public class CaseUtils {
    +
    +    /**
    +     * <p><code>CaseUtils</code> instances should NOT be constructed in
    +     * standard programming. Instead, the class should be used as
    +     * <code>CaseUtils.toCamelCase("foo bar", true, new char[]{'-'});</code>.</p>
    +     * <p>
    +     * <p>This constructor is public to permit tools that require a JavaBean
    +     * instance to operate.</p>
    +     */
    +    public CaseUtils() {
    +        super();
    +    }
    +
    +    // Camel Case
    +    //-----------------------------------------------------------------------
    +    /**
    +     * <p>Converts all the delimiter separated words in a String into camelCase,
    +     * that is each word is made up of a titlecase character and then a series of
    +     * lowercase characters. The  </p>
    +     *
    +     * <p>The delimiters represent a set of characters understood to separate words.
    +     * The first non-delimiter character after a delimiter will be capitalized. The first String
    +     * character may or may not be capitalized and it's determined by the user input for capitalizeFirstLetter
    +     * variable.</p>
    +     *
    +     * <p>A <code>null</code> input String returns <code>null</code>.
    +     * Capitalization uses the Unicode title case, normally equivalent to
    +     * upper case.</p>
    +     *
    +     * <pre>
    +     * CaseUtils.toCamelCase(null, false)                                 = null
    +     * CaseUtils.toCamelCase("", false, *)                                = ""
    +     * CaseUtils.toCamelCase(*, false, null)                              = *
    +     * CaseUtils.toCamelCase(*, true, new char[0])                        = *
    +     * CaseUtils.toCamelCase("To.Camel.Case", false, new char[]{'.'})     = "toCamelCase"
    +     * CaseUtils.toCamelCase(" to @ Camel case", true, new char[]{'@'})   = "toCamelCase"
    +     * CaseUtils.toCamelCase(" @to @ Camel case", false, new char[]{'@'}) = "toCamelCase"
    +     * </pre>
    +     *
    +     * @param str  the String to be converted to camelCase, may be null
    +     * @param capitalizeFirstLetter boolean that determines if the first character of first word should be title case.
    +     * @param delimiters  set of characters to determine capitalization, null and/or empty array means whitespace
    +     * @return camelCase of String, <code>null</code> if null String input
    +     */
    +    public static String toCamelCase(String str, boolean capitalizeFirstLetter, final char... delimiters) {
    --- End diff --
    
    I am a bit biased towards using String instead of CharSequence . Yes CharSequence allows us to pass String Buffers and builders and other types as input potentially increasing the scope of the function but considering the nature of work we do in this particular method it may not necessarily be a good idea. My basic contention is that the minute we call toString() on a charSequence  to do any sort of manipulation it becomes a costly operation and we may lose performance . 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] commons-text issue #46: TEXT-85:Added CaseUtils class with camel case conver...

Posted by coveralls <gi...@git.apache.org>.
Github user coveralls commented on the issue:

    https://github.com/apache/commons-text/pull/46
  
    
    [![Coverage Status](https://coveralls.io/builds/11920859/badge)](https://coveralls.io/builds/11920859)
    
    Coverage increased (+0.04%) to 96.691% when pulling **2de01ba6a343ffcce673768e1c603e27dfbda3e9 on arunvinudss:TEXT-85** into **5f498c0f4783d035bfeb77517731c948f8567b1e on apache:master**.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] commons-text pull request #46: TEXT-85:Added CaseUtils class with camel case...

Posted by chtompki <gi...@git.apache.org>.
Github user chtompki commented on a diff in the pull request:

    https://github.com/apache/commons-text/pull/46#discussion_r121376021
  
    --- Diff: src/main/java/org/apache/commons/text/CaseUtils.java ---
    @@ -0,0 +1,140 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *      http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.commons.text;
    +
    +import org.apache.commons.lang3.StringUtils;
    +
    +import java.util.HashSet;
    +import java.util.Set;
    +
    +/**
    + * <p>Case manipulation operations on Strings that contain words.</p>
    + *
    + * <p>This class tries to handle <code>null</code> input gracefully.
    + * An exception will not be thrown for a <code>null</code> input.
    + * Each method documents its behaviour in more detail.</p>
    + *
    + * @since 1.0
    + */
    +public class CaseUtils {
    +
    +    /**
    +     * <p><code>CaseUtils</code> instances should NOT be constructed in
    +     * standard programming. Instead, the class should be used as
    +     * <code>CaseUtils.toCamelCase("foo bar", true, new char[]{'-'});</code>.</p>
    +     * <p>
    +     * <p>This constructor is public to permit tools that require a JavaBean
    +     * instance to operate.</p>
    +     */
    +    public CaseUtils() {
    +        super();
    +    }
    +
    +    // Camel Case
    +    //-----------------------------------------------------------------------
    +    /**
    +     * <p>Converts all the delimiter separated words in a String into camelCase,
    +     * that is each word is made up of a titlecase character and then a series of
    +     * lowercase characters. The  </p>
    +     *
    +     * <p>The delimiters represent a set of characters understood to separate words.
    +     * The first non-delimiter character after a delimiter will be capitalized. The first String
    +     * character may or may not be capitalized and it's determined by the user input for capitalizeFirstLetter
    +     * variable.</p>
    +     *
    +     * <p>A <code>null</code> input String returns <code>null</code>.
    +     * Capitalization uses the Unicode title case, normally equivalent to
    +     * upper case.</p>
    +     *
    +     * <pre>
    +     * CaseUtils.toCamelCase(null, false)                                 = null
    +     * CaseUtils.toCamelCase("", false, *)                                = ""
    +     * CaseUtils.toCamelCase(*, false, null)                              = *
    +     * CaseUtils.toCamelCase(*, true, new char[0])                        = *
    +     * CaseUtils.toCamelCase("To.Camel.Case", false, new char[]{'.'})     = "toCamelCase"
    +     * CaseUtils.toCamelCase(" to @ Camel case", true, new char[]{'@'})   = "toCamelCase"
    --- End diff --
    
    After looking at the tests, this appears to be merely a documentation error.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] commons-text pull request #46: TEXT-85:Added CaseUtils class with camel case...

Posted by chtompki <gi...@git.apache.org>.
Github user chtompki commented on a diff in the pull request:

    https://github.com/apache/commons-text/pull/46#discussion_r121374008
  
    --- Diff: src/main/java/org/apache/commons/text/CaseUtils.java ---
    @@ -0,0 +1,140 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *      http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.commons.text;
    +
    +import org.apache.commons.lang3.StringUtils;
    +
    +import java.util.HashSet;
    +import java.util.Set;
    +
    +/**
    + * <p>Case manipulation operations on Strings that contain words.</p>
    + *
    + * <p>This class tries to handle <code>null</code> input gracefully.
    + * An exception will not be thrown for a <code>null</code> input.
    + * Each method documents its behaviour in more detail.</p>
    + *
    + * @since 1.0
    + */
    +public class CaseUtils {
    +
    +    /**
    +     * <p><code>CaseUtils</code> instances should NOT be constructed in
    +     * standard programming. Instead, the class should be used as
    +     * <code>CaseUtils.toCamelCase("foo bar", true, new char[]{'-'});</code>.</p>
    +     * <p>
    +     * <p>This constructor is public to permit tools that require a JavaBean
    +     * instance to operate.</p>
    +     */
    +    public CaseUtils() {
    +        super();
    +    }
    +
    +    // Camel Case
    +    //-----------------------------------------------------------------------
    +    /**
    +     * <p>Converts all the delimiter separated words in a String into camelCase,
    +     * that is each word is made up of a titlecase character and then a series of
    +     * lowercase characters. The  </p>
    +     *
    +     * <p>The delimiters represent a set of characters understood to separate words.
    +     * The first non-delimiter character after a delimiter will be capitalized. The first String
    +     * character may or may not be capitalized and it's determined by the user input for capitalizeFirstLetter
    +     * variable.</p>
    +     *
    +     * <p>A <code>null</code> input String returns <code>null</code>.
    +     * Capitalization uses the Unicode title case, normally equivalent to
    +     * upper case.</p>
    +     *
    +     * <pre>
    +     * CaseUtils.toCamelCase(null, false)                                 = null
    +     * CaseUtils.toCamelCase("", false, *)                                = ""
    +     * CaseUtils.toCamelCase(*, false, null)                              = *
    +     * CaseUtils.toCamelCase(*, true, new char[0])                        = *
    +     * CaseUtils.toCamelCase("To.Camel.Case", false, new char[]{'.'})     = "toCamelCase"
    +     * CaseUtils.toCamelCase(" to @ Camel case", true, new char[]{'@'})   = "toCamelCase"
    --- End diff --
    
    Wouldn't we want
    ```java
    CaseUtils.toCamelCase(" to @ Camel case", true, new char[]{'@'})   = "ToCamelCase"
    ```
    because of the `true` boolean?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] commons-text issue #46: TEXT-85:Added CaseUtils class with camel case conver...

Posted by chtompki <gi...@git.apache.org>.
Github user chtompki commented on the issue:

    https://github.com/apache/commons-text/pull/46
  
    Will look this over in the morning. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] commons-text pull request #46: TEXT-85:Added CaseUtils class with camel case...

Posted by arunvinudss <gi...@git.apache.org>.
Github user arunvinudss commented on a diff in the pull request:

    https://github.com/apache/commons-text/pull/46#discussion_r121406140
  
    --- Diff: src/main/java/org/apache/commons/text/CaseUtils.java ---
    @@ -0,0 +1,140 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *      http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.commons.text;
    +
    +import org.apache.commons.lang3.StringUtils;
    +
    +import java.util.HashSet;
    +import java.util.Set;
    +
    +/**
    + * <p>Case manipulation operations on Strings that contain words.</p>
    + *
    + * <p>This class tries to handle <code>null</code> input gracefully.
    + * An exception will not be thrown for a <code>null</code> input.
    + * Each method documents its behaviour in more detail.</p>
    + *
    + * @since 1.0
    + */
    +public class CaseUtils {
    +
    +    /**
    +     * <p><code>CaseUtils</code> instances should NOT be constructed in
    +     * standard programming. Instead, the class should be used as
    +     * <code>CaseUtils.toCamelCase("foo bar", true, new char[]{'-'});</code>.</p>
    +     * <p>
    +     * <p>This constructor is public to permit tools that require a JavaBean
    +     * instance to operate.</p>
    +     */
    +    public CaseUtils() {
    +        super();
    +    }
    +
    +    // Camel Case
    +    //-----------------------------------------------------------------------
    +    /**
    +     * <p>Converts all the delimiter separated words in a String into camelCase,
    +     * that is each word is made up of a titlecase character and then a series of
    +     * lowercase characters. The  </p>
    +     *
    +     * <p>The delimiters represent a set of characters understood to separate words.
    +     * The first non-delimiter character after a delimiter will be capitalized. The first String
    +     * character may or may not be capitalized and it's determined by the user input for capitalizeFirstLetter
    +     * variable.</p>
    +     *
    +     * <p>A <code>null</code> input String returns <code>null</code>.
    +     * Capitalization uses the Unicode title case, normally equivalent to
    +     * upper case.</p>
    +     *
    +     * <pre>
    +     * CaseUtils.toCamelCase(null, false)                                 = null
    +     * CaseUtils.toCamelCase("", false, *)                                = ""
    +     * CaseUtils.toCamelCase(*, false, null)                              = *
    +     * CaseUtils.toCamelCase(*, true, new char[0])                        = *
    +     * CaseUtils.toCamelCase("To.Camel.Case", false, new char[]{'.'})     = "toCamelCase"
    +     * CaseUtils.toCamelCase(" to @ Camel case", true, new char[]{'@'})   = "toCamelCase"
    --- End diff --
    
    Yes it's a documentation error I will update it . 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] commons-text pull request #46: TEXT-85:Added CaseUtils class with camel case...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/commons-text/pull/46


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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