2006-08-14 Mark Wielaard <mark@klomp.org>
[official-gcc.git] / libjava / classpath / javax / management / MBeanFeatureInfo.java
blob4f0243e1894b348dd08c5395f6cb344b2cc8c1aa
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)
9 any later version.
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
19 02110-1301 USA.
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
24 combination.
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.Serializable;
42 /**
43 * A general superclass for the description of features
44 * of management beans. This allows the user to access
45 * the feature dynamically, without knowing the details
46 * beforehand. The information is immutable as standard.
47 * Of course, subclasses may change this, but this
48 * behaviour is not recommended.
49 * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
50 * @since 1.5
52 public class MBeanFeatureInfo
53 implements Serializable
56 /**
57 * Compatible with JDK 1.5
59 private static final long serialVersionUID = 3952882688968447265L;
61 /**
62 * A description of the feature in human-readable form.
63 * Subclasses should access this via the {@link #getDescription()}
64 * function rather than using the value directly.
66 * @serial a description of the feature.
68 protected String description;
70 /**
71 * The name of the feature. Subclasses should access this
72 * via the {@link #getName()} function rather than using the
73 * value directly.
75 * @serial the name of the feature.
77 protected String name;
79 /**
80 * The <code>toString()</code> result of this instance.
82 protected transient String string;
84 /**
85 * Constructs a new {@link MBeanFeatureInfo} with the specified
86 * name and description.
88 * @param name the name of the management bean feature.
89 * @param description the description of the feature.
91 public MBeanFeatureInfo(String name, String description)
93 this.name = name;
94 this.description = description;
97 /**
98 * Compares this feature with the supplied object. This
99 * returns true iff the object is an instance of
100 * {@link MBeanFeatureInfo} and {@link Object#equals()}
101 * returns true for a comparison of both the name and
102 * description of this feature with that of the specified
103 * object.
105 * @param obj the object to compare.
106 * @return true if the object is a {@link MBeanFeatureInfo}
107 * instance,
108 * <code>name.equals(object.getName())</code> and
109 * <code>description.equals(object.getDescription</code>.
111 public boolean equals(Object obj)
113 if (obj instanceof MBeanFeatureInfo)
115 MBeanFeatureInfo o = (MBeanFeatureInfo) obj;
116 return ((name == null ?
117 o.getName() == null :
118 name.equals(o.getName())) &&
119 (description == null ?
120 o.getDescription() == null :
121 description.equals(o.getDescription())));
123 else
124 return false;
128 * Returns a description of this feature.
130 * @return a human-readable description.
132 public String getDescription()
134 return description;
138 * Returns the name of this feature.
140 * @return the name of the feature.
142 public String getName()
144 return name;
148 * Returns the hashcode of the feature as
149 * the sum of the hashcodes of its name
150 * and description.
152 * @return the hashcode of this feature.
154 public int hashCode()
156 return (name == null ? -1 : name.hashCode())
157 + (description == null ? -1 : description.hashCode());
161 * <p>
162 * Returns a textual representation of this instance. This
163 * is constructed using the class name
164 * (<code>javax.management.MBeanFeatureInfo</code>) and
165 * the name and description of the feature.
166 * </p>
167 * <p>
168 * As instances of this class are immutable, the return value
169 * is computed just once for each instance and reused
170 * throughout its life.
171 * </p>
173 * @return a @link{java.lang.String} instance representing
174 * the instance in textual form.
176 public String toString()
178 if (string == null)
179 string = getClass().getName()
180 + "[name=" + name
181 + ",desc=" + description
182 + "]";
183 return string;