Here you can find the source of toJavaMethodName(String sqlNotation)
Parameter | Description |
---|---|
sqlNotation | a parameter |
public static String toJavaMethodName(String sqlNotation)
//package com.java2s; /******************************************************************************* * Copyright (c) 2011 MadRobot./*from w ww . ja v a 2 s. c o m*/ * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v2.1 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * * Contributors: * Elton Kent - initial API and implementation ******************************************************************************/ public class Main { /** * Convert name of format THIS_IS_A_NAME to thisIsAName For each letter: if * not '_' then convert to lower case and add to output string if '_' then * skip letter and add next letter to output string without converting to * lower case * * @param sqlNotation * @return A name complaint with naming convention for Java methods and * fields, converted from SQL name */ public static String toJavaMethodName(String sqlNotation) { StringBuilder dest = new StringBuilder(); char[] src = sqlNotation.toCharArray(); for (int i = 0; i < src.length; i++) { char c = src[i]; boolean isFirstChar = (i == 0) ? true : false; if (isFirstChar || c != '_') { dest.append(Character.toLowerCase(c)); } else { i++; if (i < src.length) { dest.append(src[i]); } } } return dest.toString(); } }