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 import java.util.ArrayList;
024 import java.util.Iterator;
025 import java.util.List;
026
027 import javax.management.Descriptor;
028
029
030 /**
031 * <p>Convenience base class for <code>AttributeInfo</code>,
032 * <code>ConstructorInfo</code>, and <code>OperationInfo</code> classes
033 * that will be used to collect configuration information for the
034 * <code>ModelMBean</code> beans exposed for management.</p>
035 *
036 * @author Craig R. McClanahan
037 * @version $Revision: 480402 $ $Date: 2006-11-29 05:43:23 +0100 (Wed, 29 Nov 2006) $
038 */
039
040 public class FeatureInfo implements Serializable {
041 static final long serialVersionUID = -911529176124712296L;
042 protected String description = null;
043 protected List fields = new ArrayList();
044 protected String name = null;
045
046 // ------------------------------------------------------------- Properties
047
048
049 /**
050 * The human-readable description of this feature.
051 */
052 public String getDescription() {
053 return (this.description);
054 }
055
056 public void setDescription(String description) {
057 this.description = description;
058 }
059
060
061 /**
062 * The field information for this feature.
063 */
064 public List getFields() {
065 return (fields);
066 }
067
068
069 /**
070 * The name of this feature, which must be unique among features in the
071 * same collection.
072 */
073 public String getName() {
074 return (this.name);
075 }
076
077 public void setName(String name) {
078 this.name = name;
079 }
080
081
082 // --------------------------------------------------------- Public Methods
083
084
085 /**
086 * <p>Add a new field to the fields associated with the
087 * Descriptor that will be created from this metadata.</p>
088 *
089 * @param field The field to be added
090 */
091 public void addField(FieldInfo field) {
092 fields.add(field);
093 }
094
095
096 // ------------------------------------------------------ Protected Methods
097
098
099 /**
100 * <p>Add the name/value fields that have been stored into the
101 * specified <code>Descriptor</code> instance.</p>
102 *
103 * @param descriptor The <code>Descriptor</code> to add fields to
104 */
105 protected void addFields(Descriptor descriptor) {
106
107 Iterator items = getFields().iterator();
108 while (items.hasNext()) {
109 FieldInfo item = (FieldInfo) items.next();
110 descriptor.setField(item.getName(), item.getValue());
111 }
112
113 }
114
115
116 }