corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/Arguments.java
author ohair
Tue, 25 May 2010 15:52:11 -0700
changeset 5555 b2b5ed3f0d0d
parent 4 02bb8761fcce
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     1
/*
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     2
 * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
02bb8761fcce Initial load
duke
parents:
diff changeset
     4
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
02bb8761fcce Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    10
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
02bb8761fcce Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
02bb8761fcce Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
02bb8761fcce Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
02bb8761fcce Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
02bb8761fcce Initial load
duke
parents:
diff changeset
    16
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
02bb8761fcce Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
02bb8761fcce Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
02bb8761fcce Initial load
duke
parents:
diff changeset
    20
 *
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    23
 * questions.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    24
 */
02bb8761fcce Initial load
duke
parents:
diff changeset
    25
/*
02bb8761fcce Initial load
duke
parents:
diff changeset
    26
 * COMPONENT_NAME: idl.toJava
02bb8761fcce Initial load
duke
parents:
diff changeset
    27
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    28
 * ORIGINS: 27
02bb8761fcce Initial load
duke
parents:
diff changeset
    29
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    30
 * Licensed Materials - Property of IBM
02bb8761fcce Initial load
duke
parents:
diff changeset
    31
 * 5639-D57 (C) COPYRIGHT International Business Machines Corp. 1997, 1999
02bb8761fcce Initial load
duke
parents:
diff changeset
    32
 * RMI-IIOP v1.0
02bb8761fcce Initial load
duke
parents:
diff changeset
    33
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    34
 */
02bb8761fcce Initial load
duke
parents:
diff changeset
    35
02bb8761fcce Initial load
duke
parents:
diff changeset
    36
package com.sun.tools.corba.se.idl.toJavaPortable;
02bb8761fcce Initial load
duke
parents:
diff changeset
    37
02bb8761fcce Initial load
duke
parents:
diff changeset
    38
// NOTES:
02bb8761fcce Initial load
duke
parents:
diff changeset
    39
// -09/23/98 <klr> Ported -td option to change output directory
02bb8761fcce Initial load
duke
parents:
diff changeset
    40
// -09/23/98 <klr> Ported -m option to generate make dependencies
02bb8761fcce Initial load
duke
parents:
diff changeset
    41
// -F46082.51<daz> Transferred -m, -mmin, mall, -mdepend options to com.sun.tools.corba.se.idl.toJava
02bb8761fcce Initial load
duke
parents:
diff changeset
    42
// since these are IBM-specific (see f46838); cleaned-out dead code.
02bb8761fcce Initial load
duke
parents:
diff changeset
    43
// -D57482   <klr> Added method setDefaultEmitter so could be overridden.
02bb8761fcce Initial load
duke
parents:
diff changeset
    44
// -F60858.1<daz> Set corba level to 2.3.
02bb8761fcce Initial load
duke
parents:
diff changeset
    45
02bb8761fcce Initial load
duke
parents:
diff changeset
    46
import java.util.Enumeration;
02bb8761fcce Initial load
duke
parents:
diff changeset
    47
import java.util.Hashtable;
02bb8761fcce Initial load
duke
parents:
diff changeset
    48
import java.util.Properties;
02bb8761fcce Initial load
duke
parents:
diff changeset
    49
import java.util.Vector;
02bb8761fcce Initial load
duke
parents:
diff changeset
    50
import java.io.File;
02bb8761fcce Initial load
duke
parents:
diff changeset
    51
02bb8761fcce Initial load
duke
parents:
diff changeset
    52
import com.sun.tools.corba.se.idl.InvalidArgument;
02bb8761fcce Initial load
duke
parents:
diff changeset
    53
02bb8761fcce Initial load
duke
parents:
diff changeset
    54
/**
02bb8761fcce Initial load
duke
parents:
diff changeset
    55
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    56
 **/
02bb8761fcce Initial load
duke
parents:
diff changeset
    57
public class Arguments extends com.sun.tools.corba.se.idl.Arguments
02bb8761fcce Initial load
duke
parents:
diff changeset
    58
{
02bb8761fcce Initial load
duke
parents:
diff changeset
    59
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
    60
   * Public, zero-argument constructor.
02bb8761fcce Initial load
duke
parents:
diff changeset
    61
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
    62
  public Arguments ()
02bb8761fcce Initial load
duke
parents:
diff changeset
    63
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
    64
    super ();
02bb8761fcce Initial load
duke
parents:
diff changeset
    65
    corbaLevel = 2.4f;
02bb8761fcce Initial load
duke
parents:
diff changeset
    66
  } // ctor
