1 package org.andromda.schema2xmi;
2
3 import org.apache.commons.lang.StringUtils;
4
5
6
7
8
9
10 public class SqlToModelNameFormatter
11 {
12
13
14
15
16
17
18 public static String toClassName(String name)
19 {
20 return toCamelCase(name);
21 }
22
23
24
25
26
27
28
29 public static String toAttributeName(String name)
30 {
31 return StringUtils.uncapitalize(toClassName(name));
32 }
33
34
35
36
37
38
39
40 public static String toCamelCase(String name)
41 {
42 StringBuilder buffer = new StringBuilder();
43 String[] tokens = name.split("_|\\s+");
44 if (tokens != null && tokens.length > 0)
45 {
46 for (int ctr = 0; ctr < tokens.length; ctr++)
47 {
48 buffer.append(StringUtils.capitalize(tokens[ctr].toLowerCase()));
49 }
50 }
51 else
52 {
53 buffer.append(StringUtils.capitalize(name.toLowerCase()));
54 }
55 return buffer.toString();
56 }
57 }