1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.tuigwaa.util;
17
18 import org.seasar.tuigwaa.model.core.TgwEntity;
19
20 import com.isenshi.util.CharUtil;
21
22 public class TgwNameUtils {
23
24 public static final String ACTION_PREFIX_NORMAL = "/_save";
25
26 public static final String PROP_PREFIX_DATEYEAR= "tgw_dateyear_";
27 public static final String PROP_PREFIX_DATEMONTH= "tgw_datemonth_";
28 public static final String PROP_PREFIX_DATEDATE= "tgw_datedate_";
29
30 public static final String SUFFIX_ENHANCED_CLASS = "$$EnhancedByTUIGWAA$$";
31
32 private static final String PACKAGE_NAME = "com.isenshi.tuigwaa.db.dynamic";
33
34
35
36 public static String toCustomFormName(TgwEntity entity) {
37 return "_" + entity.getName() + "FormCustom";
38 }
39
40 public static String toCustomTableFormName(String customFormName) {
41 return "_" + customFormName + "FormCtable";
42 }
43
44 public static String toFormName(TgwEntity entity) {
45 return toFormName(entity.getName());
46 }
47
48 public static String toFormName(String entityName) {
49 return "_" + entityName + "Form";
50 }
51
52 public static String toSearchFormName(TgwEntity entity) {
53 return "_" + entity.getName() + "FormSearch";
54 }
55
56 public static String toActionName(TgwEntity entity) {
57 return toActionName(entity.getName());
58 }
59
60 public static String toActionName(String entityName) {
61 return ACTION_PREFIX_NORMAL + entityName;
62 }
63
64 public static String toCustomSaveActionName(TgwEntity entity) {
65 return "/_csave" + entity.getName();
66 }
67
68 public static String toCustomTableSaveActionName(String customActionName) {
69 return "/_ctablesave" + customActionName.substring("/_csave".length());
70 }
71
72 public static String toSearchActionName(TgwEntity entity) {
73 return "/_search" + entity.getName();
74 }
75
76 public static String toDynaPropertyName(String name) {
77 return "__" + name + "__";
78 }
79
80 public static String removeEscapeCharacters(String name) {
81 return name.substring(2, name.length() - 2);
82 }
83
84 public static String toPropertyName(String name) {
85 name = CharUtil.charpop(name, '_');
86 name = CharUtil.charpop(name, '_');
87 name = CharUtil.chartrim(name, '_');
88 name = CharUtil.chartrim(name, '_');
89 return name;
90 }
91
92 public static String toConverterFieldName(String name) {
93 return "_" + name;
94 }
95
96 public static String getOritinalConverterFieldName(String name){
97 return CharUtil.charpop(name, '_');
98 }
99
100 public static String toDynaConverterName(String name) {
101 return toDynaPropertyName(toConverterFieldName(name));
102 }
103
104 public static String toPureClassName(TgwEntity entity) {
105 String className = CharUtil.toUpperCaseAtFisrtChar(entity.getName());
106 return PACKAGE_NAME + "." + entity.getDomainName() + "." + className;
107 }
108
109 public static String toManyToManyName(String entityName) {
110 return "tgw_m2m_" + entityName;
111 }
112
113 public static String[] toDateParts(String attrName) {
114 return new String[] {
115 PROP_PREFIX_DATEYEAR + attrName,
116 PROP_PREFIX_DATEMONTH + attrName,
117 PROP_PREFIX_DATEDATE + attrName };
118 }
119
120 public static String getEnhancedClassName(Class srcClass, int hashValue){
121 String className = srcClass.getName();
122 StringBuffer buf = new StringBuffer();
123 buf.append(className);
124 buf.append(SUFFIX_ENHANCED_CLASS);
125 buf.append(Integer.toHexString(hashValue));
126 return buf.toString();
127 }
128
129
130 }