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    
019    package org.apache.commons.modeler;
020    
021    
022    import java.io.Serializable;
023    
024    import javax.management.MBeanParameterInfo;
025    
026    
027    /**
028     * <p>Internal configuration information for a <code>Parameter</code>
029     * descriptor.</p>
030     *
031     * @author Craig R. McClanahan
032     * @version $Revision: 480402 $ $Date: 2006-11-29 05:43:23 +0100 (Wed, 29 Nov 2006) $
033     */
034    
035    public class ParameterInfo extends FeatureInfo implements Serializable {
036        static final long serialVersionUID = 2222796006787664020L;
037        // ----------------------------------------------------------- Constructors
038    
039    
040        /**
041         * Standard zero-arguments constructor.
042         */
043        public ParameterInfo() {
044    
045            super();
046    
047        }
048    
049    
050        /**
051         * Special constructor for setting up parameters programatically.
052         *
053         * @param name Name of this parameter
054         * @param type Java class of this parameter
055         * @param description Description of this parameter
056         */
057        public ParameterInfo(String name, String type, String description) {
058    
059            super();
060            setName(name);
061            setType(type);
062            setDescription(description);
063    
064        }
065    
066    
067        // ----------------------------------------------------- Instance Variables
068    
069    
070        /**
071         * The <code>MBeanParameterInfo</code> object that corresponds
072         * to this <code>ParameterInfo</code> instance.
073         */
074        transient MBeanParameterInfo info = null;
075        protected String type = null;
076    
077        // ------------------------------------------------------------- Properties
078    
079    
080        /**
081         * Override the <code>description</code> property setter.
082         *
083         * @param description The new description
084         */
085        public void setDescription(String description) {
086            super.setDescription(description);
087            this.info = null;
088        }
089    
090    
091        /**
092         * Override the <code>name</code> property setter.
093         *
094         * @param name The new name
095         */
096        public void setName(String name) {
097            super.setName(name);
098            this.info = null;
099        }
100    
101    
102        /**
103         * The fully qualified Java class name of this parameter.
104         */
105        public String getType() {
106            return (this.type);
107        }
108    
109        public void setType(String type) {
110            this.type = type;
111            this.info = null;
112        }
113    
114    
115        // --------------------------------------------------------- Public Methods
116    
117    
118        /**
119         * Create and return a <code>MBeanParameterInfo</code> object that
120         * corresponds to the parameter described by this instance.
121         */
122        public MBeanParameterInfo createParameterInfo() {
123    
124            // Return our cached information (if any)
125            if (info != null)
126                return (info);
127    
128            // Create and return a new information object
129            info = new MBeanParameterInfo
130                (getName(), getType(), getDescription());
131            return (info);
132    
133        }
134    
135    
136        /**
137         * Return a string representation of this parameter descriptor.
138         */
139        public String toString() {
140    
141            StringBuffer sb = new StringBuffer("ParameterInfo[");
142            sb.append("name=");
143            sb.append(name);
144            sb.append(", description=");
145            sb.append(description);
146            sb.append(", type=");
147            sb.append(type);
148            sb.append("]");
149            return (sb.toString());
150    
151        }
152    }