1
14
15 package com.liferay.portal.tools.servicebuilder;
16
17 import com.liferay.portal.kernel.util.Validator;
18 import com.liferay.util.TextFormatter;
19
20
26 public class EntityColumn implements Cloneable {
27
28 public EntityColumn(String name) {
29 this(
30 name, null, null, false, null, null, null, true, true, null, null,
31 null, true, false);
32 }
33
34 public EntityColumn(
35 String name, String dbName, String type, boolean primary,
36 String ejbName, String mappingKey, String mappingTable,
37 boolean caseSensitive, boolean orderByAscending, String comparator,
38 String idType, String idParam, boolean convertNull, boolean localized) {
39
40 _name = name;
41 _dbName = dbName;
42 _type = type;
43 _primary = primary;
44 _methodName = TextFormatter.format(name, TextFormatter.G);
45 _ejbName = ejbName;
46 _mappingKey = mappingKey;
47 _mappingTable = mappingTable;
48 _caseSensitive = caseSensitive;
49 _orderByAscending = orderByAscending;
50 _comparator = comparator;
51 _idType = idType;
52 _idParam = idParam;
53 _convertNull = convertNull;
54 _localized = localized;
55 }
56
57 public EntityColumn(
58 String name, String dbName, String type, boolean primary,
59 String ejbName, String mappingKey, String mappingTable, String idType,
60 String idParam, boolean convertNull, boolean localized) {
61
62 this(
63 name, dbName, type, primary, ejbName, mappingKey, mappingTable,
64 true, true, null, idType, idParam, convertNull, localized);
65 }
66
67 public Object clone() {
68 return new EntityColumn(
69 getName(), getDBName(), getType(), isPrimary(), getEJBName(),
70 getMappingKey(), getMappingTable(), isCaseSensitive(),
71 isOrderByAscending(), getComparator(), getIdType(), getIdParam(),
72 isConvertNull(), isLocalized());
73 }
74
75 public boolean equals(Object obj) {
76 EntityColumn col = (EntityColumn)obj;
77
78 String name = col.getName();
79
80 if (_name.equals(name)) {
81 return true;
82 }
83 else {
84 return false;
85 }
86 }
87
88 public String getComparator() {
89 return _comparator;
90 }
91
92 public String getDBName() {
93 return _dbName;
94 }
95
96 public String getEJBName() {
97 return _ejbName;
98 }
99
100 public String getIdParam() {
101 return _idParam;
102 }
103
104 public String getIdType() {
105 return _idType;
106 }
107
108 public String getMappingKey() {
109 return _mappingKey;
110 }
111
112 public String getMappingTable() {
113 return _mappingTable;
114 }
115
116 public String getMethodName() {
117 return _methodName;
118 }
119
120 public String getMethodNames() {
121 return TextFormatter.formatPlural(new String(_methodName));
122 }
123
124 public String getMethodUserUuidName() {
125 return _methodName.substring(0, _methodName.length() - 2) + "Uuid";
126 }
127
128 public String getName() {
129 return _name;
130 }
131
132 public String getNames() {
133 return TextFormatter.formatPlural(new String(_name));
134 }
135
136 public String getType() {
137 return _type;
138 }
139
140 public String getUserUuidName() {
141 return _name.substring(0, _name.length() - 2) + "Uuid";
142 }
143
144 public int hashCode() {
145 return _name.hashCode();
146 }
147
148 public boolean isCaseSensitive() {
149 return _caseSensitive;
150 }
151
152 public boolean isCollection() {
153 if (_type.equals("Collection")) {
154 return true;
155 }
156 else {
157 return false;
158 }
159 }
160
161 public boolean isConvertNull() {
162 return _convertNull;
163 }
164
165 public boolean isFetchFinderPath() {
166 return _fetchFinderPath;
167 }
168
169 public boolean isLocalized() {
170 return _localized;
171 }
172
173 public boolean isMappingManyToMany() {
174 return Validator.isNotNull(_mappingTable);
175 }
176
177 public boolean isMappingOneToMany() {
178 return Validator.isNotNull(_mappingKey);
179 }
180
181 public boolean isOrderByAscending() {
182 return _orderByAscending;
183 }
184
185 public boolean isPrimary() {
186 return _primary;
187 }
188
189 public boolean isPrimitiveType() {
190 if (Character.isLowerCase(_type.charAt(0))) {
191 return true;
192 }
193 else if (_type.equals("Boolean")) {
194 return true;
195 }
196 else if (_type.equals("Double")) {
197 return true;
198 }
199 else if (_type.equals("Float")) {
200 return true;
201 }
202 else if (_type.equals("Integer")) {
203 return true;
204 }
205 else if (_type.equals("Long")) {
206 return true;
207 }
208 else if (_type.equals("Short")) {
209 return true;
210 }
211 else {
212 return false;
213 }
214 }
215
216 public boolean isUserUuid() {
217 if (_type.equals("long") && _methodName.endsWith("UserId")) {
218 return true;
219 }
220 else {
221 return false;
222 }
223 }
224
225 public void setCaseSensitive(boolean caseSensitive) {
226 _caseSensitive = caseSensitive;
227 }
228
229 public void setComparator(String comparator) {
230 _comparator = comparator;
231 }
232
233 public void setConvertNull(boolean convertNull) {
234 _convertNull = convertNull;
235 }
236
237 public void setDBName(String dbName) {
238 _dbName = dbName;
239 }
240
241 public void setFetchFinderPath(boolean fetchFinderPath) {
242 _fetchFinderPath = fetchFinderPath;
243 }
244
245 public void setIdParam(String idParam) {
246 _idParam = idParam;
247 }
248
249 public void setIdType(String idType) {
250 _idType = idType;
251 }
252
253 public void setLocalized(boolean localized) {
254 _localized = localized;
255 }
256
257 public void setOrderByAscending(boolean orderByAscending) {
258 _orderByAscending = orderByAscending;
259 }
260
261 private boolean _caseSensitive;
262 private String _comparator;
263 private boolean _convertNull;
264 private String _dbName;
265 private String _ejbName;
266 private boolean _fetchFinderPath;
267 private String _idParam;
268 private String _idType;
269 private boolean _localized;
270 private String _mappingKey;
271 private String _mappingTable;
272 private String _methodName;
273 private String _name;
274 private boolean _orderByAscending;
275 private boolean _primary;
276 private String _type;
277
278 }