1 /* MBeanFeatureInfo.java -- Information about a bean feature.
2 Copyright (C) 2006 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
38 package javax.management;
40 import java.io.IOException;
41 import java.io.ObjectOutputStream;
42 import java.io.Serializable;
45 * A general superclass for the description of features
46 * of management beans. This allows the user to access
47 * the feature dynamically, without knowing the details
48 * beforehand. The information is immutable as standard.
49 * Of course, subclasses may change this, but this
50 * behaviour is not recommended.
51 * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
54 public class MBeanFeatureInfo
55 implements Serializable
59 * Compatible with JDK 1.5
61 private static final long serialVersionUID = 3952882688968447265L;
64 * A description of the feature in human-readable form.
65 * Subclasses should access this via the {@link #getDescription()}
66 * function rather than using the value directly.
68 * @serial a description of the feature.
70 protected String description;
73 * The name of the feature. Subclasses should access this
74 * via the {@link #getName()} function rather than using the
77 * @serial the name of the feature.
79 protected String name;
82 * The <code>toString()</code> result of this instance.
84 transient String string;
87 * Constructs a new {@link MBeanFeatureInfo} with the specified
88 * name and description.
90 * @param name the name of the management bean feature.
91 * @param description the description of the feature.
93 public MBeanFeatureInfo(String name, String description)
96 this.description = description;
100 * Compares this feature with the supplied object. This
101 * returns true iff the object is an instance of
102 * {@link MBeanFeatureInfo} and {@link Object#equals()}
103 * returns true for a comparison of both the name and
104 * description of this feature with that of the specified
107 * @param obj the object to compare.
108 * @return true if the object is a {@link MBeanFeatureInfo}
110 * <code>name.equals(object.getName())</code> and
111 * <code>description.equals(object.getDescription</code>.
113 public boolean equals(Object obj)
115 if (obj instanceof MBeanFeatureInfo)
117 MBeanFeatureInfo o = (MBeanFeatureInfo) obj;
118 return ((name == null ?
119 o.getName() == null :
120 name.equals(o.getName())) &&
121 (description == null ?
122 o.getDescription() == null :
123 description.equals(o.getDescription())));
130 * Returns a description of this feature.
132 * @return a human-readable description.
134 public String getDescription()
140 * Returns the name of this feature.
142 * @return the name of the feature.
144 public String getName()
150 * Returns the hashcode of the feature as
151 * the sum of the hashcodes of its name
154 * @return the hashcode of this feature.
156 public int hashCode()
158 return (name == null ? -1 : name.hashCode())
159 + (description == null ? -1 : description.hashCode());
164 * Returns a textual representation of this instance. This
165 * is constructed using the class name
166 * (<code>javax.management.MBeanFeatureInfo</code>) and
167 * the name and description of the feature.
170 * As instances of this class are immutable, the return value
171 * is computed just once for each instance and reused
172 * throughout its life.
175 * @return a @link{java.lang.String} instance representing
176 * the instance in textual form.
178 public String toString()
181 string = getClass().getName()
183 + ",desc=" + description
189 * Serialize the {@link MBeanFeatureInfo}.
191 * @param out the output stream to write to.
192 * @throws IOException if an I/O error occurs.
194 private void writeObject(ObjectOutputStream out)
197 out.defaultWriteObject();
198 /* FIXME: Handle extra 1.6 descriptor stuff */