[ https://issues.apache.org/jira/browse/TEXT-85?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16046513#comment-16046513 ]
ASF GitHub Bot commented on TEXT-85: ------------------------------------ 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. > Create CaseUtils class. Add toCamelCase > --------------------------------------- > > Key: TEXT-85 > URL: https://issues.apache.org/jira/browse/TEXT-85 > Project: Commons Text > Issue Type: Improvement > Reporter: Rob Tompkins > Assignee: Rob Tompkins > > Based on the conversation here: > http://markmail.org/message/7nvizsbykvxpr7g5 > We wish to have a {{toCamelCase}} method. The suggestion is to create a > {{CaseUtils}} class. > I wonder if we should think about deprecating the case management in > {{WordUtils}} and move it over? Maybe, maybe not. > I would think our method signature would look something like: > {code} > String toCamelCase(String str, char delimiter, boolean capitalizeFirstLetter) > {code} > potentially with {{String}} replaced with {{CharSequence}}. > Lastly, {{WordUtils.capitalizeFully(String str, final char... delimiters)}} > might be a good starting point. > https://github.com/apache/commons-text/blob/master/src/main/java/org/apache/commons/text/WordUtils.java#L467-L499 -- This message was sent by Atlassian JIRA (v6.4.14#64029)