Source Code Cross Referenced for Arguments.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-2007 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:         * @(#)Arguments.java	1.27 07/05/05
035:         */
036:
037:        package com.sun.tools.corba.se.idl.toJavaPortable;
038:
039:        // NOTES:
040:        // -09/23/98 <klr> Ported -td option to change output directory
041:        // -09/23/98 <klr> Ported -m option to generate make dependencies
042:        // -F46082.51<daz> Transferred -m, -mmin, mall, -mdepend options to com.sun.tools.corba.se.idl.toJava
043:        // since these are IBM-specific (see f46838); cleaned-out dead code.
044:        // -D57482   <klr> Added method setDefaultEmitter so could be overridden.
045:        // -F60858.1<daz> Set corba level to 2.3.
046:
047:        import java.util.Enumeration;
048:        import java.util.Hashtable;
049:        import java.util.Properties;
050:        import java.util.Vector;
051:        import java.io.File;
052:
053:        import com.sun.tools.corba.se.idl.InvalidArgument;
054:
055:        /**
056:         *
057:         **/
058:        public class Arguments extends com.sun.tools.corba.se.idl.Arguments {
059:            /**
060:             * Public, zero-argument constructor.
061:             **/
062:            public Arguments() {
063:                super ();
064:                corbaLevel = 2.4f;
065:            } // ctor
066:
067:            /**
068:             *
069:             **/
070:            protected void parseOtherArgs(String[] args, Properties properties)
071:                    throws InvalidArgument {
072:                String skeletonPattern = null;
073:                String tiePattern = null;
074:
075:                // Get package prefixes from user's properties file.
076:                packages.put("CORBA", "org.omg"); // klr - always needed
077:                packageFromProps(properties);
078:
079:                // Now get package prefixes from command line (along with other args).
080:                // This order has the effect of making command line packages
081:                // supercede any idl.config file packages.
082:                try {
083:                    Vector unknownArgs = new Vector();
084:
085:                    // Process command line parameters
086:                    for (int i = 0; i < args.length; ++i) {
087:                        String lcArg = args[i].toLowerCase();
088:
089:                        if (lcArg.charAt(0) != '-' && lcArg.charAt(0) != '/')
090:                            throw new InvalidArgument(args[i]);
091:                        if (lcArg.charAt(0) == '-') {
092:                            lcArg = lcArg.substring(1);
093:                        }
094:
095:                        // Proxy options; default is -fclient.
096:                        if (lcArg.startsWith("f")) {
097:                            // If the command line had '-f client', make it '-fclient'
098:                            if (lcArg.equals("f"))
099:                                lcArg = 'f' + args[++i].toLowerCase();
100:
101:                            // Determine whether to emit bindings for client, server or both; and
102:                            // whether to emit delegate-style (TIE) rather than derived-style
103:                            // skeletons, which are the default.
104:
105:                            if (lcArg.equals("fclient")) {
106:                                emit = ((emit == Server || emit == All) ? All
107:                                        : Client);
108:                            } else if (lcArg.equals("fserver")) {
109:                                emit = ((emit == Client || emit == All) ? All
110:                                        : Server);
111:                                TIEServer = false;
112:                            } else if (lcArg.equals("fall")) {
113:                                emit = All;
114:                                TIEServer = false;
115:                                //Should be removed and incorporated in the clause below
116:                                //            POAServer = true;
117:                            } else if (lcArg.equals("fservertie")) {
118:                                emit = ((emit == Client || emit == All) ? All
119:                                        : Server);
120:                                TIEServer = true;
121:                            } else if (lcArg.equals("falltie")) {
122:                                emit = All;
123:                                TIEServer = true;
124:                            } else
125:                                i = collectUnknownArg(args, i, unknownArgs);
126:                        } else if (lcArg.equals("pkgtranslate")) {
127:                            if (i + 2 >= args.length)
128:                                throw new InvalidArgument(args[i]);
129:
130:                            String orig = args[++i];
131:                            String trans = args[++i];
132:                            checkPackageNameValid(orig);
133:                            checkPackageNameValid(trans);
134:                            if (orig.equals("org")
135:                                    || orig.startsWith("org.omg"))
136:                                throw new InvalidArgument(args[i]);
137:                            orig = orig.replace('.', '/');
138:                            trans = trans.replace('.', '/');
139:                            packageTranslation.put(orig, trans);
140:                        }
141:                        // Package prefix
142:                        else if (lcArg.equals("pkgprefix")) {
143:                            if (i + 2 >= args.length)
144:                                throw new InvalidArgument(args[i]);
145:
146:                            String type = args[++i];
147:                            String pkg = args[++i];
148:                            checkPackageNameValid(type);
149:                            checkPackageNameValid(pkg);
150:                            packages.put(type, pkg);
151:                        }
152:                        // Target directory
153:                        else if (lcArg.equals("td")) // <f46838.4>
154:                        {
155:                            if (i + 1 >= args.length)
156:                                throw new InvalidArgument(args[i]);
157:                            String trgtDir = args[++i];
158:                            if (trgtDir.charAt(0) == '-')
159:                                throw new InvalidArgument(args[i - 1]);
160:                            else {
161:                                targetDir = trgtDir.replace('/',
162:                                        File.separatorChar);
163:                                if (targetDir.charAt(targetDir.length() - 1) != File.separatorChar)
164:                                    targetDir = targetDir + File.separatorChar;
165:                            }
166:                        }
167:                        // Separator
168:                        else if (lcArg.equals("sep")) {
169:                            if (i + 1 >= args.length)
170:                                throw new InvalidArgument(args[i]);
171:                            separator = args[++i];
172:                        }
173:                        // POA flag ?
174:                        else if (lcArg.equals("oldimplbase")) {
175:                            POAServer = false;
176:                        } else if (lcArg.equals("skeletonname")) {
177:                            if (i + 1 >= args.length)
178:                                throw new InvalidArgument(args[i]);
179:                            skeletonPattern = args[++i];
180:                        } else if (lcArg.equals("tiename")) {
181:                            if (i + 1 >= args.length)
182:                                throw new InvalidArgument(args[i]);
183:                            tiePattern = args[++i];
184:                        } else if (lcArg.equals("localoptimization")) {
185:                            LocalOptimization = true;
186:                        } else
187:                            i = collectUnknownArg(args, i, unknownArgs);
188:                    }
189:
190:                    // Encountered unknown arguments?
191:                    if (unknownArgs.size() > 0) {
192:                        String[] otherArgs = new String[unknownArgs.size()];
193:                        unknownArgs.copyInto(otherArgs);
194:                        // Throws InvalidArgument by default
195:                        super .parseOtherArgs(otherArgs, properties);
196:                    }
197:
198:                    setDefaultEmitter(); // d57482 <klr>
199:                    setNameModifiers(skeletonPattern, tiePattern);
200:                } catch (ArrayIndexOutOfBoundsException e) {
201:                    // If there is any array indexing problem, it is probably
202:                    // because the qualifier on the last argument is missing.
203:                    // Report that this last argument is invalid.
204:                    throw new InvalidArgument(args[args.length - 1]);
205:                }
206:            } // parseOtherArgs
207:
208:            /**
209:             *
210:             **/
211:            protected int collectUnknownArg(String[] args, int i,
212:                    Vector unknownArgs) {
213:                unknownArgs.addElement(args[i]);
214:                ++i;
215:                while (i < args.length && args[i].charAt(0) != '-'
216:                        && args[i].charAt(0) != '/')
217:                    unknownArgs.addElement(args[i++]);
218:                return --i;
219:            } // collectUnknownArg
220:
221:            /**
222:             *
223:             **/
224:            // XXX Either generalize this facility or remove it completely.
225:            protected void packageFromProps(Properties props)
226:                    throws InvalidArgument {
227:                Enumeration propsEnum = props.propertyNames();
228:                while (propsEnum.hasMoreElements()) {
229:                    String prop = (String) propsEnum.nextElement();
230:                    if (prop.startsWith("PkgPrefix.")) {
231:                        String type = prop.substring(10);
232:                        String pkg = props.getProperty(prop);
233:                        checkPackageNameValid(pkg);
234:                        checkPackageNameValid(type);
235:                        packages.put(type, pkg);
236:                    }
237:                }
238:            } // packageFromProps
239:
240:            /**
241:             * d57482 <klr> method added so default emitter check could be overriden.
242:             **/
243:            protected void setDefaultEmitter() {
244:                // If the flag -fclient was not found, assume it.
245:                if (emit == None)
246:                    emit = Client;
247:            }
248:
249:            protected void setNameModifiers(String skeletonPattern,
250:                    String tiePattern) {
251:                if (emit > Client) {
252:                    String tp;
253:                    String sp;
254:
255:                    if (skeletonPattern != null)
256:                        sp = skeletonPattern;
257:                    else if (POAServer)
258:                        sp = "%POA";
259:                    else
260:                        sp = "_%ImplBase";
261:
262:                    if (tiePattern != null)
263:                        tp = tiePattern;
264:                    else if (POAServer)
265:                        tp = "%POATie";
266:                    else
267:                        tp = "%_Tie";
268:
269:                    skeletonNameModifier = new NameModifierImpl(sp);
270:                    tieNameModifier = new NameModifierImpl(tp);
271:                }
272:            }
273:
274:            /**
275:             *
276:             **/
277:            private void checkPackageNameValid(String name)
278:                    throws InvalidArgument {
279:                if (name.charAt(0) == '.')
280:                    throw new InvalidArgument(name);
281:                for (int i = 0; i < name.length(); ++i)
282:                    if (name.charAt(i) == '.') {
283:                        if (i == name.length() - 1
284:                                || !Character.isJavaIdentifierStart(name
285:                                        .charAt(++i)))
286:                            throw new InvalidArgument(name);
287:                    } else if (!Character.isJavaIdentifierPart(name.charAt(i)))
288:                        throw new InvalidArgument(name);
289:            } // validatePackageName
290:
291:            // <46082.03><46838> Modified access restrictions from protected to public.
292:
293:            // This is a hash table whose keys are top-level typenames and
294:            // whose values are the package prefixes to those types.
295:            // For instance, <"CORBA", "org.omg"> is a possible entry.
296:            public Hashtable packages = new Hashtable();
297:
298:            public String separator = null;
299:
300:            public static final int None = 0, Client = 1, Server = 2, All = 3;
301:            public int emit = None;
302:            public boolean TIEServer = false;
303:            public boolean POAServer = true;
304:            // By default we do not generate Locally Optimized stub because of an
305:            // unresolved PI problem. We will generate only if -localOptimization flag
306:            // is passed
307:            public boolean LocalOptimization = false;
308:            public NameModifier skeletonNameModifier = null;
309:            public NameModifier tieNameModifier = null;
310:
311:            // Key is original package name; value is translated package name.
312:            // Note that this translation happens AFTER prefixes are added in the
313:            // packages table.
314:            public Hashtable packageTranslation = new Hashtable();
315:
316:            public String targetDir = ""; // <f46838.4>
317:        } // class Arguments
w_w_w.__ja___v_a2s___.__c_o_m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.