public static String dbNameToVarName(String columnName){
  if (columnName == null)   return null;
  StringBuilder fieldName=new StringBuilder(columnName.length());
  boolean toUpper=false;
  for (int i=0; i < columnName.length(); i++) {
    char ch=columnName.charAt(i);
    if (ch == '_') {
      toUpper=true;
    }
 else     if (toUpper) {
      fieldName.append(Character.toUpperCase(ch));
      toUpper=false;
    }
 else {
      fieldName.append(Character.toLowerCase(ch));
    }
  }
  return fieldName.toString();
}

public static String dbNameToVarName ( String columnName ) { if ( columnName == null ) return null ; StringBuilder fieldName = new StringBuilder ( columnName . length ( ) ) ; boolean toUpper = false ; for ( int i = 0 ; i < columnName . length ( ) ; i ++ ) { char ch = columnName . charAt ( i ) ; if ( ch == '_' ) { toUpper = true ; } else if ( toUpper ) { fieldName . append ( Character . toUpperCase ( ch ) ) ; toUpper = false ; } else { fieldName . append ( Character . toLowerCase ( ch ) ) ; } } return fieldName . toString ( ) ; }
converts a database name to a java variable name . the naming conventions used to allow for this are as follows : a database name ( table or column ) is in all capital letters , and the words are separated by an underscore ( for example : neat_entity_name or random_field_name ) ; a java name ( ejb or field ) is in all lower case letters , except the letter at the beginning of each word ( for example : neatentityname or randomfieldname ) . the convention of using a capital letter at the beginning of a class name in java , or a lower - case letter for the beginning of a variable name in java is also used along with the java name convention above .
