1
22
23 package com.liferay.portal.tools.servicebuilder;
24
25 import com.liferay.portal.kernel.util.Validator;
26 import com.liferay.util.TextFormatter;
27
28
35 public class EntityColumn implements Cloneable {
36
37 public EntityColumn(String name) {
38 this(
39 name, null, null, false, null, null, null, true, true, null, null,
40 null, true);
41 }
42
43 public EntityColumn(
44 String name, String dbName, String type, boolean primary,
45 String ejbName, String mappingKey, String mappingTable,
46 boolean caseSensitive, boolean orderByAscending, String comparator,
47 String idType, String idParam, boolean convertNull) {
48
49 _name = name;
50 _dbName = dbName;
51 _type = type;
52 _primary = primary;
53 _methodName = TextFormatter.format(name, TextFormatter.G);
54 _ejbName = ejbName;
55 _mappingKey = mappingKey;
56 _mappingTable = mappingTable;
57 _caseSensitive = caseSensitive;
58 _orderByAscending = orderByAscending;
59 _comparator = comparator;
60 _idType = idType;
61 _idParam = idParam;
62 _convertNull = convertNull;
63 }
64
65 public EntityColumn(
66 String name, String dbName, String type, boolean primary,
67 String ejbName, String mappingKey, String mappingTable, String idType,
68 String idParam, boolean convertNull) {
69
70 this(
71 name, dbName, type, primary, ejbName, mappingKey, mappingTable,
72 true, true, null, idType, idParam, convertNull);
73 }
74
75 public Object clone() {
76 return new EntityColumn(
77 getName(), getDBName(), getType(), isPrimary(), getEJBName(),
78 getMappingKey(), getMappingTable(), isCaseSensitive(),
79 isOrderByAscending(), getComparator(), getIdType(), getIdParam(),
80 isConvertNull());
81 }
82
83 public boolean equals(Object obj) {
84 EntityColumn col = (EntityColumn)obj;
85
86 String name = col.getName();
87
88 if (_name.equals(name)) {
89 return true;
90 }
91 else {
92 return false;
93 }
94 }
95
96 public String getComparator() {
97 return _comparator;
98 }
99
100 public String getDBName() {
101 return _dbName;
102 }
103
104 public String getEJBName() {
105 return _ejbName;
106 }
107
108 public String getIdParam() {
109 return _idParam;
110 }
111
112 public String getIdType() {
113 return _idType;
114 }
115
116 public String getMappingKey() {
117 return _mappingKey;
118 }
119
120 public String getMappingTable() {
121 return _mappingTable;
122 }
123
124 public String getMethodName() {
125 return _methodName;
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 boolean isCaseSensitive() {
141 return _caseSensitive;
142 }
143
144 public boolean isCollection() {
145 if (_type.equals("Collection")) {
146 return true;
147 }
148 else {
149 return false;
150 }
151 }
152
153 public boolean isConvertNull() {
154 return _convertNull;
155 }
156
157 public boolean isFetchFinderPath() {
158 return _fetchFinderPath;
159 }
160
161 public boolean isMappingManyToMany() {
162 return Validator.isNotNull(_mappingTable);
163 }
164
165 public boolean isMappingOneToMany() {
166 return Validator.isNotNull(_mappingKey);
167 }
168
169 public boolean isOrderByAscending() {
170 return _orderByAscending;
171 }
172
173 public boolean isPrimary() {
174 return _primary;
175 }
176
177 public boolean isPrimitiveType() {
178 if (Character.isLowerCase(_type.charAt(0))) {
179 return true;
180 }
181 else {
182 return false;
183 }
184 }
185
186 public void setCaseSensitive(boolean caseSensitive) {
187 _caseSensitive = caseSensitive;
188 }
189
190 public void setComparator(String comparator) {
191 _comparator = comparator;
192 }
193
194 public void setConvertNull(boolean convertNull) {
195 _convertNull = convertNull;
196 }
197
198 public void setDBName(String dbName) {
199 _dbName = dbName;
200 }
201
202 public void setFetchFinderPath(boolean fetchFinderPath) {
203 _fetchFinderPath = fetchFinderPath;
204 }
205
206 public void setIdParam(String idParam) {
207 _idParam = idParam;
208 }
209
210 public void setIdType(String idType) {
211 _idType = idType;
212 }
213
214 public void setOrderByAscending(boolean orderByAscending) {
215 _orderByAscending = orderByAscending;
216 }
217
218 private boolean _caseSensitive;
219 private String _comparator;
220 private boolean _convertNull;
221 private String _dbName;
222 private String _ejbName;
223 private boolean _fetchFinderPath;
224 private String _idParam;
225 private String _idType;
226 private String _mappingKey;
227 private String _mappingTable;
228 private String _methodName;
229 private String _name;
230 private boolean _orderByAscending;
231 private boolean _primary;
232 private String _type;
233
234 }