KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > ccm > scripts > IR3XMIOptionsManager


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2005 INRIA - USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Tran Huynh (tran.huynh@fr.thalesgroup.com)
23 Contributor(s): Philippe Merle.
24
25 ====================================================================
26 $Id: IR3XMIOptionsManager.java,v 1.2 2005/06/17 15:58:27 merle Exp $
27 ====================================================================*/

28
29 package org.objectweb.ccm.scripts;
30
31 /**
32  * This class analyzes the ir3_xmi's command line options.
33  */

34 public class IR3XMIOptionsManager
35     extends OptionsManager_impl {
36
37     /**
38      * The IR object name.
39      */

40     private java.lang.String JavaDoc objectName_;
41
42     /**
43      * The command name.
44      */

45     private java.lang.String JavaDoc commandName_;
46
47     /**
48      * Constructor.
49      *
50      * @param identation The indentation to use.
51      * @param commandName The command name.
52      */

53     public
54     IR3XMIOptionsManager(java.lang.String JavaDoc indentation,
55                          java.lang.String JavaDoc commandName) {
56     
57         super(indentation);
58
59         addOption(new Option(
60             "-h", 0, "-h Display this help."));
61         addOption(new Option(
62             "-o", 1, "-o <file> Output filename."));
63         addOption(new Option(
64             "-dtd", 1, "-dtd <file> Location of the XMI DTD."));
65
66         objectName_ = "";
67         commandName_ = commandName;
68     }
69
70     /**
71      * This method displays the usage.
72      */

73     public void
74     usage() {
75         System.err.println("usage :");
76         System.err.println(commandName_ + " [options] <ir_object>\n");
77         System.err.println("options :");
78         optionsUsage("");
79     }
80
81     /**
82      * This method analyzes the command line arguments.
83      *
84      * @param cmdline The command line arguments.
85      *
86      * @return The exit error code.
87      */

88     public int
89     analyse(java.lang.String JavaDoc[] cmdline) {
90         int length = cmdline.length;
91
92         if (length < 1) {
93             System.err.println("Missing <ir_object>");
94             usage();
95             return -1;
96         }
97         if (analyseOptions(cmdline, 1) == -1) {
98             return -1;
99         }
100         if (isSet("-h") || cmdline[length - 1].equals("-h")) {
101             usage();
102             return -1;
103         }
104         if (cmdline[length - 1].startsWith("-")) {
105             System.err.println("Invalid <ir_object> : " + cmdline[length - 1]);
106             usage();
107             return -1;
108         }
109       
110         objectName_ = cmdline[length - 1];
111         return 0;
112     }
113
114     /**
115      * This method returns the IR object name.
116      *
117      * @return The IR object name.
118      */

119     public java.lang.String JavaDoc
120     getObjectName() {
121         return objectName_;
122     }
123 }
124
Popular Tags