01 /*
02 *
03 * Licensed to the Apache Software Foundation (ASF) under one
04 * or more contributor license agreements. See the NOTICE file
05 * distributed with this work for additional information
06 * regarding copyright ownership. The ASF licenses this file
07 * to you under the Apache License, Version 2.0 (the
08 * "License"); you may not use this file except in compliance
09 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 */
21 package org.apache.qpid.management.ui.model;
22
23 /**
24 * Class representing an mbean operation parameter
25 * @author Bhupendra Bhardwaj
26 */
27 public class ParameterData
28 {
29 private String _name;
30 private String _description;
31 private String _type;
32 private Object _value;
33
34 ParameterData(String name, String desc, String type)
35 {
36 this._name = name;
37 this._description = desc;
38 this._type = type;
39 setDefaultValue();
40 }
41
42 public String getDescription()
43 {
44 return _description;
45 }
46
47 public String getName()
48 {
49 return _name;
50 }
51
52 public String getType()
53 {
54 return _type;
55 }
56
57 public Object getValue()
58 {
59 return _value;
60 }
61
62 public void setValueFromString(String strValue)
63 {
64 if ("int".equals(_type))
65 _value = Integer.parseInt(strValue);
66 else if (isBoolean())
67 _value = Boolean.valueOf(strValue);
68 else if ("long".equals(_type))
69 _value = Long.parseLong(strValue);
70 else
71 _value = strValue;
72 }
73
74 public void setValue(Object value)
75 {
76 this._value = value;
77 }
78
79 public boolean isBoolean()
80 {
81 return (_type.equals("boolean") || _type.equals("java.lang.Boolean"));
82 }
83
84 public void setDefaultValue()
85 {
86 if (isBoolean())
87 {
88 _value = Boolean.valueOf("false");
89 }
90 else
91 {
92 _value = null;
93 }
94 }
95 }
|