Source Code Cross Referenced for RequestUsingFields.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: RequestUsingFields.java,v 1.2 2004/02/01 18:22:42 jackknifebarber Exp $
009:         */
010:
011:        package com.triactive.jdo.store;
012:
013:        import com.triactive.jdo.model.ClassMetaData;
014:        import com.triactive.jdo.util.IntArrayList;
015:        import javax.jdo.JDOFatalInternalException;
016:
017:        /**
018:         * A storage request involving specific fields of a persistence-capable
019:         * class.
020:         *
021:         * @author <a href="mailto:mmartin5@austin.rr.com">Mike Martin</a>
022:         * @version $Revision: 1.2 $
023:         */
024:
025:        abstract class RequestUsingFields extends Request {
026:            /**
027:             * The fields involved in this request that use ColumnMappings.
028:             * Null if there are no such fields.
029:             */
030:            protected final int[] colFields;
031:
032:            /**
033:             * The fields involved in this request that use ComplexMappings.
034:             * Null if there are no such fields.
035:             */
036:            protected final int[] cpxFields;
037:
038:            /**
039:             * The ColumnMappings used by fields involved in this request, indexed by
040:             * absolute field number.
041:             * Null if {@link #colFields} is null.
042:             */
043:            protected final ColumnMapping[] colFieldMappings;
044:
045:            /**
046:             * The ComplexMappings used by fields involved in this request, indexed by
047:             * absolute field number.
048:             * Null if {@link #cpxFields} is null.
049:             */
050:            protected final ComplexMapping[] cpxFieldMappings;
051:
052:            /**
053:             * Constructs a request involving all fields of the class backed by the
054:             * given table.
055:             *
056:             * @param table
057:             *      The table on which the request will operate.
058:             */
059:
060:            protected RequestUsingFields(final ClassBaseTable table) {
061:                this (table, new FieldIterator() {
062:                    private ClassMetaData cmd = table.getClassMetaData();
063:                    private int fn = cmd.getInheritedFieldCount();
064:                    private int end = fn + cmd.getFieldCount();
065:
066:                    public int nextFieldNumber() {
067:                        return fn < end ? fn++ : -1;
068:                    }
069:                });
070:            }
071:
072:            /**
073:             * Constructs a request involving the specified fields of the class backed
074:             * by the given table.
075:             *
076:             * @param table
077:             *      The table on which the request will operate.
078:             * @param fieldNumbers
079:             *      The fields that will be involved in the request.
080:             */
081:
082:            protected RequestUsingFields(final ClassBaseTable table,
083:                    final int[] fieldNumbers) {
084:                this (table, new FieldIterator() {
085:                    private ClassMetaData cmd = table.getClassMetaData();
086:                    private int start = cmd.getInheritedFieldCount();
087:                    private int end = start + cmd.getFieldCount();
088:                    private int idx = 0;
089:
090:                    public int nextFieldNumber() {
091:                        while (idx < fieldNumbers.length) {
092:                            int fn = fieldNumbers[idx++];
093:
094:                            if (fn >= start && fn < end)
095:                                return fn;
096:                        }
097:
098:                        return -1;
099:                    }
100:                });
101:            }
102:
103:            /**
104:             * Internal constructor that takes the field number list from a
105:             * FieldIterator.
106:             */
107:
108:            private RequestUsingFields(ClassBaseTable table,
109:                    FieldIterator fieldIterator) {
110:                super (table);
111:
112:                ClassMetaData cmd = table.getClassMetaData();
113:                int declaredFieldCount = cmd.getFieldCount();
114:                int inheritedFieldCount = cmd.getInheritedFieldCount();
115:                int totalFieldCount = inheritedFieldCount + declaredFieldCount;
116:
117:                IntArrayList colfn = new IntArrayList(declaredFieldCount);
118:                IntArrayList cpxfn = new IntArrayList(declaredFieldCount);
119:                ColumnMapping[] colfm = new ColumnMapping[totalFieldCount];
120:                ComplexMapping[] cpxfm = new ComplexMapping[totalFieldCount];
121:
122:                int field;
123:
124:                while ((field = fieldIterator.nextFieldNumber()) >= 0) {
125:                    if (table.isFieldPersistent(field)) {
126:                        Mapping m = table.getFieldMapping(field);
127:
128:                        if (m instanceof  ColumnMapping) {
129:                            colfn.add(field);
130:                            colfm[field] = (ColumnMapping) m;
131:                        } else if (m instanceof  ComplexMapping) {
132:                            cpxfn.add(field);
133:                            cpxfm[field] = (ComplexMapping) m;
134:                        } else
135:                            throw new JDOFatalInternalException(
136:                                    "Unknown mapping: " + m);
137:                    }
138:                }
139:
140:                if (colfn.isEmpty()) {
141:                    colFields = null;
142:                    colFieldMappings = null;
143:                } else {
144:                    colFields = colfn.toArray();
145:                    colFieldMappings = colfm;
146:                }
147:
148:                if (cpxfn.isEmpty()) {
149:                    cpxFields = null;
150:                    cpxFieldMappings = null;
151:                } else {
152:                    cpxFields = cpxfn.toArray();
153:                    cpxFieldMappings = cpxfm;
154:                }
155:            }
156:
157:            /**
158:             * An object that iterates over a set of field numbers.
159:             */
160:            private interface FieldIterator {
161:                /**
162:                 * Returns the next field number.
163:                 *
164:                 * @return The next field number, or -1 if there are no more fields.
165:                 */
166:                int nextFieldNumber();
167:            }
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.