Source Code Cross Referenced for CastNode.java in  » Testing » PolePosition-0.20 » com » versant » core » jdo » query » 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 » Testing » PolePosition 0.20 » com.versant.core.jdo.query 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 1998 - 2005 Versant Corporation
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         * Versant Corporation - initial API and implementation
010:         */
011:        package com.versant.core.jdo.query;
012:
013:        /**
014:         * A cast operation.
015:         */
016:        public class CastNode extends UnaryNode {
017:
018:            public int brackets;
019:            public String type;
020:            public Class cls;
021:
022:            public CastNode(Node child, int brackets, Object tp) {
023:                super (child);
024:                this .brackets = brackets;
025:                if (tp instanceof  Class)
026:                    cls = (Class) tp;
027:                else
028:                    type = (String) tp;
029:            }
030:
031:            public String toString() {
032:                StringBuffer s = new StringBuffer();
033:                s.append(super .toString());
034:                s.append(" (");
035:                if (cls != null)
036:                    s.append(cls);
037:                else
038:                    s.append(type);
039:                s.append(')');
040:                return s.toString();
041:            }
042:
043:            public Field visit(MemVisitor visitor, Object obj) {
044:                return visitor.visitCastNode(this , obj);
045:            }
046:
047:            /**
048:             * Convert us into a FieldNavNode with cast information.
049:             */
050:            protected void normalizeImp() {
051:                super .normalizeImp();
052:
053:                // convert this tree:
054:                //   CastNode (Address) [this]
055:                //     FieldNavNode (PolyRefHolder)data [toRaise]
056:                //       FieldNode data [toReplace]
057:                //   FieldNode city [toMove]
058:                //   SomeOtherNode [toKeep] (may be missing)
059:
060:                // or this one (note that toRaise is missing):
061:                //   CastNode (Address) [this]
062:                //     FieldNode data [toReplace]
063:                //   FieldNode city [toMove]
064:                //   SomeOtherNode [toKeep] (may be missing)
065:
066:                // into:
067:                //   FieldNavNode (PolyRefHolder)data [toRaise]
068:                //     FieldNavNode (Address)data [castFnn]
069:                //       FieldNode city [toMove]
070:                //   SomeOtherNode [toKeep] (if not null)
071:
072:                if (next instanceof  FieldNode || next instanceof  FieldNavNode) {
073:
074:                    // find FieldNode to replace with FieldNavNode including cast
075:                    FieldNode toReplace = findFieldNode(childList);
076:                    if (toReplace == null)
077:                        return;
078:                    Node toMove = next;
079:                    Node toKeep = next.next;
080:                    Node toRaise = childList;
081:
082:                    // create FNN including cast from toReplace's field name
083:                    FieldNavNode castFnn = new FieldNavNode();
084:                    castFnn.cast = type;
085:                    castFnn.lexeme = toReplace.lexeme;
086:
087:                    // make toMove castFnn's only child
088:                    castFnn.childList = toMove;
089:                    toMove.parent = castFnn;
090:                    toMove.next = null;
091:
092:                    // make castFnn toReplace.parent's only child
093:                    toReplace.parent.childList = castFnn;
094:                    castFnn.parent = toReplace.parent;
095:
096:                    // if toRaise and toReplace are the same then raise castFnn
097:                    if (toRaise == toReplace)
098:                        toRaise = castFnn;
099:
100:                    // make toRaise and toKeep our parents first and second children
101:                    // removing us from the tree
102:                    parent.childList = toRaise;
103:                    toRaise.parent = parent;
104:                    toRaise.next = toKeep;
105:                    if (toKeep != null)
106:                        toKeep.parent = parent;
107:                }
108:            }
109:
110:            /**
111:             * Find the first FieldNode in tree at root following only the first
112:             * child of each node down the tree. Returns null if none found.
113:             */
114:            private FieldNode findFieldNode(Node root) {
115:                for (; root != null && !(root instanceof  FieldNode); root = root.childList)
116:                    ;
117:                return (FieldNode) root;
118:            }
119:
120:            public Object arrive(NodeVisitor v, Object msg) {
121:                return v.arriveCastNode(this, msg);
122:            }
123:
124:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.