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