Source Code Cross Referenced for ObjectAsLongMapping.java in  » Database-ORM » JPOX » org » jpox » store » mapping » 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 » JPOX » org.jpox.store.mapping 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************
002:        Copyright (c) 2006 Andy Jefferson and others. All rights reserved.
003:        Licensed under the Apache License, Version 2.0 (the "License");
004:        you may not use this file except in compliance with the License.
005:        You may obtain a copy of the License at
006:
007:            http://www.apache.org/licenses/LICENSE-2.0
008:
009:        Unless required by applicable law or agreed to in writing, software
010:        distributed under the License is distributed on an "AS IS" BASIS,
011:        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012:        See the License for the specific language governing permissions and
013:        limitations under the License.
014:
015:        Contributors:
016:            ...
017:         **********************************************************************/package org.jpox.store.mapping;
018:
019:        import org.jpox.ClassNameConstants;
020:        import org.jpox.ObjectManager;
021:        import org.jpox.store.expression.IntegerLiteral;
022:        import org.jpox.store.expression.LogicSetExpression;
023:        import org.jpox.store.expression.NumericExpression;
024:        import org.jpox.store.expression.QueryExpression;
025:        import org.jpox.store.expression.ScalarExpression;
026:
027:        /**
028:         * Abstract SCO mapping for a java type that will be stored as a Long type.
029:         *
030:         * @version $Revision: 1.5 $
031:         */
032:        public abstract class ObjectAsLongMapping extends SingleFieldMapping
033:                implements  SimpleDatastoreRepresentation {
034:            /**
035:             * Method to create a literal of this type for use in a JDOQL query.
036:             * @param qs The QueryExpression
037:             * @param value The value of the literal
038:             * @return The Literal
039:             */
040:            public ScalarExpression newLiteral(QueryExpression qs, Object value) {
041:                return new IntegerLiteral(qs, this , objectToLong(value));
042:            }
043:
044:            /**
045:             * Method to create a new expression for this mapping for use in a JDOQL Query.
046:             * @param qs The QueryExpression
047:             * @param te Expression for the datastore container
048:             * @return The JDOQL expression
049:             */
050:            public ScalarExpression newScalarExpression(QueryExpression qs,
051:                    LogicSetExpression te) {
052:                return new NumericExpression(qs, this , te);
053:            }
054:
055:            /**
056:             * Method to return the Java type.
057:             * @return The Java type being represented.
058:             */
059:            public abstract Class getJavaType();
060:
061:            /**
062:             * Accessor for the name of the java-type actually used when mapping the particular datastore
063:             * field. This java-type must have an entry in the datastore mappings.
064:             * @param index requested datastore field index.
065:             * @return the name of java-type for the requested datastore field.
066:             */
067:            public String getJavaTypeForDatastoreMapping(int index) {
068:                // All of the types extending this class will be using java-type of Long for the datastore
069:                return ClassNameConstants.JAVA_LANG_LONG;
070:            }
071:
072:            /**
073:             * Method to set the object when updating the the datastore.
074:             * @see org.jpox.store.mapping.SingleFieldMapping#setObject(org.jpox.ObjectManager, java.lang.Object, int[], java.lang.Object)
075:             */
076:            public void setObject(ObjectManager om, Object preparedStatement,
077:                    int[] exprIndex, Object value) {
078:                getDataStoreMapping(0).setObject(preparedStatement,
079:                        exprIndex[0], objectToLong(value));
080:            }
081:
082:            /**
083:             * Method to get the object from the datastore and convert to an object.
084:             * @see org.jpox.store.mapping.SingleFieldMapping#getObject(org.jpox.ObjectManager, java.lang.Object, int[])
085:             */
086:            public Object getObject(ObjectManager om, Object resultSet,
087:                    int[] exprIndex) {
088:                if (exprIndex == null) {
089:                    return null;
090:                }
091:
092:                Object datastoreValue = getDataStoreMapping(0).getObject(
093:                        resultSet, exprIndex[0]);
094:                Object value = null;
095:                if (datastoreValue != null) {
096:                    value = longToObject((Long) datastoreValue);
097:                }
098:                return value;
099:            }
100:
101:            /**
102:             * Method to set the datastore value based on the object value.
103:             * @param object The object
104:             * @return The value to pass to the datastore
105:             */
106:            protected abstract Long objectToLong(Object object);
107:
108:            /**
109:             * Method to extract the objects value from the datastore object.
110:             * @param datastoreValue Value obtained from the datastore
111:             * @return The value of this object (derived from the datastore value)
112:             */
113:            protected abstract Object longToObject(Long datastoreValue);
114:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.