02bb8761fcce Initial load
duke
parents:
diff changeset
    67
02bb8761fcce Initial load
duke
parents:
diff changeset
    68
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
    69
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
    70
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
    71
  protected void parseOtherArgs (String[] args,
02bb8761fcce Initial load
duke
parents:
diff changeset
    72
    Properties properties) throws InvalidArgument
02bb8761fcce Initial load
duke
parents:
diff changeset
    73
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
    74
    String skeletonPattern = null ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    75
    String tiePattern = null ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    76
02bb8761fcce Initial load
duke
parents:
diff changeset
    77
    // Get package prefixes from user's properties file.
02bb8761fcce Initial load
duke
parents:
diff changeset
    78
    packages.put ("CORBA", "org.omg"); // klr - always needed
02bb8761fcce Initial load
duke
parents:
diff changeset
    79
    packageFromProps (properties);
02bb8761fcce Initial load
duke
parents:
diff changeset
    80
02bb8761fcce Initial load
duke
parents:
diff changeset
    81
    // Now get package prefixes from command line (along with other args).
02bb8761fcce Initial load
duke
parents:
diff changeset
    82
    // This order has the effect of making command line packages
02bb8761fcce Initial load
duke
parents:
diff changeset
    83
    // supercede any idl.config file packages.
02bb8761fcce Initial load
duke
parents:
diff changeset
    84
    try
02bb8761fcce Initial load
duke
parents:
diff changeset
    85
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
    86
      Vector unknownArgs = new Vector ();
02bb8761fcce Initial load
duke
parents:
diff changeset
    87
02bb8761fcce Initial load
duke
parents:
diff changeset
    88
      // Process command line parameters
02bb8761fcce Initial load
duke
parents:
diff changeset
    89
      for (int i = 0; i < args.length; ++i)
02bb8761fcce Initial load
duke
parents:
diff changeset
    90
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
    91
        String lcArg = args[i].toLowerCase ();
02bb8761fcce Initial load
duke
parents:
diff changeset
    92
02bb8761fcce Initial load
duke
parents:
diff changeset
    93
        if (lcArg.charAt (0) != '-' && lcArg.charAt (0) != '/')
02bb8761fcce Initial load
duke
parents:
diff changeset
    94
          throw new InvalidArgument (args[i]);
