Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 15181200C92 for ; Mon, 12 Jun 2017 14:45:11 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 139DC160BEC; Mon, 12 Jun 2017 12:45:11 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3393A160BD6 for ; Mon, 12 Jun 2017 14:45:10 +0200 (CEST) Received: (qmail 68508 invoked by uid 500); 12 Jun 2017 12:45:04 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 68405 invoked by uid 99); 12 Jun 2017 12:45:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Jun 2017 12:45:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 50B5E180418 for ; Mon, 12 Jun 2017 12:45:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id pR6JIYaF8sCC for ; Mon, 12 Jun 2017 12:45:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id C30F05FCA1 for ; Mon, 12 Jun 2017 12:45:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 29CFCE0D22 for ; Mon, 12 Jun 2017 12:45:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 73ED321E0F for ; Mon, 12 Jun 2017 12:45:00 +0000 (UTC) Date: Mon, 12 Jun 2017 12:45:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (TEXT-85) Create CaseUtils class. Add toCamelCase MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 12 Jun 2017 12:45:11 -0000 [ https://issues.apache.org/jira/browse/TEXT-85?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16046514#comment-16046514 ] 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_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; + +/** + *

Case manipulation operations on Strings that contain words.

+ * + *

This class tries to handle null input gracefully. + * An exception will not be thrown for a null input. + * Each method documents its behaviour in more detail.

+ * + * @since 1.0 + */ +public class CaseUtils { + + /** + *

CaseUtils instances should NOT be constructed in + * standard programming. Instead, the class should be used as + * CaseUtils.toCamelCase("foo bar", true, new char[]{'-'});.

+ *

+ *

This constructor is public to permit tools that require a JavaBean + * instance to operate.

+ */ + public CaseUtils() { + super(); + } + + // Camel Case + //----------------------------------------------------------------------- + /** + *

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

+ * + *

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.

+ * + *

A null input String returns null. + * Capitalization uses the Unicode title case, normally equivalent to + * upper case.

+ * --- 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`. > 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)