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