02bb8761fcce Initial load
duke
parents:
diff changeset
    95
        if (lcArg.charAt (0) == '-' ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
    96
            lcArg = lcArg.substring (1);
02bb8761fcce Initial load
duke
parents:
diff changeset
    97
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
    98
02bb8761fcce Initial load
duke
parents:
diff changeset
    99
        // Proxy options; default is -fclient.
02bb8761fcce Initial load
duke
parents:
diff changeset
   100
        if (lcArg.startsWith ("f"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   101
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
   102
          // If the command line had '-f client', make it '-fclient'
02bb8761fcce Initial load
duke
parents:
diff changeset
   103
          if (lcArg.equals ("f"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   104
            lcArg = 'f' + args[++i].toLowerCase ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   105
02bb8761fcce Initial load
duke
parents:
diff changeset
   106
          // Determine whether to emit bindings for client, server or both; and
02bb8761fcce Initial load
duke
parents:
diff changeset
   107
          // whether to emit delegate-style (TIE) rather than derived-style
02bb8761fcce Initial load
duke
parents:
diff changeset
   108
          // skeletons, which are the default.
02bb8761fcce Initial load
duke
parents:
diff changeset
   109
02bb8761fcce Initial load
duke
parents:
diff changeset
   110
          if (lcArg.equals ("fclient"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   111
          {
02bb8761fcce Initial load
duke
parents:
diff changeset
   112
            emit = ((emit == Server || emit == All) ? All : Client);
02bb8761fcce Initial load
duke
parents:
diff changeset
   113
          }
02bb8761fcce Initial load
duke
parents:
diff changeset
   114
          else if (lcArg.equals ("fserver"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   115
          {
02bb8761fcce Initial load
duke
parents:
diff changeset
   116
            emit = ((emit == Client || emit == All) ? All : Server);
02bb8761fcce Initial load
duke
parents:
diff changeset
   117
            TIEServer = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   118
          }
02bb8761fcce Initial load
duke
parents:
diff changeset
   119
          else if (lcArg.equals ("fall"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   120
          {
02bb8761fcce Initial load
duke
parents:
diff changeset
   121
            emit = All;
02bb8761fcce Initial load
duke
parents:
diff changeset
   122
            TIEServer = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   123
            //Should be removed and incorporated in the clause below
02bb8761fcce Initial load
duke
parents:
diff changeset
   124
            //            POAServer = true;
02bb8761fcce Initial load
duke
parents:
diff changeset
   125
          }
02bb8761fcce Initial load
duke
parents:
diff changeset
   126
          else if (lcArg.equals ("fservertie"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   127
          {
02bb8761fcce Initial load
duke
parents:
diff changeset
   128
            emit = ((emit == Client || emit == All) ? All : Server);
02bb8761fcce Initial load
duke
parents:
diff changeset
   129
            TIEServer = true;
02bb8761fcce Initial load
duke
parents:
diff changeset
   130
          }
02bb8761fcce Initial load
duke
parents:
diff changeset
   131
          else if (lcArg.equals ("falltie"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   132
          {
02bb8761fcce Initial load
duke
parents:
diff changeset
   133
            emit = All;
02bb8761fcce Initial load
duke
parents:
diff changeset
   134
            TIEServer = true;
02bb8761fcce Initial load
duke
parents:
diff changeset
   135
          }
02bb8761fcce Initial load
duke
parents:
diff changeset
   136
          else
02bb8761fcce Initial load
duke
parents:
diff changeset
   137
            i = collectUnknownArg (args, i, unknownArgs);
02bb8761fcce Initial load
duke
parents:
diff changeset
   138
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   139
        else if (lcArg.equals ("pkgtranslate"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   140
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
   141
          if (i + 2 >= args.length)
02bb8761fcce Initial load
duke
parents:
diff changeset
   142
            throw new InvalidArgument( args[i] ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   143
02bb8761fcce Initial load
duke
parents:
diff changeset
   144
          String orig = args[++i] ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   145
          String trans = args[++i] ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   146
          checkPackageNameValid( orig ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   147
          checkPackageNameValid( trans ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   148
          if (orig.equals( "org" ) || orig.startsWith( "org.omg" ))
02bb8761fcce Initial load
duke
parents:
diff changeset
   149
              throw new InvalidArgument( args[i] ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   150
          orig = orig.replace( '.', '/' ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   151
          trans = trans.replace( '.', '/' ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   152
          packageTranslation.put( orig, trans ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   153
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   154
        // Package prefix
02bb8761fcce Initial load
duke
parents:
diff changeset
   155
        else if (lcArg.equals ("pkgprefix"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   156
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
   157
          if (i + 2 >= args.length)
02bb8761fcce Initial load
duke
parents:
diff changeset
   158
            throw new InvalidArgument (args[i]);
02bb8761fcce Initial load
duke
parents:
diff changeset
   159
02bb8761fcce Initial load
duke
parents:
diff changeset
   160
          String type = args[++i];
02bb8761fcce Initial load
duke
parents:
diff changeset
   161
          String pkg = args[++i];
02bb8761fcce Initial load
duke
parents:
diff changeset
   162
          checkPackageNameValid( type ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   163
          checkPackageNameValid( pkg ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   164
          packages.put (type, pkg);
02bb8761fcce Initial load
duke
parents:
diff changeset
   165
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   166
        // Target directory
02bb8761fcce Initial load
duke
parents:
diff changeset
   167
        else if (lcArg.equals ("td"))  // <f46838.4>
02bb8761fcce Initial load
duke
parents:
diff changeset
   168
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
   169
          if (i + 1 >= args.length)
02bb8761fcce Initial load
duke
parents:
diff changeset
   170
            throw new InvalidArgument (args[i]);
02bb8761fcce Initial load
duke
parents:
diff changeset
   171
          String trgtDir = args[++i];
02bb8761fcce Initial load
duke
parents:
diff changeset
   172
          if (trgtDir.charAt (0) == '-')
02bb8761fcce Initial load
duke
parents:
diff changeset
   173
            throw new InvalidArgument (args[i - 1]);
02bb8761fcce Initial load
duke
parents:
diff changeset
   174
          else
02bb8761fcce Initial load
duke
parents:
diff changeset
   175
          {
02bb8761fcce Initial load
duke
parents:
diff changeset
   176
            targetDir = trgtDir.replace ('/', File.separatorChar);
02bb8761fcce Initial load
duke
parents:
diff changeset
   177
            if (targetDir.charAt (targetDir.length () - 1) != File.separatorChar)
02bb8761fcce Initial load
duke
parents:
diff changeset
   178
              targetDir = targetDir + File.separatorChar;
02bb8761fcce Initial load
duke
parents:
diff changeset
   179
          }
02bb8761fcce Initial load
duke
parents:
diff changeset
   180
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   181
        // Separator
02bb8761fcce Initial load
duke
parents:
diff changeset
   182
        else if (lcArg.equals ("sep"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   183
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
   184
          if (i + 1 >= args.length)
02bb8761fcce Initial load
duke
parents:
diff changeset
   185
            throw new InvalidArgument (args[i]);
02bb8761fcce Initial load
duke
parents:
diff changeset
   186
          separator = args[++i];
02bb8761fcce Initial load
duke
parents:
diff changeset
   187
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   188
        // POA flag ?
02bb8761fcce Initial load
duke
parents:
diff changeset
   189
        else if (lcArg.equals ("oldimplbase")){
02bb8761fcce Initial load
duke
parents:
diff changeset
   190
            POAServer = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   191
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   192
        else if (lcArg.equals("skeletonname")){
02bb8761fcce Initial load
duke
parents:
diff changeset
   193
          if (i + 1 >= args.length)
02bb8761fcce Initial load
duke
parents:
diff changeset
   194
            throw new InvalidArgument (args[i]);
02bb8761fcce Initial load
duke
parents:
diff changeset
   195
          skeletonPattern = args[++i];
02bb8761fcce Initial load
duke
parents:
diff changeset
   196
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   197
        else if (lcArg.equals("tiename")){
02bb8761fcce Initial load
duke
parents:
diff changeset
   198
          if (i + 1 >= args.length)
02bb8761fcce Initial load
duke
parents:
diff changeset
   199
            throw new InvalidArgument (args[i]);
02bb8761fcce Initial load
duke
parents:
diff changeset
   200
          tiePattern = args[++i];
02bb8761fcce Initial load
duke
parents:
diff changeset
   201
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   202
        else if (lcArg.equals("localoptimization")) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   203
            LocalOptimization = true;
02bb8761fcce Initial load
duke
parents:
diff changeset
   204
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   205
        else i = collectUnknownArg (args, i, unknownArgs);
02bb8761fcce Initial load
duke
parents:
diff changeset
   206
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
   207
02bb8761fcce Initial load
duke
parents:
diff changeset
   208
      // Encountered unknown arguments?
02bb8761fcce Initial load
duke
parents:
diff changeset
   209
      if (unknownArgs.size () > 0)
02bb8761fcce Initial load
duke
parents:
diff changeset
   210
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
   211
        String [] otherArgs = new String [unknownArgs.size ()];
02bb8761fcce Initial load
duke
parents:
diff changeset
   212
        unknownArgs.copyInto (otherArgs);
02bb8761fcce Initial load
duke
parents:
diff changeset
   213
        // Throws InvalidArgument by default
02bb8761fcce Initial load
duke
parents:
diff changeset
   214
        super.parseOtherArgs (otherArgs, properties);
02bb8761fcce Initial load
duke
parents:
diff changeset
   215
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
   216
02bb8761fcce Initial load
duke
parents:
diff changeset
   217
      setDefaultEmitter(); // d57482 <klr>
02bb8761fcce Initial load
duke
parents:
diff changeset
   218
      setNameModifiers( skeletonPattern, tiePattern ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   219
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   220
    catch (ArrayIndexOutOfBoundsException e)
02bb8761fcce Initial load
duke
parents:
diff changeset
   221
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   222
      // If there is any array indexing problem, it is probably
02bb8761fcce Initial load
duke
parents:
diff changeset
   223
      // because the qualifier on the last argument is missing.
02bb8761fcce Initial load
duke
parents:
diff changeset
   224
      // Report that this last argument is invalid.
02bb8761fcce Initial load
duke
parents:
diff changeset
   225
      throw new InvalidArgument (args[args.length - 1]);
02bb8761fcce Initial load
duke
parents:
diff changeset
   226
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   227
  } // parseOtherArgs
02bb8761fcce Initial load
duke
parents:
diff changeset
   228
02bb8761fcce Initial load
duke
parents:
diff changeset
   229
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   230
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
   231
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   232
  protected int collectUnknownArg (String[] args, int i, Vector unknownArgs)
02bb8761fcce Initial load
duke
parents:
diff changeset
   233
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   234
    unknownArgs.addElement (args [i]);
02bb8761fcce Initial load
duke
parents:
diff changeset
   235
    ++i;
02bb8761fcce Initial load
duke
parents:
diff changeset
   236
    while (i < args.length && args[i].charAt (0) != '-' && args[i].charAt (0) != '/')
02bb8761fcce Initial load
duke
parents:
diff changeset
   237
      unknownArgs.addElement (args[i++]);
02bb8761fcce Initial load
duke
parents:
diff changeset
   238
    return --i;
02bb8761fcce Initial load
duke
parents:
diff changeset
   239
  } // collectUnknownArg
02bb8761fcce Initial load
duke
parents:
diff changeset
   240
02bb8761fcce Initial load
duke
parents:
diff changeset
   241
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   242
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
   243
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   244
  // XXX Either generalize this facility or remove it completely.
02bb8761fcce Initial load
duke
parents:
diff changeset
   245
  protected void packageFromProps (Properties props) throws InvalidArgument
02bb8761fcce Initial load
duke
parents:
diff changeset
   246
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   247
    Enumeration propsEnum = props.propertyNames ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   248
    while (propsEnum.hasMoreElements ())
02bb8761fcce Initial load
duke
parents:
diff changeset
   249
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   250
      String prop = (String)propsEnum.nextElement ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   251
      if (prop.startsWith ("PkgPrefix."))
02bb8761fcce Initial load
duke
parents:
diff changeset
   252
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
   253
        String type = prop.substring (10);
02bb8761fcce Initial load
duke
parents:
diff changeset
   254
        String pkg = props.getProperty (prop);
02bb8761fcce Initial load
duke
parents:
diff changeset
   255
        checkPackageNameValid( pkg ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   256
        checkPackageNameValid( type ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   257
        packages.put (type, pkg);
02bb8761fcce Initial load
duke
parents:
diff changeset
   258
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
   259
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   260
  } // packageFromProps
02bb8761fcce Initial load
duke
parents:
diff changeset
   261
02bb8761fcce Initial load
duke
parents:
diff changeset
   262
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   263
   * d57482 <klr> method added so default emitter check could be overriden.
02bb8761fcce Initial load
duke
parents:
diff changeset
   264
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   265
  protected void setDefaultEmitter () {
02bb8761fcce Initial load
duke
parents:
diff changeset
   266
      // If the flag -fclient was not found, assume it.
02bb8761fcce Initial load
duke
parents:
diff changeset
   267
      if (emit == None) emit = Client;
02bb8761fcce Initial load
duke
parents:
diff changeset
   268
  }
02bb8761fcce Initial load
duke
parents:
diff changeset
   269
02bb8761fcce Initial load
duke
parents:
diff changeset
   270
  protected void setNameModifiers( String skeletonPattern,
02bb8761fcce Initial load
duke
parents:
diff changeset
   271
    String tiePattern ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   272
    if (emit>Client) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   273
        String tp ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   274
        String sp ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   275
02bb8761fcce Initial load
duke
parents:
diff changeset
   276
        if (skeletonPattern != null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   277
            sp = skeletonPattern ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   278
        else if (POAServer)
02bb8761fcce Initial load
duke
parents:
diff changeset
   279
            sp = "%POA" ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   280
        else
02bb8761fcce Initial load
duke
parents:
diff changeset
   281
            sp = "_%ImplBase" ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   282
02bb8761fcce Initial load
duke
parents:
diff changeset
   283
        if (tiePattern != null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   284
            tp = tiePattern ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   285
        else if (POAServer)
02bb8761fcce Initial load
duke
parents:
diff changeset
   286
            tp = "%POATie" ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   287
        else
02bb8761fcce Initial load
duke
parents:
diff changeset
   288
            tp = "%_Tie" ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   289
02bb8761fcce Initial load
duke
parents:
diff changeset
   290
        skeletonNameModifier = new NameModifierImpl( sp ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   291
        tieNameModifier = new NameModifierImpl( tp ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   292
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   293
  }
02bb8761fcce Initial load
duke
parents:
diff changeset
   294
02bb8761fcce Initial load
duke
parents:
diff changeset
   295
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   296
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
   297
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   298
  private void checkPackageNameValid (String name) throws InvalidArgument
02bb8761fcce Initial load
duke
parents:
diff changeset
   299
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   300
    if (name.charAt (0) == '.')
02bb8761fcce Initial load
duke
parents:
diff changeset
   301
      throw new InvalidArgument (name);
02bb8761fcce Initial load
duke
parents:
diff changeset
   302
    for (int i = 0; i < name.length ();++i)
02bb8761fcce Initial load
duke
parents:
diff changeset
   303
      if (name.charAt (i) == '.')
02bb8761fcce Initial load
duke
parents:
diff changeset
   304
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
   305
        if (i == name.length () - 1 || !Character.isJavaIdentifierStart (name.charAt (++i)))
02bb8761fcce Initial load
duke
parents:
diff changeset
   306
          throw new InvalidArgument (name);
02bb8761fcce Initial load
duke
parents:
diff changeset
   307
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
   308
      else if (!Character.isJavaIdentifierPart (name.charAt (i)))
02bb8761fcce Initial load
duke
parents:
diff changeset
   309
        throw new InvalidArgument (name);
02bb8761fcce Initial load
duke
parents:
diff changeset
   310
  } // validatePackageName
02bb8761fcce Initial load
duke
parents:
diff changeset
   311
02bb8761fcce Initial load
duke
parents:
diff changeset
   312
  // <46082.03><46838> Modified access restrictions from protected to public.
02bb8761fcce Initial load
duke
parents:
diff changeset
   313
02bb8761fcce Initial load
duke
parents:
diff changeset
   314
  // This is a hash table whose keys are top-level typenames and
02bb8761fcce Initial load
duke
parents:
diff changeset
   315
  // whose values are the package prefixes to those types.
02bb8761fcce Initial load
duke
parents:
diff changeset
   316
  // For instance, <"CORBA", "org.omg"> is a possible entry.
02bb8761fcce Initial load
duke
parents:
diff changeset
   317
  public Hashtable packages         = new Hashtable ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   318
02bb8761fcce Initial load
duke
parents:
diff changeset
   319
  public    String separator        = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   320
02bb8761fcce Initial load
duke
parents:
diff changeset
   321
  public static final int
02bb8761fcce Initial load
duke
parents:
diff changeset
   322
    None   = 0,
02bb8761fcce Initial load
duke
parents:
diff changeset
   323
    Client = 1,
02bb8761fcce Initial load
duke
parents:
diff changeset
   324
    Server = 2,
02bb8761fcce Initial load
duke
parents:
diff changeset
   325
    All    = 3;
02bb8761fcce Initial load
duke
parents:
diff changeset
   326
  public int       emit              = None;
02bb8761fcce Initial load
duke
parents:
diff changeset
   327
  public boolean   TIEServer         = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   328
  public boolean   POAServer         = true;
02bb8761fcce Initial load
duke
parents:
diff changeset
   329
  // By default we do not generate Locally Optimized stub because of an
02bb8761fcce Initial load
duke
parents:
diff changeset
   330
  // unresolved PI problem. We will generate only if -localOptimization flag
02bb8761fcce Initial load
duke
parents:
diff changeset
   331
  // is passed
02bb8761fcce Initial load
duke
parents:
diff changeset
   332
  public boolean   LocalOptimization = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   333
  public NameModifier skeletonNameModifier   = null ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   334
  public NameModifier tieNameModifier   = null ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   335
02bb8761fcce Initial load
duke
parents:
diff changeset
   336
  // Key is original package name; value is translated package name.
02bb8761fcce Initial load
duke
parents:
diff changeset
   337
  // Note that this translation happens AFTER prefixes are added in the
02bb8761fcce Initial load
duke
parents:
diff changeset
   338
  // packages table.
02bb8761fcce Initial load
duke
parents:
diff changeset
   339
  public Hashtable packageTranslation = new Hashtable() ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   340
02bb8761fcce Initial load
duke
parents:
diff changeset
   341
  public String    targetDir        = "";     // <f46838.4>
02bb8761fcce Initial load
duke
parents:
diff changeset
   342
} // class Arguments