MBeanParameterInfo.java 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /* MBeanParameterInfo.java -- Information about an operation's parameters.
  2. Copyright (C) 2006 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package javax.management;
  32. /**
  33. * Describes the parameters of a constructor or operation associated
  34. * with a management bean. The information in this class is immutable
  35. * as standard. Of course, subclasses may change this, but this
  36. * behaviour is not recommended.
  37. *
  38. * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
  39. * @since 1.5
  40. */
  41. public class MBeanParameterInfo
  42. extends MBeanFeatureInfo
  43. implements Cloneable
  44. {
  45. /**
  46. * Compatible with JDK 1.5
  47. */
  48. private static final long serialVersionUID = 7432616882776782338L;
  49. /**
  50. * The type of the parameter, represented by the class name.
  51. */
  52. private String type;
  53. /**
  54. * Constructs a new {@link MBeanParameterInfo} using the specified
  55. * name, description and type.
  56. *
  57. * @param name the name of the attribute.
  58. * @param type the type of the attribute, in the form of its class name.
  59. * @param desc a description of the attribute.
  60. */
  61. public MBeanParameterInfo(String name, String type, String desc)
  62. {
  63. super(name, desc);
  64. this.type = type;
  65. }
  66. /**
  67. * Returns a clone of this instance. The clone is created
  68. * using just the method provided by {@link java.lang.Object}.
  69. * Thus, the clone is just a shallow clone as returned by
  70. * that method, and does not contain any deeper cloning based
  71. * on the subject of this class.
  72. *
  73. * @return a clone of this instance.
  74. * @see java.lang.Cloneable
  75. */
  76. public Object clone()
  77. {
  78. try
  79. {
  80. return super.clone();
  81. }
  82. catch (CloneNotSupportedException e)
  83. {
  84. /* This shouldn't happen; we implement Cloneable */
  85. throw new IllegalStateException("clone() called on " +
  86. "non-cloneable object.");
  87. }
  88. }
  89. /**
  90. * Compares this feature with the supplied object. This returns
  91. * true iff the object is an instance of {@link MBeanParameterInfo},
  92. * {@link Object#equals()} returns true for a comparison of both the
  93. * name and description of this parameter with that of the specified
  94. * object (performed by the superclass), and the type of the two
  95. * instances is equal.
  96. *
  97. * @param obj the object to compare.
  98. * @return true if the object is a {@link MBeanParameterInfo}
  99. * instance,
  100. * <code>name.equals(object.getName())</code>,
  101. * <code>description.equals(object.getDescription())</code>,
  102. * and <code>type.equals(object.getType())</code>.
  103. */
  104. public boolean equals(Object obj)
  105. {
  106. if (!(obj instanceof MBeanParameterInfo))
  107. return false;
  108. if (!(super.equals(obj)))
  109. return false;
  110. MBeanParameterInfo o = (MBeanParameterInfo) obj;
  111. return type.equals(o.getType());
  112. }
  113. /**
  114. * Returns the type of this attribute, in the form of its class name.
  115. *
  116. * @return the type of this attribute.
  117. */
  118. public String getType()
  119. {
  120. return type;
  121. }
  122. /**
  123. * Returns the hashcode of the parameter information as the sum of
  124. * the hashcode of the superclass and the hashcode of the type.
  125. *
  126. * @return the hashcode of the parameter information.
  127. */
  128. public int hashCode()
  129. {
  130. return super.hashCode() + type.hashCode();
  131. }
  132. /**
  133. * <p>
  134. * Returns a textual representation of this instance. This
  135. * is constructed using the class name
  136. * (<code>javax.management.MBeanParameterInfo</code>) along
  137. * with the name, description and type of the parameter.
  138. * </p>
  139. * <p>
  140. * As instances of this class are immutable, the return value
  141. * is computed just once for each instance and reused
  142. * throughout its life.
  143. * </p>
  144. *
  145. * @return a @link{java.lang.String} instance representing
  146. * the instance in textual form.
  147. */
  148. public String toString()
  149. {
  150. if (string == null)
  151. {
  152. super.toString();
  153. string = string.substring(0, string.length() - 1)
  154. + ",type=" + type
  155. + "]";
  156. }
  157. return string;
  158. }
  159. }