01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19:
20: package org.apache.axis2.util;
21:
22: import java.util.ArrayList;
23:
24: public class CommandLineOption implements CommandLineOptionConstants {
25:
26: private String type;
27: private ArrayList optionValues;
28:
29: public CommandLineOption(String type, String[] values) {
30: setOptionType(type);
31: ArrayList arrayList = new ArrayList(values.length);
32: for (int i = 0; i < values.length; i++) {
33: arrayList.add(values[i]);
34: }
35: this .optionValues = arrayList;
36: }
37:
38: private void setOptionType(String type) {
39: //cater for the long options first
40: if (type.startsWith("--")) {
41: type = type.replaceFirst("--", "");
42: }
43: if (type.startsWith("-")) {
44: type = type.replaceFirst("-", "");
45: }
46:
47: //we do not change the case of the option!
48:
49: this .type = type;
50: }
51:
52: /**
53: * @param type
54: */
55: public CommandLineOption(String type, ArrayList values) {
56: setOptionType(type);
57:
58: if (null != values) {
59: this .optionValues = values;
60: }
61: }
62:
63: /**
64: * @return Returns the type.
65: * @see CommandLineOptionConstants
66: */
67: public String getOptionType() {
68: return type;
69: }
70:
71: /**
72: * @return Returns the optionValues.
73: */
74: public String getOptionValue() {
75: if ((optionValues != null) && (optionValues.size() > 0)) {
76: return (String) optionValues.get(0);
77: } else {
78: return null;
79: }
80: }
81:
82: /**
83: * @return Returns the optionValues.
84: */
85: public ArrayList getOptionValues() {
86: return optionValues;
87: }
88:
89: }
|