Save This Page
Home » openjdk-7 » javax » management » [javadoc | source]
    1   /*
    2    * Copyright 1999-2006 Sun Microsystems, Inc.  All Rights Reserved.
    3    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    4    *
    5    * This code is free software; you can redistribute it and/or modify it
    6    * under the terms of the GNU General Public License version 2 only, as
    7    * published by the Free Software Foundation.  Sun designates this
    8    * particular file as subject to the "Classpath" exception as provided
    9    * by Sun in the LICENSE file that accompanied this code.
   10    *
   11    * This code is distributed in the hope that it will be useful, but WITHOUT
   12    * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13    * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14    * version 2 for more details (a copy is included in the LICENSE file that
   15    * accompanied this code).
   16    *
   17    * You should have received a copy of the GNU General Public License version
   18    * 2 along with this work; if not, write to the Free Software Foundation,
   19    * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20    *
   21    * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   22    * CA 95054 USA or visit www.sun.com if you need additional information or
   23    * have any questions.
   24    */
   25   
   26   package javax.management;
   27   
   28   
   29   /**
   30    * Describes an argument of an operation exposed by an MBean.
   31    * Instances of this class are immutable.  Subclasses may be mutable
   32    * but this is not recommended.
   33    *
   34    * @since 1.5
   35    */
   36   public class MBeanParameterInfo extends MBeanFeatureInfo implements Cloneable {
   37   
   38       /* Serial version */
   39       static final long serialVersionUID = 7432616882776782338L;
   40   
   41       /* All zero-length arrays are interchangeable. */
   42       static final MBeanParameterInfo[] NO_PARAMS = new MBeanParameterInfo[0];
   43   
   44       /**
   45        * @serial The type or class name of the data.
   46        */
   47       private final String type;
   48   
   49   
   50       /**
   51        * Constructs an <CODE>MBeanParameterInfo</CODE> object.
   52        *
   53        * @param name The name of the data
   54        * @param type The type or class name of the data
   55        * @param description A human readable description of the data. Optional.
   56        */
   57       public MBeanParameterInfo(String name,
   58                                 String type,
   59                                 String description) {
   60           this(name, type, description, (Descriptor) null);
   61       }
   62   
   63       /**
   64        * Constructs an <CODE>MBeanParameterInfo</CODE> object.
   65        *
   66        * @param name The name of the data
   67        * @param type The type or class name of the data
   68        * @param description A human readable description of the data. Optional.
   69        * @param descriptor The descriptor for the operation.  This may be null
   70        * which is equivalent to an empty descriptor.
   71        *
   72        * @since 1.6
   73        */
   74       public MBeanParameterInfo(String name,
   75                                 String type,
   76                                 String description,
   77                                 Descriptor descriptor) {
   78           super(name, description, descriptor);
   79   
   80           this.type = type;
   81       }
   82   
   83   
   84       /**
   85        * <p>Returns a shallow clone of this instance.
   86        * The clone is obtained by simply calling <tt>super.clone()</tt>,
   87        * thus calling the default native shallow cloning mechanism
   88        * implemented by <tt>Object.clone()</tt>.
   89        * No deeper cloning of any internal field is made.</p>
   90        *
   91        * <p>Since this class is immutable, cloning is chiefly of
   92        * interest to subclasses.</p>
   93        */
   94        public Object clone () {
   95            try {
   96                return super.clone() ;
   97            } catch (CloneNotSupportedException e) {
   98                // should not happen as this class is cloneable
   99                return null;
  100            }
  101        }
  102   
  103       /**
  104        * Returns the type or class name of the data.
  105        *
  106        * @return the type string.
  107        */
  108       public String getType() {
  109           return type;
  110       }
  111   
  112       public String toString() {
  113           return
  114               getClass().getName() + "[" +
  115               "description=" + getDescription() + ", " +
  116               "name=" + getName() + ", " +
  117               "type=" + getType() + ", " +
  118               "descriptor=" + getDescriptor() +
  119               "]";
  120       }
  121   
  122       /**
  123        * Compare this MBeanParameterInfo to another.
  124        *
  125        * @param o the object to compare to.
  126        *
  127        * @return true if and only if <code>o</code> is an MBeanParameterInfo such
  128        * that its {@link #getName()}, {@link #getType()},
  129        * {@link #getDescriptor()}, and {@link
  130        * #getDescription()} values are equal (not necessarily identical)
  131        * to those of this MBeanParameterInfo.
  132        */
  133       public boolean equals(Object o) {
  134           if (o == this)
  135               return true;
  136           if (!(o instanceof MBeanParameterInfo))
  137               return false;
  138           MBeanParameterInfo p = (MBeanParameterInfo) o;
  139           return (p.getName().equals(getName()) &&
  140                   p.getType().equals(getType()) &&
  141                   p.getDescription().equals(getDescription()) &&
  142                   p.getDescriptor().equals(getDescriptor()));
  143       }
  144   
  145       public int hashCode() {
  146           return getName().hashCode() ^ getType().hashCode();
  147       }
  148   }

Save This Page
Home » openjdk-7 » javax » management » [javadoc | source]