Source Code Cross Referenced for FieldBean.java in  » J2EE » Jaffa » org » jaffa » tools » domainmeta » common » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » Jaffa » org.jaffa.tools.domainmeta.common 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ====================================================================
003:         * JAFFA - Java Application Framework For All
004:         *
005:         * Copyright (C) 2002 JAFFA Development Group
006:         *
007:         *     This library is free software; you can redistribute it and/or
008:         *     modify it under the terms of the GNU Lesser General Public
009:         *     License as published by the Free Software Foundation; either
010:         *     version 2.1 of the License, or (at your option) any later version.
011:         *
012:         *     This library is distributed in the hope that it will be useful,
013:         *     but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         *     Lesser General Public License for more details.
016:         *
017:         *     You should have received a copy of the GNU Lesser General Public
018:         *     License along with this library; if not, write to the Free Software
019:         *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
020:         *
021:         * Redistribution and use of this software and associated documentation ("Software"),
022:         * with or without modification, are permitted provided that the following conditions are met:
023:         * 1.	Redistributions of source code must retain copyright statements and notices.
024:         *         Redistributions must also contain a copy of this document.
025:         * 2.	Redistributions in binary form must reproduce the above copyright notice,
026:         * 	this list of conditions and the following disclaimer in the documentation
027:         * 	and/or other materials provided with the distribution.
028:         * 3.	The name "JAFFA" must not be used to endorse or promote products derived from
029:         * 	this Software without prior written permission. For written permission,
030:         * 	please contact mail to: jaffagroup@yahoo.com.
031:         * 4.	Products derived from this Software may not be called "JAFFA" nor may "JAFFA"
032:         * 	appear in their names without prior written permission.
033:         * 5.	Due credit should be given to the JAFFA Project (http://jaffa.sourceforge.net).
034:         *
035:         * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
036:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
037:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
038:         * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
039:         * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
040:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
041:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
042:         * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
043:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
044:         * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
045:         * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
046:         * SUCH DAMAGE.
047:         * ====================================================================
048:         */
049:        /*
050:         * FieldBean.java
051:         *
052:         * Created on March 19, 2003, 7:43 PM
053:         */
054:
055:        package org.jaffa.tools.domainmeta.common;
056:
057:        import java.beans.*;
058:        import java.io.PrintWriter;
059:        import java.util.HashMap;
060:        import org.apache.log4j.Logger;
061:        import org.jaffa.datatypes.Defaults;
062:        import org.jaffa.util.StringHelper;
063:
064:        /** Java Bean to store information about a domain object field
065:         * @version 1.0
066:         * @author PaulE
067:         */
068:        public class FieldBean extends Object implements  java.io.Serializable {
069:
070:            private static Logger log = Logger.getLogger(FieldBean.class);
071:
072:            private static HashMap reservedNames = new HashMap();
073:            static {
074:                reservedNames.put("interface", "interfaceName");
075:                reservedNames.put("class", "className");
076:            }
077:
078:            private PropertyChangeSupport propertySupport;
079:
080:            /** Holds value of property propertyName. */
081:            private String propertyName;
082:
083:            /** Holds value of property fieldName. */
084:            private String fieldName;
085:
086:            /** Holds value of property javaDataType. */
087:            private String javaDataType;
088:
089:            /** Holds value of property sqlDataType. */
090:            private String sqlDataType;
091:
092:            /** Holds value of property fracSize. */
093:            private String fracSize;
094:
095:            /** Holds value of property intSize. */
096:            private String intSize;
097:
098:            /** Holds value of property mandatory. */
099:            private boolean mandatory;
100:
101:            /** Holds value of property primaryKey. */
102:            private boolean primaryKey;
103:
104:            /** Holds value of property label. */
105:            private String label;
106:
107:            /** Holds value of property labelText. */
108:            private String labelText;
109:
110:            /** Holds value of property description. */
111:            private String description;
112:
113:            /** Creates new FieldBean */
114:            public FieldBean() {
115:                propertySupport = new PropertyChangeSupport(this );
116:            }
117:
118:            /** Write out the contents of the bean as XML
119:             * @param out Writer to output to
120:             */
121:            public void write(PrintWriter out) {
122:                out.println("    <Field>");
123:                out
124:                        .println("      <Name>"
125:                                + StringHelper.getUpper1(this .propertyName)
126:                                + "</Name>");
127:                out.println("      <DataType>" + this .javaDataType
128:                        + "</DataType>");
129:                out.println("      <DatabaseFieldName>"
130:                        + StringHelper.getUpper(this .fieldName)
131:                        + "</DatabaseFieldName>");
132:                out.println("      <DatabaseDataType>" + this .sqlDataType
133:                        + "</DatabaseDataType>");
134:                out.println("      <PrimaryKey>"
135:                        + (this .primaryKey ? "T" : "F") + "</PrimaryKey>");
136:                if (this .description != null)
137:                    out.println("      <Description>" + this .description
138:                            + "</Description>");
139:                if (this .label != null)
140:                    out.println("      <LabelToken>" + this .label
141:                            + "</LabelToken>");
142:                out.println("      <Mandatory>" + (this .mandatory ? "T" : "F")
143:                        + "</Mandatory>");
144:                //out.println("      <Width></Width>"); -- Deprectaed move from v1.0 to v1.1
145:                if (this .intSize != null
146:                        && (!Defaults.DATEONLY.equals(this .sqlDataType))
147:                        && (!Defaults.DATETIME.equals(this .sqlDataType)))
148:                    out
149:                            .println("      <IntSize>" + this .intSize
150:                                    + "</IntSize>");
151:                if (this .fracSize != null)
152:                    out.println("      <FracSize>" + this .fracSize
153:                            + "</FracSize>");
154:                else if (Defaults.DECIMAL.equals(this .sqlDataType))
155:                    out.println("      <FracSize>0</FracSize>");
156:                else if (Defaults.CURRENCY.equals(this .sqlDataType))
157:                    out.println("      <FracSize>2</FracSize>");
158:                /*
159:                out.println("      <MinValue></MinValue>");
160:                out.println("      <MaxValue></MaxValue>");
161:                out.println("      <Layout></Layout>");
162:                out.println("      <Pattern></Pattern>");
163:                 */
164:                if (this .primaryKey)
165:                    out.println("      <CaseType>UpperCase</CaseType>");
166:                else
167:                    out.println("      <CaseType>MixedCase</CaseType>");
168:                out.println("      <Ignore>false</Ignore>");
169:                out.println("    </Field>");
170:            }
171:
172:            /** Return a string representation of the data for
173:             * debugging
174:             * @return returns key information for the bean
175:             */
176:            public String toString() {
177:                StringBuffer sb = new StringBuffer();
178:
179:                sb.append(this .propertyName);
180:                sb.append("(");
181:                sb.append(this .fieldName);
182:                sb.append("), DataType=");
183:                sb.append(this .sqlDataType);
184:                sb.append(",");
185:                sb.append(this .intSize);
186:                sb.append(",");
187:                sb.append(this .fracSize);
188:                sb.append("(");
189:                sb.append(this .javaDataType);
190:                sb.append(")");
191:
192:                return sb.toString();
193:            }
194:
195:            /** Getter for property propertyName.
196:             * @return Value of property propertyName.
197:             */
198:            public String getPropertyName() {
199:                return this .propertyName;
200:            }
201:
202:            /** Setter for property propertyName.
203:             * @param propertyName New value of property propertyName.
204:             */
205:            public void setPropertyName(String propertyName) {
206:                propertyName = TableBean.formatName(propertyName);
207:                if (reservedNames.containsKey(propertyName.toLowerCase())) {
208:                    this .propertyName = (String) reservedNames.get(propertyName
209:                            .toLowerCase());
210:                    log.debug("Replaced name " + propertyName + " with "
211:                            + this .propertyName);
212:                } else
213:                    this .propertyName = propertyName;
214:            }
215:
216:            /** Getter for property fieldName.
217:             * @return Value of property fieldName.
218:             */
219:            public String getFieldName() {
220:                return this .fieldName;
221:            }
222:
223:            /** Setter for property fieldName.
224:             * @param fieldName New value of property fieldName.
225:             */
226:            public void setFieldName(String fieldName) {
227:                this .fieldName = fieldName;
228:            }
229:
230:            /** Getter for property javaDataType.
231:             * @return Value of property javaDataType.
232:             */
233:            public String getJavaDataType() {
234:                return this .javaDataType;
235:            }
236:
237:            /** Setter for property javaDataType.
238:             * @param javaDataType New value of property javaDataType.
239:             */
240:            public void setJavaDataType(String javaDataType) {
241:                this .javaDataType = javaDataType;
242:            }
243:
244:            /** Getter for property sqlDataType.
245:             * @return Value of property sqlDataType.
246:             */
247:            public String getSqlDataType() {
248:                return this .sqlDataType;
249:            }
250:
251:            /** Setter for property sqlDataType.
252:             * @param sqlDataType New value of property sqlDataType.
253:             */
254:            public void setSqlDataType(String sqlDataType) {
255:                this .sqlDataType = sqlDataType;
256:            }
257:
258:            /** Getter for property fracSize.
259:             * @return Value of property fracSize.
260:             */
261:            public String getFracSize() {
262:                return this .fracSize;
263:            }
264:
265:            /** Setter for property fracSize.
266:             * @param fracSize New value of property fracSize.
267:             */
268:            public void setFracSize(String fracSize) {
269:                this .fracSize = fracSize;
270:            }
271:
272:            /** Getter for property intSize.
273:             * @return Value of property intSize.
274:             */
275:            public String getIntSize() {
276:                return this .intSize;
277:            }
278:
279:            /** Setter for property intSize.
280:             * @param intSize New value of property intSize.
281:             */
282:            public void setIntSize(String intSize) {
283:                this .intSize = intSize;
284:            }
285:
286:            /** Getter for property mandatory.
287:             * @return Value of property mandatory.
288:             */
289:            public boolean isMandatory() {
290:                return this .mandatory;
291:            }
292:
293:            /** Setter for property mandatory.
294:             * @param mandatory New value of property mandatory.
295:             */
296:            public void setMandatory(boolean mandatory) {
297:                this .mandatory = mandatory;
298:            }
299:
300:            /** Getter for property primaryKey.
301:             * @return Value of property primaryKey.
302:             */
303:            public boolean isPrimaryKey() {
304:                return this .primaryKey;
305:            }
306:
307:            /** Setter for property primaryKey.
308:             * @param primaryKey New value of property primaryKey.
309:             */
310:            public void setPrimaryKey(boolean primaryKey) {
311:                this .primaryKey = primaryKey;
312:                if (primaryKey)
313:                    setMandatory(true);
314:            }
315:
316:            /** Getter for property label.
317:             * @return Value of property label.
318:             */
319:            public String getLabel() {
320:                return this .label;
321:            }
322:
323:            /** Setter for property label.
324:             * @param label New value of property label.
325:             */
326:            public void setLabel(String label) {
327:                this .label = label;
328:            }
329:
330:            /** Getter for property labelText.
331:             * @return Value of property labelText.
332:             */
333:            public String getLabelText() {
334:                return this .labelText;
335:            }
336:
337:            /** Setter for property labelText.
338:             * @param labelText New value of property labelText.
339:             */
340:            public void setLabelText(String labelText) {
341:                this .labelText = labelText;
342:            }
343:
344:            /** Getter for property description.
345:             * @return Value of property description.
346:             */
347:            public String getDescription() {
348:                return this .description;
349:            }
350:
351:            /** Setter for property description.
352:             * @param description New value of property description.
353:             */
354:            public void setDescription(String description) {
355:                this.description = description;
356:            }
357:
358:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.