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