Source Code Cross Referenced for MethodGen24.java in  » 6.0-JDK-Modules-com.sun » tools » com » sun » tools » corba » se » idl » toJavaPortable » 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 » 6.0 JDK Modules com.sun » tools » com.sun.tools.corba.se.idl.toJavaPortable 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 1999-2001 Sun Microsystems, Inc.  All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004:         *
005:         * This code is free software; you can redistribute it and/or modify it
006:         * under the terms of the GNU General Public License version 2 only, as
007:         * published by the Free Software Foundation.  Sun designates this
008:         * particular file as subject to the "Classpath" exception as provided
009:         * by Sun in the LICENSE file that accompanied this code.
010:         *
011:         * This code is distributed in the hope that it will be useful, but WITHOUT
012:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014:         * version 2 for more details (a copy is included in the LICENSE file that
015:         * accompanied this code).
016:         *
017:         * You should have received a copy of the GNU General Public License version
018:         * 2 along with this work; if not, write to the Free Software Foundation,
019:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020:         *
021:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022:         * CA 95054 USA or visit www.sun.com if you need additional information or
023:         * have any questions.
024:         */
025:        /*
026:         * COMPONENT_NAME: idl.toJava
027:         *
028:         * ORIGINS: 27
029:         *
030:         * Licensed Materials - Property of IBM
031:         * 5639-D57 (C) COPYRIGHT International Business Machines Corp. 1997, 1999
032:         * RMI-IIOP v1.0
033:         *
034:         * @(#)MethodGen24.java	1.20 07/05/05
035:         */
036:
037:        package com.sun.tools.corba.se.idl.toJavaPortable;
038:
039:        // NOTES:
040:        // -D62023   <klr> New file to implement CORBA 2.4 RTF
041:        // -D62794   <klr> Fix problem with no-arg create functions
042:
043:        import java.io.PrintWriter;
044:
045:        import java.util.Enumeration;
046:        import java.util.Vector;
047:        import java.util.Hashtable;
048:
049:        import com.sun.tools.corba.se.idl.GenFileStream;
050:        import com.sun.tools.corba.se.idl.InterfaceEntry;
051:        import com.sun.tools.corba.se.idl.MethodEntry;
052:        import com.sun.tools.corba.se.idl.ParameterEntry;
053:        import com.sun.tools.corba.se.idl.SymtabEntry;
054:        import com.sun.tools.corba.se.idl.ValueEntry;
055:        import com.sun.tools.corba.se.idl.ValueBoxEntry;
056:        import com.sun.tools.corba.se.idl.TypedefEntry;
057:        import com.sun.tools.corba.se.idl.InterfaceState;
058:        import com.sun.tools.corba.se.idl.PrimitiveEntry;
059:        import com.sun.tools.corba.se.idl.StructEntry;
060:
061:        /**
062:         *
063:         **/
064:        public class MethodGen24 extends MethodGen {
065:            /**
066:             * Public zero-argument constructor.
067:             **/
068:            public MethodGen24() {
069:            } // ctor
070:
071:            /**
072:             * Print the parameter list for the factory method.
073:             * @param m The method to list parameters for
074:             * @param listTypes If try, declare the parms, otherwise just list them
075:             * @param stream The PrintWriter to print on
076:             */
077:            protected void writeParmList(MethodEntry m, boolean listTypes,
078:                    PrintWriter stream) {
079:                boolean firstTime = true;
080:                Enumeration e = m.parameters().elements();
081:                while (e.hasMoreElements()) {
082:                    if (firstTime)
083:                        firstTime = false;
084:                    else
085:                        stream.print(", ");
086:                    ParameterEntry parm = (ParameterEntry) e.nextElement();
087:                    if (listTypes) {
088:                        writeParmType(parm.type(), parm.passType());
089:                        stream.print(' ');
090:                    }
091:                    // Print parm name
092:                    stream.print(parm.name());
093:                    // end of parameter list
094:                }
095:            }
096:
097:            /**
098:             * <d62023> Write the methodEntry for a valuetype factory method into
099:             * 	      the Value Helper class. Contents from email from Simon,
100:             *	      4/25/99.
101:             **/
102:            protected void helperFactoryMethod(Hashtable symbolTable,
103:                    MethodEntry m, SymtabEntry t, PrintWriter stream) {
104:                this .symbolTable = symbolTable;
105:                this .m = m;
106:                this .stream = stream;
107:                String initializerName = m.name();
108:                String typeName = Util.javaName(t);
109:                String factoryName = typeName + "ValueFactory";
110:
111:                // Step 1. Print factory method decl up to parms.
112:                stream.print("  public static " + typeName + " "
113:                        + initializerName + " (org.omg.CORBA.ORB $orb");
114:                if (!m.parameters().isEmpty())
115:                    stream.print(", "); // <d62794>
116:
117:                // Step 2. Print the declaration parameter list.
118:                writeParmList(m, true, stream);
119:
120:                // Step 3. Print the body of the factory method
121:                stream.println(")");
122:                stream.println("  {");
123:                stream.println("    try {");
124:                stream.println("      " + factoryName + " $factory = ("
125:                        + factoryName + ")");
126:                stream
127:                        .println("          ((org.omg.CORBA_2_3.ORB) $orb).lookup_value_factory(id());");
128:                stream.print("      return $factory." + initializerName + " (");
129:                writeParmList(m, false, stream);
130:                stream.println(");");
131:                stream.println("    } catch (ClassCastException $ex) {");
132:                stream.println("      throw new org.omg.CORBA.BAD_PARAM ();");
133:                stream.println("    }");
134:                stream.println("  }");
135:                stream.println();
136:            } // helperFactoryMethod
137:
138:            /**
139:             * <d62023> - write an abstract method definition
140:             **/
141:            protected void abstractMethod(Hashtable symbolTable, MethodEntry m,
142:                    PrintWriter stream) {
143:                this .symbolTable = symbolTable;
144:                this .m = m;
145:                this .stream = stream;
146:                if (m.comment() != null)
147:                    m.comment().generate("  ", stream);
148:                stream.print("  ");
149:                stream.print("public abstract ");
150:                writeMethodSignature();
151:                stream.println(";");
152:                stream.println();
153:            } // abstractMethod
154:
155:            /**
156:             * <d62023> - write a default factory method implementation for the
157:             *		<value>DefaultFactory. m is a methodEntry for a factory
158:             *		method contained in a non-abstract ValueEntry.
159:             **/
160:            protected void defaultFactoryMethod(Hashtable symbolTable,
161:                    MethodEntry m, PrintWriter stream) {
162:                this .symbolTable = symbolTable;
163:                this .m = m;
164:                this .stream = stream;
165:                String typeName = m.container().name();
166:                stream.println();
167:                if (m.comment() != null)
168:                    m.comment().generate("  ", stream);
169:                stream.print("  public " + typeName + " " + m.name() + " (");
170:                writeParmList(m, true, stream);
171:                stream.println(")");
172:                stream.println("  {");
173:                stream.print("    return new " + typeName + "Impl (");
174:                writeParmList(m, false, stream);
175:                stream.println(");");
176:                stream.println("  }");
177:            } // defaultFactoryMethod
178:
179:            /**
180:             * <d62023> - remove all valueInitializer junk
181:             **/
182:            protected void writeMethodSignature() {
183:                // Step 0.  Print the return type and name.
184:                // A return type of null indicates the "void" return type. If m is a
185:                // Valuetype factory method, it has a null return type,
186:                if (m.type() == null) {
187:                    // if factory method, result type is container 
188:                    if (isValueInitializer())
189:                        stream.print(m.container().name());
190:                    else
191:                        stream.print("void");
192:                } else {
193:                    stream.print(Util.javaName(m.type()));
194:                }
195:                stream.print(' ' + m.name() + " (");
196:
197:                // Step 1.  Print the parameter list.
198:                boolean firstTime = true;
199:                Enumeration e = m.parameters().elements();
200:                while (e.hasMoreElements()) {
201:                    if (firstTime)
202:                        firstTime = false;
203:                    else
204:                        stream.print(", ");
205:                    ParameterEntry parm = (ParameterEntry) e.nextElement();
206:
207:                    writeParmType(parm.type(), parm.passType());
208:
209:                    // Print parm name
210:                    stream.print(' ' + parm.name());
211:                }
212:
213:                // Step 2.  Add the context parameter if necessary.
214:                if (m.contexts().size() > 0) {
215:                    if (!firstTime)
216:                        stream.print(", ");
217:                    stream.print("org.omg.CORBA.Context $context");
218:                }
219:
220:                // Step 3.  Print the throws clause (if necessary).
221:                if (m.exceptions().size() > 0) {
222:                    stream.print(") throws ");
223:                    e = m.exceptions().elements();
224:                    firstTime = true;
225:                    while (e.hasMoreElements()) {
226:                        if (firstTime)
227:                            firstTime = false;
228:                        else
229:                            stream.print(", ");
230:                        stream.print(Util.javaName((SymtabEntry) e
231:                                .nextElement()));
232:                    }
233:                } else
234:                    stream.print(')');
235:            } // writeMethodSignature
236:
237:            /**
238:             * <d62023> - delete method templates for valuetypes
239:             **/
240:            protected void interfaceMethod(Hashtable symbolTable,
241:                    MethodEntry m, PrintWriter stream) {
242:                this .symbolTable = symbolTable;
243:                this .m = m;
244:                this .stream = stream;
245:                if (m.comment() != null)
246:                    m.comment().generate("  ", stream);
247:                stream.print("  ");
248:                writeMethodSignature();
249:                stream.println(";");
250:            } // interfaceMethod
251:        }
w__w__w._ja__v_a_2__s.c_om | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.