Source Code Cross Referenced for ColumnMapping.java in  » Database-ORM » TJDO » com » triactive » jdo » store » 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 » TJDO » com.triactive.jdo.store 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2004 (C) TJDO.
003:         * All rights reserved.
004:         *
005:         * This software is distributed under the terms of the TJDO License version 1.0.
006:         * See the terms of the TJDO License in the documentation provided with this software.
007:         *
008:         * $Id: ColumnMapping.java,v 1.5 2004/01/18 03:01:06 jackknifebarber Exp $
009:         */
010:
011:        package com.triactive.jdo.store;
012:
013:        import com.triactive.jdo.PersistenceManager;
014:        import java.sql.PreparedStatement;
015:        import java.sql.ResultSet;
016:        import javax.jdo.JDOFatalInternalException;
017:
018:        /**
019:         * A database mapping that maps a Java type to a single column.
020:         * <p>
021:         * A ColumnMapping can set Java objects directly into JDBC PreparedStatement
022:         * parameters, and get Java objects directly from JDBC ResultSet columns.
023:         *
024:         * @author <a href="mailto:mmartin5@austin.rr.com">Mike Martin</a>
025:         * @version $Revision: 1.5 $
026:         *
027:         * @see DatabaseAdapter#getMapping(Column)
028:         */
029:
030:        public abstract class ColumnMapping extends Mapping {
031:            protected final Column col;
032:
033:            protected TypeInfo typeInfo;
034:
035:            public ColumnMapping(DatabaseAdapter dba, Class type) {
036:                super (dba, type);
037:                this .col = null;
038:            }
039:
040:            public ColumnMapping(Column col) {
041:                super (col.getStoreManager().getDatabaseAdapter(), col.getType());
042:                this .col = col;
043:            }
044:
045:            protected abstract TypeInfo getTypeInfo();
046:
047:            protected void initTypeInfo() {
048:                TypeInfo typeInfo = getTypeInfo();
049:
050:                if (typeInfo == null)
051:                    throw new UnsupportedDataTypeException(
052:                            "No suitable JDBC type found for column " + col);
053:
054:                if (this .typeInfo != null)
055:                    throw new IllegalStateException(
056:                            "JDBC type already selected for column " + col);
057:
058:                this .typeInfo = typeInfo;
059:
060:                if (col != null)
061:                    col.setTypeInfo(typeInfo);
062:            }
063:
064:            public Column getColumn() {
065:                return col;
066:            }
067:
068:            public String getSQLInsertionValue() {
069:                return "?";
070:            }
071:
072:            public String getSQLUpdateValue() {
073:                return "?";
074:            }
075:
076:            public SQLExpression newSQLExpression(QueryStatement qs,
077:                    TableExpression te, String fieldName) {
078:                if (col == null)
079:                    throw new JDOFatalInternalException(
080:                            "Mapping has no specific column: " + this );
081:
082:                return newSQLExpression(qs, qs.getColumn(te, col), fieldName);
083:            }
084:
085:            protected String failureMessage(String method) {
086:                return "Somehow " + getClass().getName() + "." + method
087:                        + "() was called, which should not have been possible";
088:            }
089:
090:            public void setBoolean(PersistenceManager pm, PreparedStatement ps,
091:                    int param, boolean value) {
092:                throw new JDOFatalInternalException(
093:                        failureMessage("setBoolean"));
094:            }
095:
096:            public boolean getBoolean(PersistenceManager pm, ResultSet rs,
097:                    int column) {
098:                throw new JDOFatalInternalException(
099:                        failureMessage("setBoolean"));
100:            }
101:
102:            public void setChar(PersistenceManager pm, PreparedStatement ps,
103:                    int param, char value) {
104:                throw new JDOFatalInternalException(failureMessage("setChar"));
105:            }
106:
107:            public char getChar(PersistenceManager pm, ResultSet rs, int column) {
108:                throw new JDOFatalInternalException(failureMessage("getChar"));
109:            }
110:
111:            public void setByte(PersistenceManager pm, PreparedStatement ps,
112:                    int param, byte value) {
113:                throw new JDOFatalInternalException(failureMessage("setByte"));
114:            }
115:
116:            public byte getByte(PersistenceManager pm, ResultSet rs, int column) {
117:                throw new JDOFatalInternalException(failureMessage("getByte"));
118:            }
119:
120:            public void setShort(PersistenceManager pm, PreparedStatement ps,
121:                    int param, short value) {
122:                throw new JDOFatalInternalException(failureMessage("setShort"));
123:            }
124:
125:            public short getShort(PersistenceManager pm, ResultSet rs,
126:                    int column) {
127:                throw new JDOFatalInternalException(failureMessage("getShort"));
128:            }
129:
130:            public void setInt(PersistenceManager pm, PreparedStatement ps,
131:                    int param, int value) {
132:                throw new JDOFatalInternalException(failureMessage("setInt"));
133:            }
134:
135:            public int getInt(PersistenceManager pm, ResultSet rs, int column) {
136:                throw new JDOFatalInternalException(failureMessage("getInt"));
137:            }
138:
139:            public void setLong(PersistenceManager pm, PreparedStatement ps,
140:                    int param, long value) {
141:                throw new JDOFatalInternalException(failureMessage("setLong"));
142:            }
143:
144:            public long getLong(PersistenceManager pm, ResultSet rs, int column) {
145:                throw new JDOFatalInternalException(failureMessage("getLong"));
146:            }
147:
148:            public void setFloat(PersistenceManager pm, PreparedStatement ps,
149:                    int param, float value) {
150:                throw new JDOFatalInternalException(failureMessage("setFloat"));
151:            }
152:
153:            public float getFloat(PersistenceManager pm, ResultSet rs,
154:                    int column) {
155:                throw new JDOFatalInternalException(failureMessage("getFloat"));
156:            }
157:
158:            public void setDouble(PersistenceManager pm, PreparedStatement ps,
159:                    int param, double value) {
160:                throw new JDOFatalInternalException(failureMessage("setDouble"));
161:            }
162:
163:            public double getDouble(PersistenceManager pm, ResultSet rs,
164:                    int column) {
165:                throw new JDOFatalInternalException(failureMessage("getDouble"));
166:            }
167:
168:            public void setString(PersistenceManager pm, PreparedStatement ps,
169:                    int param, String value) {
170:                throw new JDOFatalInternalException(failureMessage("setString"));
171:            }
172:
173:            public String getString(PersistenceManager pm, ResultSet rs,
174:                    int column) {
175:                throw new JDOFatalInternalException(failureMessage("getString"));
176:            }
177:
178:            public void setObject(PersistenceManager pm, PreparedStatement ps,
179:                    int param, Object value) {
180:                throw new JDOFatalInternalException(failureMessage("setObject"));
181:            }
182:
183:            public Object getObject(PersistenceManager pm, ResultSet rs,
184:                    int column) {
185:                throw new JDOFatalInternalException(failureMessage("getObject"));
186:            }
187:
188:            public boolean equals(Object obj) {
189:                if (this  == obj)
190:                    return true;
191:
192:                if (!(obj instanceof  ColumnMapping))
193:                    return false;
194:
195:                ColumnMapping cm = (ColumnMapping) obj;
196:
197:                return getClass().equals(cm.getClass())
198:                        && dba.equals(cm.dba)
199:                        && (col == null ? cm.col == null : col.equals(cm.col))
200:                        && (typeInfo == null ? cm.typeInfo == null : typeInfo
201:                                .equals(cm.typeInfo));
202:            }
203:
204:            public int hashCode() {
205:                return dba.hashCode() ^ (col == null ? 0 : col.hashCode())
206:                        ^ (typeInfo == null ? 0 : typeInfo.hashCode());
207:            }
208:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.