KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > wsdl > codegen > CommandLineOption


1 /*
2 * Copyright 2001-2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */

16
17 package org.apache.axis2.wsdl.codegen;
18
19 import java.util.ArrayList JavaDoc;
20
21 /**
22  * @author chathura@opensource.lk
23  *
24  */

25 public class CommandLineOption implements CommandLineOptionConstants {
26
27     private String JavaDoc type;
28     private ArrayList JavaDoc optionValues;
29     private boolean invalid = false;
30
31     public CommandLineOption(String JavaDoc type, String JavaDoc[] values){
32         updateType(type);
33         ArrayList JavaDoc arrayList = new ArrayList JavaDoc(values.length);
34         for(int i =0; i< values.length; i++){
35             arrayList.add(values[i]);
36         }
37         this.optionValues = arrayList;
38     }
39
40     private void updateType(String JavaDoc type) {
41         if (type.startsWith("-")) type = type.replaceFirst("-","");
42         type = type.toLowerCase();
43         this.type = type;
44     }
45
46     /**
47      * @param type
48      */

49     public CommandLineOption(String JavaDoc type, ArrayList JavaDoc values) {
50         updateType(type);
51         this.validate(this.type);
52
53         if (null != values) {
54             this.optionValues = values ;
55         }
56     }
57
58
59         
60
61     /**
62      * @return Returns the type.
63      * @see <code>CommandLineOptionConstans</code>
64      */

65     public String JavaDoc getType() {
66         return type;
67     }
68
69
70     /**
71      * @return Returns the optionValues.
72      */

73     public String JavaDoc getOptionValue() {
74         if (optionValues!=null)
75             return (String JavaDoc)optionValues.get(0);
76         else
77             return null;
78     }
79
80     /**
81      * @return Returns the invalid.
82      */

83     public boolean isInvalid() {
84         return invalid;
85     }
86
87
88     /**
89      * @return Returns the optionValues.
90      */

91     public ArrayList JavaDoc getOptionValues() {
92         return optionValues;
93     }
94
95     private void validate(String JavaDoc optionType){
96         invalid = !((WSDL_LOCATION_URI_OPTION).equalsIgnoreCase(optionType) ||
97             (OUTPUT_LOCATION_OPTION).equalsIgnoreCase(optionType) ||
98             (SERVER_SIDE_CODE_OPTION).equalsIgnoreCase(optionType) ||
99             (CODEGEN_ASYNC_ONLY_OPTION).equalsIgnoreCase(optionType) ||
100             (CODEGEN_SYNC_ONLY_OPTION).equalsIgnoreCase(optionType) ||
101             (PACKAGE_OPTION).equalsIgnoreCase(optionType)||
102             (GENERATE_SERVICE_DESCRIPTION_OPTION).equalsIgnoreCase(optionType)||
103             (GENERATE_TEST_CASE_OPTION).equalsIgnoreCase(optionType)||
104             (STUB_LANGUAGE_OPTION).equalsIgnoreCase(optionType));
105     }
106 }
Popular Tags