01: package com.avaje.util.codegen;
02:
03: import java.util.HashMap;
04: import java.util.Map;
05:
06: /**
07: * Java Reserved words that should not be used as property names.
08: * <p>
09: * You can specify a mapping in the system properties file. These mappings are
10: * used to convert the property names and should automatically create a COLUMN
11: * annotation for you.
12: * </p>
13: * <p>
14: * Example system properties entry:
15: * </p>
16: * <pre><code>
17: * ebean.codegen.reservedwords=abstract=summary,int=integer
18: * </code></pre>
19: *
20: */
21: public class ReservedWords {
22:
23: HashMap map = new HashMap();
24:
25: public ReservedWords() {
26: init();
27: }
28:
29: /**
30: * Override the current reserved word mappings.
31: */
32: public void merge(Map wordMapping) {
33: this .map.putAll(wordMapping);
34: }
35:
36: /**
37: * Some inital translations from reserved words.
38: */
39: private void init() {
40:
41: // are these reasonable conversions?
42: map.put("class", "class");
43: map.put("abstract", "abstract");// "summary");
44:
45: // let these error by default
46: map.put("byte", "byte");
47: map.put("char", "char");
48: map.put("short", "short");
49: map.put("float", "float");
50: map.put("int", "int");
51: map.put("double", "double");
52: map.put("boolean", "boolean");
53: map.put("void", "void");
54:
55: map.put("native", "native");
56: map.put("synchronized", "synchronized");
57: map.put("volatile", "volatile");
58: map.put("return", "return");
59: map.put("enum", "enum");
60:
61: map.put("private", "private");
62: map.put("public", "public");
63: map.put("import", "import");
64:
65: map.put("package", "package");
66: map.put("super", "super");
67: map.put("this", "this");
68:
69: }
70:
71: public boolean isReservedWord(String word) {
72: return map.containsKey(word);
73: }
74:
75: public String getTranslation(String word) {
76: return (String) map.get(word);
77: }
78:
79: public void setTransaction(String word, String translation) {
80: map.put(word, translation);
81: }
82: }
|