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