Source Code Cross Referenced for SubId.java in  » EJB-Server-resin-3.1.5 » resin » com » caucho » amber » field » 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 » EJB Server resin 3.1.5 » resin » com.caucho.amber.field 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003:         *
004:         * This file is part of Resin(R) Open Source
005:         *
006:         * Each copy or derived work must preserve the copyright notice and this
007:         * notice unmodified.
008:         *
009:         * Resin Open Source is free software; you can redistribute it and/or modify
010:         * it under the terms of the GNU General Public License as published by
011:         * the Free Software Foundation; either version 2 of the License, or
012:         * (at your option) any later version.
013:         *
014:         * Resin Open Source is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017:         * of NON-INFRINGEMENT.  See the GNU General Public License for more
018:         * details.
019:         *
020:         * You should have received a copy of the GNU General Public License
021:         * along with Resin Open Source; if not, write to the
022:         *
023:         *   Free Software Foundation, Inc.
024:         *   59 Temple Place, Suite 330
025:         *   Boston, MA 02111-1307  USA
026:         *
027:         * @author Scott Ferguson
028:         */
029:
030:        package com.caucho.amber.field;
031:
032:        import com.caucho.amber.manager.AmberPersistenceUnit;
033:        import com.caucho.amber.table.Column;
034:        import com.caucho.amber.table.LinkColumns;
035:        import com.caucho.amber.type.RelatedType;
036:        import com.caucho.java.JavaWriter;
037:        import com.caucho.log.Log;
038:        import com.caucho.util.CharBuffer;
039:        import com.caucho.util.L10N;
040:
041:        import java.io.IOException;
042:        import java.util.ArrayList;
043:        import java.util.HashSet;
044:        import java.util.logging.Logger;
045:
046:        /**
047:         * Configuration for a bean's field
048:         */
049:        public class SubId extends Id {
050:            private static final L10N L = new L10N(SubId.class);
051:            protected static final Logger log = Log.open(SubId.class);
052:
053:            private Id _parentId;
054:            private LinkColumns _link;
055:
056:            public SubId(RelatedType ownerType, RelatedType rootType) {
057:                super (ownerType, new ArrayList<IdField>());
058:
059:                _parentId = rootType.getId();
060:            }
061:
062:            /**
063:             * Returns the parent keys.
064:             */
065:            public ArrayList<IdField> getParentKeys() {
066:                return _parentId.getKeys();
067:            }
068:
069:            /**
070:             * Returns the keys.
071:             */
072:            public ArrayList<IdField> getKeys() {
073:                return _parentId.getKeys();
074:            }
075:
076:            /**
077:             * Returns the foreign type.
078:             */
079:            public String getForeignTypeName() {
080:                return _parentId.getForeignTypeName();
081:            }
082:
083:            /**
084:             * Generates any prologue.
085:             */
086:            public void generatePrologue(JavaWriter out,
087:                    HashSet<Object> completedSet) throws IOException {
088:            }
089:
090:            /**
091:             * Returns the foreign type.
092:             */
093:            public int generateLoadForeign(JavaWriter out, String rs,
094:                    String indexVar, int index) throws IOException {
095:                return _parentId.generateLoadForeign(out, rs, indexVar, index);
096:            }
097:
098:            /**
099:             * Returns the foreign type.
100:             */
101:            public int generateLoadForeign(JavaWriter out, String rs,
102:                    String indexVar, int index, String name) throws IOException {
103:                return _parentId.generateLoadForeign(out, rs, indexVar, index,
104:                        name);
105:            }
106:
107:            /**
108:             * Generates the select clause.
109:             */
110:            public String generateSelect(String id) {
111:                ArrayList<IdField> keys = getParentKeys();
112:
113:                CharBuffer cb = CharBuffer.allocate();
114:
115:                for (int i = 0; i < keys.size(); i++) {
116:                    if (i != 0)
117:                        cb.append(", ");
118:
119:                    cb.append(keys.get(i).generateSelect(id));
120:                }
121:
122:                return cb.close();
123:            }
124:
125:            /**
126:             * Generates the select clause.
127:             */
128:            public String generateLoadSelect(String id) {
129:                return null;
130:            }
131:
132:            /**
133:             * Returns the key for the value
134:             */
135:            public String generateGetProperty(String value) {
136:                return _parentId.generateGetProperty(value);
137:            }
138:
139:            /**
140:             * Generates loading cache
141:             */
142:            public void generateLoadFromObject(JavaWriter out, String obj)
143:                    throws IOException {
144:                _parentId.generateLoadFromObject(out, obj);
145:            }
146:
147:            /**
148:             * Generates loading cache
149:             */
150:            public void generateSet(JavaWriter out, String obj)
151:                    throws IOException {
152:                _parentId.generateSet(out, obj);
153:            }
154:
155:            /**
156:             * Generates loading cache
157:             */
158:            public void generateUpdateFromObject(JavaWriter out, String obj)
159:                    throws IOException {
160:                _parentId.generateUpdateFromObject(out, obj);
161:            }
162:
163:            /**
164:             * Generates the where clause.
165:             */
166:            public String generateMatchArgWhere(String id) {
167:                ArrayList<IdField> keys = getParentKeys();
168:
169:                CharBuffer cb = CharBuffer.allocate();
170:
171:                for (int i = 0; i < keys.size(); i++) {
172:                    if (i != 0)
173:                        cb.append(" and ");
174:
175:                    generateMatchArgWhere(cb, keys.get(i), id);
176:                }
177:
178:                return cb.close();
179:            }
180:
181:            /**
182:             * Generates the where clause.
183:             */
184:            private void generateMatchArgWhere(CharBuffer cb, IdField parentId,
185:                    String id) {
186:                LinkColumns link = getOwnerType().getTable()
187:                        .getDependentIdLink();
188:
189:                ArrayList<Column> columns = parentId.getColumns();
190:
191:                for (int i = 0; i < columns.size(); i++) {
192:                    Column column = columns.get(i);
193:
194:                    if (i != 0)
195:                        cb.append(" and ");
196:
197:                    cb.append(id);
198:                    cb.append('.');
199:                    cb.append(link.getSourceColumn(column).getName());
200:                    cb.append("=?");
201:                }
202:            }
203:
204:            /**
205:             * Generates the where clause.
206:             */
207:            public String generateCreateTableSQL(AmberPersistenceUnit manager) {
208:                return null;
209:            }
210:
211:            /**
212:             * Generates the set clause.
213:             */
214:            public void generateSetKey(JavaWriter out, String pstmt,
215:                    String obj, String index) throws IOException {
216:                _parentId.generateSetKey(out, pstmt, obj, index);
217:            }
218:
219:            /**
220:             * Generates the set clause.
221:             */
222:            public void generateSet(JavaWriter out, String pstmt, String obj,
223:                    String index) throws IOException {
224:                _parentId.generateSet(out, pstmt, obj, index);
225:            }
226:
227:            /**
228:             * Generates the set clause.
229:             */
230:            public void generateSet(JavaWriter out, String pstmt, String index)
231:                    throws IOException {
232:                _parentId.generateSet(out, pstmt, index);
233:            }
234:
235:            /**
236:             * Generates the set clause.
237:             */
238:            public void generateSetInsert(JavaWriter out, String pstmt,
239:                    String index) throws IOException {
240:                _parentId.generateSetInsert(out, pstmt, index);
241:            }
242:
243:            /**
244:             * Generates code to convert to the type from the object.
245:             */
246:            public String generateCastFromObject(String value) {
247:                return value;
248:            }
249:
250:            /**
251:             * Generates code for a match.
252:             */
253:            public void generateMatch(JavaWriter out, String key)
254:                    throws IOException {
255:                // jpa/0l30
256:                out
257:                        .println("return "
258:                                + generateEquals("__caucho_getPrimaryKey()",
259:                                        key) + ";");
260:            }
261:
262:            /**
263:             * Generates code to test the equals.
264:             */
265:            public String generateEquals(String leftBase, String value) {
266:                return leftBase + ".equals(" + value + ")";
267:            }
268:
269:            /**
270:             * Generates the set clause.
271:             */
272:            public void generateCheckCreateKey(JavaWriter out)
273:                    throws IOException {
274:            }
275:
276:            /**
277:             * Generates code to convert to the object.
278:             */
279:            public String toObject(String value) {
280:                return value;
281:            }
282:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.