src/share/jaxws_classes/com/sun/tools/internal/jxc/ap/Options.java

Tue, 06 Mar 2012 16:09:35 -0800

author
ohair
date
Tue, 06 Mar 2012 16:09:35 -0800
changeset 286
f50545b5e2f1
child 368
0989ad8c0860
permissions
-rw-r--r--

7150322: Stop using drop source bundles in jaxws
Reviewed-by: darcy, ohrstrom

     1 /*
     2  * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 package com.sun.tools.internal.jxc.ap;
    28 import java.io.File;
    29 import java.util.ArrayList;
    30 import java.util.List;
    32 import com.sun.tools.internal.xjc.BadCommandLineException;
    34 /**
    35  * This stores the invocation configuration for
    36  * SchemaGenerator
    37  *
    38  * @author Bhakti Mehta
    39  */
    40 public class Options  {
    42     // honor CLASSPATH environment variable, but it will be overrided by -cp
    43     public String classpath = System.getenv("CLASSPATH");
    45     public File targetDir = null;
    47     public File episodeFile = null;
    49     // encoding is not required for JDK5, 6, but JDK 7 javac is much more strict - see issue 6859289
    50     public String encoding = null;
    52     public final List<String> arguments = new ArrayList<String>();
    54     public void parseArguments(String[] args) throws BadCommandLineException {
    55         for (int i = 0 ; i <args.length; i++) {
    56             if (args[i].charAt(0)== '-') {
    57                 int j = parseArgument(args,i);
    58                 if(j==0)
    59                     throw new BadCommandLineException(
    60                             Messages.UNRECOGNIZED_PARAMETER.format(args[i]));
    61                 i += j;
    62             } else {
    63                 arguments.add(args[i]);
    64             }
    65         }
    66     }
    68     private int parseArgument( String[] args, int i ) throws BadCommandLineException {
    69         if (args[i].equals("-d")) {
    70             if (i == args.length - 1)
    71                 throw new BadCommandLineException(
    72                         (Messages.OPERAND_MISSING.format(args[i])));
    73             targetDir = new File(args[++i]);
    74             if( !targetDir.exists() )
    75                 throw new BadCommandLineException(
    76                         Messages.NON_EXISTENT_FILE.format(targetDir));
    77             return 1;
    78         }
    80         if (args[i].equals("-episode")) {
    81             if (i == args.length - 1)
    82                 throw new BadCommandLineException(
    83                         (Messages.OPERAND_MISSING.format(args[i])));
    84             episodeFile = new File(args[++i]);
    85             return 1;
    86         }
    88         if (args[i].equals("-encoding")) {
    89             if (i == args.length - 1)
    90                 throw new BadCommandLineException(
    91                         (Messages.OPERAND_MISSING.format(args[i])));
    92             encoding = args[++i];
    93             return 1;
    94         }
    96         if (args[i].equals("-cp") || args[i].equals("-classpath")) {
    97             if (i == args.length - 1)
    98                 throw new BadCommandLineException(
    99                         (Messages.OPERAND_MISSING.format(args[i])));
   100             classpath = args[++i];
   102             return 1;
   103         }
   105         return 0;
   107     }
   110 }

mercurial