View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  
19  package org.apache.commons.modeler;
20  
21  
22  import java.io.Serializable;
23  import java.util.ArrayList;
24  import java.util.Iterator;
25  import java.util.List;
26  
27  import javax.management.Descriptor;
28  
29  
30  /***
31   * <p>Convenience base class for <code>AttributeInfo</code>,
32   * <code>ConstructorInfo</code>, and <code>OperationInfo</code> classes
33   * that will be used to collect configuration information for the
34   * <code>ModelMBean</code> beans exposed for management.</p>
35   *
36   * @author Craig R. McClanahan
37   * @version $Revision: 480402 $ $Date: 2006-11-29 04:43:23 +0000 (Wed, 29 Nov 2006) $
38   */
39  
40  public class FeatureInfo implements Serializable {
41      static final long serialVersionUID = -911529176124712296L;
42      protected String description = null;
43      protected List fields = new ArrayList();
44      protected String name = null;
45  
46      // ------------------------------------------------------------- Properties
47  
48  
49      /***
50       * The human-readable description of this feature.
51       */
52      public String getDescription() {
53          return (this.description);
54      }
55  
56      public void setDescription(String description) {
57          this.description = description;
58      }
59  
60  
61      /***
62       * The field information for this feature.
63       */
64      public List getFields() {
65          return (fields);
66      }
67  
68  
69      /***
70       * The name of this feature, which must be unique among features in the
71       * same collection.
72       */
73      public String getName() {
74          return (this.name);
75      }
76  
77      public void setName(String name) {
78          this.name = name;
79      }
80  
81  
82      // --------------------------------------------------------- Public Methods
83  
84  
85      /***
86       * <p>Add a new field to the fields associated with the
87       * Descriptor that will be created from this metadata.</p>
88       *
89       * @param field The field to be added
90       */
91      public void addField(FieldInfo field) {
92          fields.add(field);
93      }
94  
95  
96      // ------------------------------------------------------ Protected Methods
97  
98  
99      /***
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 }