< prev index next >

src/java.management/share/classes/javax/management/MBeanOperationInfo.java

Print this page


   1 /*
   2  * Copyright (c) 1999, 2013, Oracle and/or its affiliates. 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.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 129                               String type,
 130                               int impact) {
 131         this(name, description, signature, type, impact, (Descriptor) null);
 132     }
 133 
 134     /**
 135      * Constructs an {@code MBeanOperationInfo} object.
 136      *
 137      * @param name The name of the method.
 138      * @param description A human readable description of the operation.
 139      * @param signature {@code MBeanParameterInfo} objects
 140      * describing the parameters(arguments) of the method.  This may be
 141      * null with the same effect as a zero-length array.
 142      * @param type The type of the method's return value.
 143      * @param impact The impact of the method, one of
 144      * {@link #INFO}, {@link #ACTION}, {@link #ACTION_INFO},
 145      * {@link #UNKNOWN}.
 146      * @param descriptor The descriptor for the operation.  This may be null
 147      * which is equivalent to an empty descriptor.
 148      *



 149      * @since 1.6
 150      */
 151     public MBeanOperationInfo(String name,
 152                               String description,
 153                               MBeanParameterInfo[] signature,
 154                               String type,
 155                               int impact,
 156                               Descriptor descriptor) {
 157 
 158         super(name, description, descriptor);
 159 







 160         if (signature == null || signature.length == 0)
 161             signature = MBeanParameterInfo.NO_PARAMS;
 162         else
 163             signature = signature.clone();
 164         this.signature = signature;
 165         this.type = type;
 166         this.impact = impact;
 167         this.arrayGettersSafe =
 168             MBeanInfo.arrayGettersSafe(this.getClass(),
 169                                        MBeanOperationInfo.class);
 170     }
 171 
 172     /**
 173      * <p>Returns a shallow clone of this instance.
 174      * The clone is obtained by simply calling {@code super.clone()},
 175      * thus calling the default native shallow cloning mechanism
 176      * implemented by {@code Object.clone()}.
 177      * No deeper cloning of any internal field is made.</p>
 178      *
 179      * <p>Since this class is immutable, cloning is chiefly of interest


 237             // see getSignature() above.
 238             //
 239             if (signature == null)
 240                 return MBeanParameterInfo.NO_PARAMS;
 241             else return signature;
 242         } else return getSignature();
 243     }
 244 
 245     /**
 246      * Returns the impact of the method, one of
 247      * {@code INFO, ACTION, ACTION_INFO, UNKNOWN}.
 248      *
 249      * @return the impact code.
 250      */
 251     public int getImpact() {
 252         return impact;
 253     }
 254 
 255     @Override
 256     public String toString() {
 257         String impactString;
 258         switch (getImpact()) {
 259         case ACTION: impactString = "action"; break;
 260         case ACTION_INFO: impactString = "action/info"; break;
 261         case INFO: impactString = "info"; break;
 262         case UNKNOWN: impactString = "unknown"; break;
 263         default: impactString = "(" + getImpact() + ")";
 264         }
 265         return getClass().getName() + "[" +
 266             "description=" + getDescription() + ", " +
 267             "name=" + getName() + ", " +
 268             "returnType=" + getReturnType() + ", " +
 269             "signature=" + Arrays.asList(fastGetSignature()) + ", " +
 270             "impact=" + impactString + ", " +
 271             "descriptor=" + getDescriptor() +
 272             "]";
 273     }
 274 
 275     /**
 276      * Compare this MBeanOperationInfo to another.
 277      *
 278      * @param o the object to compare to.
 279      *
 280      * @return true if and only if {@code o} is an MBeanOperationInfo such
 281      * that its {@link #getName()}, {@link #getReturnType()}, {@link
 282      * #getDescription()}, {@link #getImpact()}, {@link #getDescriptor()}
 283      * and {@link #getSignature()} values are equal (not necessarily identical)


   1 /*
   2  * Copyright (c) 1999, 2017, Oracle and/or its affiliates. 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.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 129                               String type,
 130                               int impact) {
 131         this(name, description, signature, type, impact, (Descriptor) null);
 132     }
 133 
 134     /**
 135      * Constructs an {@code MBeanOperationInfo} object.
 136      *
 137      * @param name The name of the method.
 138      * @param description A human readable description of the operation.
 139      * @param signature {@code MBeanParameterInfo} objects
 140      * describing the parameters(arguments) of the method.  This may be
 141      * null with the same effect as a zero-length array.
 142      * @param type The type of the method's return value.
 143      * @param impact The impact of the method, one of
 144      * {@link #INFO}, {@link #ACTION}, {@link #ACTION_INFO},
 145      * {@link #UNKNOWN}.
 146      * @param descriptor The descriptor for the operation.  This may be null
 147      * which is equivalent to an empty descriptor.
 148      *
 149      * @throws IllegalArgumentException if {@code impact} is not one of {@code
 150      * ACTION}, {@code ACTION_INFO}, {@code INFO}, or {@code UNKNOWN}.
 151      *
 152      * @since 1.6
 153      */
 154     public MBeanOperationInfo(String name,
 155                               String description,
 156                               MBeanParameterInfo[] signature,
 157                               String type,
 158                               int impact,
 159                               Descriptor descriptor) {
 160 
 161         super(name, description, descriptor);
 162 
 163         if (impact != ACTION && impact != ACTION_INFO && impact != INFO
 164                 && impact != UNKNOWN) {
 165             throw new IllegalArgumentException("Argument impact can only be "
 166                     + "one of ACTION, ACTION_INFO, "
 167                     + "INFO, or UNKNOWN: " + impact);
 168         }
 169 
 170         if (signature == null || signature.length == 0)
 171             signature = MBeanParameterInfo.NO_PARAMS;
 172         else
 173             signature = signature.clone();
 174         this.signature = signature;
 175         this.type = type;
 176         this.impact = impact;
 177         this.arrayGettersSafe =
 178             MBeanInfo.arrayGettersSafe(this.getClass(),
 179                                        MBeanOperationInfo.class);
 180     }
 181 
 182     /**
 183      * <p>Returns a shallow clone of this instance.
 184      * The clone is obtained by simply calling {@code super.clone()},
 185      * thus calling the default native shallow cloning mechanism
 186      * implemented by {@code Object.clone()}.
 187      * No deeper cloning of any internal field is made.</p>
 188      *
 189      * <p>Since this class is immutable, cloning is chiefly of interest


 247             // see getSignature() above.
 248             //
 249             if (signature == null)
 250                 return MBeanParameterInfo.NO_PARAMS;
 251             else return signature;
 252         } else return getSignature();
 253     }
 254 
 255     /**
 256      * Returns the impact of the method, one of
 257      * {@code INFO, ACTION, ACTION_INFO, UNKNOWN}.
 258      *
 259      * @return the impact code.
 260      */
 261     public int getImpact() {
 262         return impact;
 263     }
 264 
 265     @Override
 266     public String toString() {
 267         String impactString = "";
 268         switch (getImpact()) {
 269         case ACTION: impactString = "action"; break;
 270         case ACTION_INFO: impactString = "action/info"; break;
 271         case INFO: impactString = "info"; break;
 272         case UNKNOWN: impactString = "unknown"; break;

 273         }
 274         return getClass().getName() + "[" +
 275             "description=" + getDescription() + ", " +
 276             "name=" + getName() + ", " +
 277             "returnType=" + getReturnType() + ", " +
 278             "signature=" + Arrays.asList(fastGetSignature()) + ", " +
 279             "impact=" + impactString + ", " +
 280             "descriptor=" + getDescriptor() +
 281             "]";
 282     }
 283 
 284     /**
 285      * Compare this MBeanOperationInfo to another.
 286      *
 287      * @param o the object to compare to.
 288      *
 289      * @return true if and only if {@code o} is an MBeanOperationInfo such
 290      * that its {@link #getName()}, {@link #getReturnType()}, {@link
 291      * #getDescription()}, {@link #getImpact()}, {@link #getDescriptor()}
 292      * and {@link #getSignature()} values are equal (not necessarily identical)


< prev index next >