Source Code Cross Referenced for Attribute.java in  » Database-ORM » jaxor-3.5 » net » sourceforge » jaxor » parser » 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 » Database ORM » jaxor 3.5 » net.sourceforge.jaxor.parser 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sourceforge.jaxor.parser;
002:
003:        import net.sourceforge.jaxor.util.ObjectUtils;
004:        import net.sourceforge.jaxor.mappers.*;
005:
006:        import java.sql.Timestamp;
007:
008:        public class Attribute {
009:
010:            private String _name;
011:            private String _typeClass;
012:            private boolean _nullable;
013:            private boolean _readOnly;
014:            private boolean _primaryKey;
015:            private boolean _aggregate;
016:
017:            private boolean _matchOnUpdate;
018:            private String _mapper;
019:            private String _alias;
020:            private String _default;
021:            private boolean _autoAssign;
022:
023:            private String _fieldAdapter = FieldAdapterImpl.class.getName();
024:
025:            public Attribute() {
026:            }
027:
028:            public Attribute(String name, String type, boolean nullable) {
029:                _name = name;
030:                _typeClass = type;
031:                _nullable = nullable;
032:            }
033:
034:            public Attribute(String name, String type, boolean nullable,
035:                    boolean readOnly) {
036:                this (name, type, nullable);
037:                _readOnly = readOnly;
038:            }
039:
040:            public boolean isMatchOnUpdate() {
041:                if (_primaryKey)
042:                    return true;
043:                return _matchOnUpdate;
044:            }
045:
046:            public String getDefaultValue() {
047:                if (_default == null)
048:                    return "null";
049:
050:                if ("String".equals(_typeClass)) {
051:                    return "\"" + _default + "\"";
052:                } else
053:                    return _default;
054:            }
055:
056:            public void setDefault(String aDefault) {
057:                _default = aDefault;
058:            }
059:
060:            public void setMatchonupdate(boolean matchOnUpdate) {
061:                _matchOnUpdate = matchOnUpdate;
062:            }
063:
064:            public boolean isReadOnly() {
065:                return _readOnly;
066:            }
067:
068:            public void setName(String name) {
069:                _name = name;
070:            }
071:
072:            public String getName() {
073:                return _name;
074:            }
075:
076:            public String getJavaName() {
077:                if (_alias == null)
078:                    return JavaNameGenerator.toJavaName(getName());
079:                return _alias;
080:            }
081:
082:            public String getMetaName() {
083:                return getName().toUpperCase() + "_META";
084:            }
085:
086:            public String getFieldAdapter() {
087:                return _fieldAdapter;
088:            }
089:
090:            public void setType(String type) {
091:                if ("version".equalsIgnoreCase(type)) {
092:                    setNullable(false);
093:                    setMatchonupdate(true);
094:                    _fieldAdapter = LongVersionFieldAdapter.class.getName();
095:                    _typeClass = Long.class.getName();
096:                } else if ("user".equalsIgnoreCase(type)) {
097:                    setNullable(false);
098:                    _fieldAdapter = UserFieldAdapter.class.getName();
099:                    _typeClass = String.class.getName();
100:                } else if ("user-insert".equalsIgnoreCase(type)) {
101:                    setNullable(false);
102:                    _fieldAdapter = UserInsertFieldAdapter.class.getName();
103:                    _typeClass = String.class.getName();
104:                } else if ("user-update".equalsIgnoreCase(type)) {
105:                    setNullable(true);
106:                    _fieldAdapter = UserUpdateFieldAdapter.class.getName();
107:                    _typeClass = String.class.getName();
108:                } else if ("timestamp".equalsIgnoreCase(type)) {
109:                    setNullable(false);
110:                    _fieldAdapter = TimestampFieldAdapter.class.getName();
111:                    _typeClass = Timestamp.class.getName();
112:                } else if ("timestamp-update".equalsIgnoreCase(type)) {
113:                    setNullable(true);
114:                    _fieldAdapter = TimestampUpdateFieldAdapter.class.getName();
115:                    _typeClass = Timestamp.class.getName();
116:                } else if ("timestamp-insert".equalsIgnoreCase(type)) {
117:                    setNullable(false);
118:                    _fieldAdapter = TimestampInsertFieldAdapter.class.getName();
119:                    _typeClass = Timestamp.class.getName();
120:                } else
121:                    _typeClass = type;
122:            }
123:
124:            public String getType() {
125:                return _typeClass;
126:            }
127:
128:            public String getTypeName() {
129:                int index = getType().lastIndexOf(".");
130:                return getType().substring(index + 1);
131:            }
132:
133:            public String getMapperParameter(Jaxor jaxor) {
134:                if (isPrimitive())
135:                    return "";
136:                else
137:                    return "new " + getMapperName(jaxor) + "(),";
138:            }
139:
140:            public String getMapperName(Jaxor jaxor) {
141:                if (_mapper != null)
142:                    return _mapper;
143:                return jaxor.getMapperName(getType());
144:            }
145:
146:            public void setNullable(boolean b) {
147:                _nullable = b;
148:            }
149:
150:            public boolean isNullable() {
151:                if (isAutoAssign())
152:                    return true;
153:                return _nullable;
154:            }
155:
156:            public boolean isPrimaryKey() {
157:                return _primaryKey;
158:            }
159:
160:            public void setIsPrimaryKey(boolean primaryKey) {
161:                _primaryKey = primaryKey;
162:            }
163:
164:            public void setMapper(String mapper) {
165:                _mapper = mapper;
166:            }
167:
168:            public String getGetterSig() {
169:                return "public " + getType() + " " + getGetter();
170:            }
171:
172:            public String getGetter() {
173:                return "get" + getJavaName() + "()";
174:            }
175:
176:            public String getSetterSig(String mod) {
177:                return mod + " void " + getSetterBase() + "(" + getType()
178:                        + " arg)";
179:            }
180:
181:            public String getAccessor() {
182:                if (isPrimitive())
183:                    return getName() + ".get"
184:                            + JavaNameGenerator.toJavaName(getType()) + "()";
185:                else
186:                    return getName() + ".getValue()";
187:            }
188:
189:            public String getSetterBase() {
190:                return "set" + getJavaName();
191:            }
192:
193:            public void setAlias(String alias) {
194:                _alias = alias;
195:            }
196:
197:            public boolean isAggregate() {
198:                return _aggregate;
199:            }
200:
201:            public void setAggregate(boolean _aggregate) {
202:                this ._aggregate = _aggregate;
203:            }
204:
205:            public String getPropertyAsString() {
206:                return "\"" + getJavaName() + "\"";
207:            }
208:
209:            public String getBooleanConstructorList() {
210:                return isNullable() + "," + isPrimaryKey() + ","
211:                        + isMatchOnUpdate() + "," + isAutoAssign();
212:            }
213:
214:            public boolean isAutoAssign() {
215:                return _autoAssign;
216:            }
217:
218:            public void setAutoAssign(boolean autoAssign) {
219:                _autoAssign = autoAssign;
220:            }
221:
222:            public boolean isPrimitive() {
223:                return ObjectUtils.isPrimitive(getType());
224:            }
225:
226:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.