1 package org.apache.ojb.tools.mapping.reversedb; 2 3 17 18 19 20 21 27 public class Namer 28 { 29 32 public static String nameClass(String tableName) 33 { 34 StringBuffer sb = new StringBuffer (); 35 char[] chars = new char[tableName.length()]; 36 chars = tableName.toCharArray(); 37 char c; 38 boolean nextup = false; 39 for (int i = 0; i < chars.length; i++) { 40 if (i==0) c = Character.toUpperCase(chars[i]); 41 else if (chars[i]=='_') { 42 nextup = true; 43 continue; 44 } 45 else if (nextup) { 46 nextup = false; 47 c = Character.toUpperCase(chars[i]); 48 } 49 else c = Character.toLowerCase(chars[i]); 50 sb.append(c); 51 } 52 return sb.toString(); 53 } 54 55 58 public static String nameField(String columnName) 59 { 60 StringBuffer sb = new StringBuffer (); 61 char[] chars = new char[columnName.length()]; 62 chars = columnName.toCharArray(); 63 char c; 64 boolean nextup = false; 65 for (int i = 0; i < chars.length; i++) { 66 if (chars[i]=='_') { 67 nextup = true; 68 continue; 69 } 70 else if (nextup) { 71 nextup = false; 72 c = Character.toUpperCase(chars[i]); 73 } 74 else c = Character.toLowerCase(chars[i]); 75 sb.append(c); 76 } 77 return sb.toString(); 78 } 79 } 80 | Popular Tags |