001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.commons.modeler;
019:
020: import java.io.Serializable;
021:
022: import javax.management.MBeanParameterInfo;
023:
024: /**
025: * <p>Internal configuration information for a <code>Parameter</code>
026: * descriptor.</p>
027: *
028: * @author Craig R. McClanahan
029: * @version $Revision: 480402 $ $Date: 2006-11-29 04:43:23 +0000 (Wed, 29 Nov 2006) $
030: */
031:
032: public class ParameterInfo extends FeatureInfo implements Serializable {
033: static final long serialVersionUID = 2222796006787664020L;
034:
035: // ----------------------------------------------------------- Constructors
036:
037: /**
038: * Standard zero-arguments constructor.
039: */
040: public ParameterInfo() {
041:
042: super ();
043:
044: }
045:
046: /**
047: * Special constructor for setting up parameters programatically.
048: *
049: * @param name Name of this parameter
050: * @param type Java class of this parameter
051: * @param description Description of this parameter
052: */
053: public ParameterInfo(String name, String type, String description) {
054:
055: super ();
056: setName(name);
057: setType(type);
058: setDescription(description);
059:
060: }
061:
062: // ----------------------------------------------------- Instance Variables
063:
064: /**
065: * The <code>MBeanParameterInfo</code> object that corresponds
066: * to this <code>ParameterInfo</code> instance.
067: */
068: transient MBeanParameterInfo info = null;
069: protected String type = null;
070:
071: // ------------------------------------------------------------- Properties
072:
073: /**
074: * Override the <code>description</code> property setter.
075: *
076: * @param description The new description
077: */
078: public void setDescription(String description) {
079: super .setDescription(description);
080: this .info = null;
081: }
082:
083: /**
084: * Override the <code>name</code> property setter.
085: *
086: * @param name The new name
087: */
088: public void setName(String name) {
089: super .setName(name);
090: this .info = null;
091: }
092:
093: /**
094: * The fully qualified Java class name of this parameter.
095: */
096: public String getType() {
097: return (this .type);
098: }
099:
100: public void setType(String type) {
101: this .type = type;
102: this .info = null;
103: }
104:
105: // --------------------------------------------------------- Public Methods
106:
107: /**
108: * Create and return a <code>MBeanParameterInfo</code> object that
109: * corresponds to the parameter described by this instance.
110: */
111: public MBeanParameterInfo createParameterInfo() {
112:
113: // Return our cached information (if any)
114: if (info != null)
115: return (info);
116:
117: // Create and return a new information object
118: info = new MBeanParameterInfo(getName(), getType(),
119: getDescription());
120: return (info);
121:
122: }
123:
124: /**
125: * Return a string representation of this parameter descriptor.
126: */
127: public String toString() {
128:
129: StringBuffer sb = new StringBuffer("ParameterInfo[");
130: sb.append("name=");
131: sb.append(name);
132: sb.append(", description=");
133: sb.append(description);
134: sb.append(", type=");
135: sb.append(type);
136: sb.append("]");
137: return (sb.toString());
138:
139: }
140: }
|