1 |
|
package org.apache.torque.engine.database.model; |
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
import java.util.List; |
23 |
|
import java.util.StringTokenizer; |
24 |
|
|
25 |
|
import org.apache.commons.lang.StringUtils; |
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
@author |
31 |
|
@author |
32 |
|
@version |
33 |
|
|
|
|
| 0% |
Uncovered Elements: 72 (72) |
Complexity: 15 |
Complexity Density: 0.32 |
|
34 |
|
public class JavaNameGenerator implements NameGenerator |
35 |
|
{ |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
@param |
49 |
|
|
50 |
|
@return |
51 |
|
@see |
52 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 5 |
Complexity Density: 0.38 |
|
53 |
0
|
public String generateName(List inputs)... |
54 |
|
{ |
55 |
0
|
String schemaName = (String) inputs.get(0); |
56 |
0
|
String method = (String) inputs.get(1); |
57 |
0
|
String javaName = null; |
58 |
|
|
59 |
0
|
if (CONV_METHOD_UNDERSCORE.equals(method)) |
60 |
|
{ |
61 |
0
|
javaName = underscoreMethod(schemaName); |
62 |
|
} |
63 |
0
|
else if (CONV_METHOD_UNDERSCORE_OMIT_SCHEMA.equals(method)) |
64 |
|
{ |
65 |
0
|
javaName = underscoreOmitSchemaMethod(schemaName); |
66 |
|
} |
67 |
0
|
else if (CONV_METHOD_JAVANAME.equals(method)) |
68 |
|
{ |
69 |
0
|
javaName = javanameMethod(schemaName); |
70 |
|
} |
71 |
0
|
else if (CONV_METHOD_NOCHANGE.equals(method)) |
72 |
|
{ |
73 |
0
|
javaName = nochangeMethod(schemaName); |
74 |
|
} |
75 |
|
else |
76 |
|
{ |
77 |
|
|
78 |
|
|
79 |
0
|
javaName = underscoreMethod(schemaName); |
80 |
|
} |
81 |
|
|
82 |
0
|
return javaName; |
83 |
|
} |
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
@param |
93 |
|
@return |
94 |
|
@see |
95 |
|
@see |
96 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 3 |
Complexity Density: 0.25 |
|
97 |
0
|
protected String underscoreMethod(String schemaName)... |
98 |
|
{ |
99 |
0
|
StringBuffer name = new StringBuffer(); |
100 |
|
|
101 |
|
|
102 |
|
|
103 |
0
|
StringTokenizer tok = new StringTokenizer |
104 |
|
(schemaName, String.valueOf(STD_SEPARATOR_CHAR)); |
105 |
0
|
while (tok.hasMoreTokens()) |
106 |
|
{ |
107 |
0
|
String namePart = ((String) tok.nextElement()).toLowerCase(); |
108 |
0
|
name.append(StringUtils.capitalize(namePart)); |
109 |
|
} |
110 |
|
|
111 |
|
|
112 |
|
|
113 |
0
|
schemaName = name.toString(); |
114 |
0
|
name = new StringBuffer(); |
115 |
0
|
tok = new StringTokenizer |
116 |
|
(schemaName, String.valueOf(SCHEMA_SEPARATOR_CHAR)); |
117 |
0
|
while (tok.hasMoreTokens()) |
118 |
|
{ |
119 |
0
|
String namePart = (String) tok.nextElement(); |
120 |
0
|
name.append(StringUtils.capitalize(namePart)); |
121 |
|
} |
122 |
0
|
return name.toString(); |
123 |
|
} |
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
@param |
134 |
|
@return |
135 |
|
@see |
136 |
|
@see |
137 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
138 |
0
|
protected String underscoreOmitSchemaMethod(String schemaName)... |
139 |
|
{ |
140 |
|
|
141 |
0
|
int lastDotPos = schemaName.lastIndexOf(SCHEMA_SEPARATOR_CHAR); |
142 |
0
|
if (lastDotPos != -1) |
143 |
|
{ |
144 |
0
|
schemaName = schemaName.substring(lastDotPos + 1); |
145 |
|
} |
146 |
0
|
StringBuffer name = new StringBuffer(); |
147 |
0
|
StringTokenizer tok = new StringTokenizer |
148 |
|
(schemaName, String.valueOf(STD_SEPARATOR_CHAR)); |
149 |
0
|
while (tok.hasMoreTokens()) |
150 |
|
{ |
151 |
0
|
String namePart = ((String) tok.nextElement()).toLowerCase(); |
152 |
0
|
name.append(StringUtils.capitalize(namePart)); |
153 |
|
} |
154 |
0
|
return name.toString(); |
155 |
|
} |
156 |
|
|
157 |
|
|
158 |
|
|
159 |
|
|
160 |
|
|
161 |
|
|
162 |
|
@param |
163 |
|
@return |
164 |
|
@see |
165 |
|
@see |
166 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 3 |
Complexity Density: 0.25 |
|
167 |
0
|
protected String javanameMethod(String schemaName)... |
168 |
|
{ |
169 |
0
|
StringBuffer name = new StringBuffer(); |
170 |
0
|
StringTokenizer tok = new StringTokenizer |
171 |
|
(schemaName, String.valueOf(STD_SEPARATOR_CHAR)); |
172 |
0
|
while (tok.hasMoreTokens()) |
173 |
|
{ |
174 |
0
|
String namePart = (String) tok.nextElement(); |
175 |
0
|
name.append(StringUtils.capitalize(namePart)); |
176 |
|
} |
177 |
|
|
178 |
|
|
179 |
|
|
180 |
0
|
schemaName = name.toString(); |
181 |
0
|
name = new StringBuffer(); |
182 |
|
|
183 |
0
|
tok = new StringTokenizer |
184 |
|
(schemaName, String.valueOf(SCHEMA_SEPARATOR_CHAR)); |
185 |
0
|
while (tok.hasMoreTokens()) |
186 |
|
{ |
187 |
0
|
String namePart = (String) tok.nextElement(); |
188 |
0
|
name.append(StringUtils.capitalize(namePart)); |
189 |
|
} |
190 |
0
|
return name.toString(); |
191 |
|
} |
192 |
|
|
193 |
|
|
194 |
|
|
195 |
|
|
196 |
|
|
197 |
|
@param |
198 |
|
@return |
199 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
200 |
0
|
protected final String nochangeMethod(String name)... |
201 |
|
{ |
202 |
0
|
return name; |
203 |
|
} |
204 |
|
} |