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