KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > modeler > ParameterInfo


1 /*
2  * Copyright 1999,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
18 package org.apache.commons.modeler;
19
20
21 import java.io.Serializable JavaDoc;
22
23 import javax.management.MBeanParameterInfo JavaDoc;
24
25
26 /**
27  * <p>Internal configuration information for a <code>Parameter</code>
28  * descriptor.</p>
29  *
30  * @author Craig R. McClanahan
31  * @version $Revision$ $Date: 2005-02-26 05:12:25 -0800 (Sat, 26 Feb 2005) $
32  */

33
34 public class ParameterInfo extends FeatureInfo implements Serializable JavaDoc {
35     static final long serialVersionUID = 2222796006787664020L;
36     // ----------------------------------------------------------- Constructors
37

38
39     /**
40      * Standard zero-arguments constructor.
41      */

42     public ParameterInfo() {
43
44         super();
45
46     }
47
48
49     /**
50      * Special constructor for setting up parameters programatically.
51      *
52      * @param name Name of this parameter
53      * @param type Java class of this parameter
54      * @param description Description of this parameter
55      */

56     public ParameterInfo(String JavaDoc name, String JavaDoc type, String JavaDoc description) {
57
58         super();
59         setName(name);
60         setType(type);
61         setDescription(description);
62
63     }
64
65
66     // ----------------------------------------------------- Instance Variables
67

68
69     /**
70      * The <code>MBeanParameterInfo</code> object that corresponds
71      * to this <code>ParameterInfo</code> instance.
72      */

73     transient MBeanParameterInfo JavaDoc info = null;
74     protected String JavaDoc type = null;
75
76     // ------------------------------------------------------------- Properties
77

78
79     /**
80      * Override the <code>description</code> property setter.
81      *
82      * @param description The new description
83      */

84     public void setDescription(String JavaDoc description) {
85         super.setDescription(description);
86         this.info = null;
87     }
88
89
90     /**
91      * Override the <code>name</code> property setter.
92      *
93      * @param name The new name
94      */

95     public void setName(String JavaDoc name) {
96         super.setName(name);
97         this.info = null;
98     }
99
100
101     /**
102      * The fully qualified Java class name of this parameter.
103      */

104     public String JavaDoc getType() {
105         return (this.type);
106     }
107
108     public void setType(String JavaDoc type) {
109         this.type = type;
110         this.info = null;
111     }
112
113
114     // --------------------------------------------------------- Public Methods
115

116
117     /**
118      * Create and return a <code>MBeanParameterInfo</code> object that
119      * corresponds to the parameter described by this instance.
120      */

121     public MBeanParameterInfo JavaDoc createParameterInfo() {
122
123         // Return our cached information (if any)
124
if (info != null)
125             return (info);
126
127         // Create and return a new information object
128
info = new MBeanParameterInfo JavaDoc
129             (getName(), getType(), getDescription());
130         return (info);
131
132     }
133
134
135     /**
136      * Return a string representation of this parameter descriptor.
137      */

138     public String JavaDoc toString() {
139
140         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("ParameterInfo[");
141         sb.append("name=");
142         sb.append(name);
143         sb.append(", description=");
144         sb.append(description);
145         sb.append(", type=");
146         sb.append(type);
147         sb.append("]");
148         return (sb.toString());
149
150     }
151 }
152
Popular Tags