001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portal.tools.servicebuilder;
022:
023: import com.liferay.portal.kernel.util.Validator;
024: import com.liferay.util.TextFormatter;
025:
026: /**
027: * <a href="EntityColumn.java.html"><b><i>View Source</i></b></a>
028: *
029: * @author Brian Wing Shun Chan
030: * @author Charles May
031: *
032: */
033: public class EntityColumn implements Cloneable {
034:
035: public EntityColumn(String name) {
036: this (name, null, null, false, null, null, null, true, true,
037: null, null, null, true);
038: }
039:
040: public EntityColumn(String name, String dbName, String type,
041: boolean primary, String ejbName, String mappingKey,
042: String mappingTable, String idType, String idParam,
043: boolean convertNull) {
044:
045: this (name, dbName, type, primary, ejbName, mappingKey,
046: mappingTable, true, true, null, idType, idParam,
047: convertNull);
048: }
049:
050: public EntityColumn(String name, String dbName, String type,
051: boolean primary, String ejbName, String mappingKey,
052: String mappingTable, boolean caseSensitive,
053: boolean orderByAscending, String comparator, String idType,
054: String idParam, boolean convertNull) {
055:
056: _name = name;
057: _dbName = dbName;
058: _type = type;
059: _primary = primary;
060: _methodName = TextFormatter.format(name, TextFormatter.G);
061: _ejbName = ejbName;
062: _mappingKey = mappingKey;
063: _mappingTable = mappingTable;
064: _caseSensitive = caseSensitive;
065: _orderByAscending = orderByAscending;
066: _comparator = comparator;
067: _idType = idType;
068: _idParam = idParam;
069: _convertNull = convertNull;
070: }
071:
072: public String getName() {
073: return _name;
074: }
075:
076: public String getDBName() {
077: return _dbName;
078: }
079:
080: public void setDBName(String dbName) {
081: _dbName = dbName;
082: }
083:
084: public String getType() {
085: return _type;
086: }
087:
088: public boolean isPrimitiveType() {
089: if (Character.isLowerCase(_type.charAt(0))) {
090: return true;
091: } else {
092: return false;
093: }
094: }
095:
096: public boolean isCollection() {
097: if (_type.equals("Collection")) {
098: return true;
099: } else {
100: return false;
101: }
102: }
103:
104: public boolean isPrimary() {
105: return _primary;
106: }
107:
108: public String getMethodName() {
109: return _methodName;
110: }
111:
112: public String getEJBName() {
113: return _ejbName;
114: }
115:
116: public String getMappingKey() {
117: return _mappingKey;
118: }
119:
120: public String getMappingTable() {
121: return _mappingTable;
122: }
123:
124: public boolean isMappingOneToMany() {
125: return Validator.isNotNull(_mappingKey);
126: }
127:
128: public boolean isMappingManyToMany() {
129: return Validator.isNotNull(_mappingTable);
130: }
131:
132: public boolean isCaseSensitive() {
133: return _caseSensitive;
134: }
135:
136: public void setCaseSensitive(boolean caseSensitive) {
137: _caseSensitive = caseSensitive;
138: }
139:
140: public boolean isOrderByAscending() {
141: return _orderByAscending;
142: }
143:
144: public void setOrderByAscending(boolean orderByAscending) {
145: _orderByAscending = orderByAscending;
146: }
147:
148: public String getComparator() {
149: return _comparator;
150: }
151:
152: public void setComparator(String comparator) {
153: _comparator = comparator;
154: }
155:
156: public String getIdType() {
157: return _idType;
158: }
159:
160: public void setIdType(String idType) {
161: _idType = idType;
162: }
163:
164: public String getIdParam() {
165: return _idParam;
166: }
167:
168: public void setIdParam(String idParam) {
169: _idParam = idParam;
170: }
171:
172: public boolean isConvertNull() {
173: return _convertNull;
174: }
175:
176: public void setConvertNull(boolean convertNull) {
177: _convertNull = convertNull;
178: }
179:
180: public Object clone() {
181: return new EntityColumn(getName(), getDBName(), getType(),
182: isPrimary(), getEJBName(), getMappingKey(),
183: getMappingTable(), isCaseSensitive(),
184: isOrderByAscending(), getComparator(), getIdType(),
185: getIdParam(), isConvertNull());
186: }
187:
188: public boolean equals(Object obj) {
189: EntityColumn col = (EntityColumn) obj;
190:
191: String name = col.getName();
192:
193: if (_name.equals(name)) {
194: return true;
195: } else {
196: return false;
197: }
198: }
199:
200: private String _name;
201: private String _dbName;
202: private String _type;
203: private boolean _primary;
204: private String _methodName;
205: private String _ejbName;
206: private String _mappingKey;
207: private String _mappingTable;
208: private boolean _caseSensitive;
209: private boolean _orderByAscending;
210: private String _comparator;
211: private String _idType;
212: private String _idParam;
213: private boolean _convertNull;
214:
215: }
|