< prev index next >

src/java.management/share/classes/javax/management/modelmbean/ModelMBeanInfoSupport.java

Print this page
rev 52881 : 8214971: Replace use of string.equals("") with isEmpty()
Reviewed-by: jlaskey, prappo, lancea, dfuchs, redestad


 350     /**
 351      * Returns a shallow clone of this instance.  Neither the Descriptor nor
 352      * the contained arrays ({@code ModelMBeanAttributeInfo[]} etc) are
 353      * cloned.  This method is chiefly of interest to modify the Descriptor
 354      * of the clone via {@link #setDescriptor setDescriptor} without affecting
 355      * the Descriptor of the original object.
 356      *
 357      * @return a shallow clone of this instance.
 358      */
 359     public Object clone() {
 360         return(new ModelMBeanInfoSupport(this));
 361     }
 362 
 363 
 364     public Descriptor[] getDescriptors(String inDescriptorType)
 365     throws MBeanException, RuntimeOperationsException {
 366         if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
 367             MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
 368         }
 369 
 370         if ((inDescriptorType == null) || (inDescriptorType.equals(""))) {
 371             inDescriptorType = "all";
 372         }
 373 
 374         // if no descriptors of that type, will return empty array
 375         //
 376         final Descriptor[] retList;
 377 
 378         if (inDescriptorType.equalsIgnoreCase(MMB)) {
 379             retList = new Descriptor[] {modelMBeanDescriptor};
 380         } else if (inDescriptorType.equalsIgnoreCase(ATTR)) {
 381             final MBeanAttributeInfo[] attrList = modelMBeanAttributes;
 382             int numAttrs = 0;
 383             if (attrList != null) numAttrs = attrList.length;
 384 
 385             retList = new Descriptor[numAttrs];
 386             for (int i=0; i < numAttrs; i++) {
 387                 retList[i] = (((ModelMBeanAttributeInfo)
 388                     attrList[i]).getDescriptor());
 389             }
 390         } else if (inDescriptorType.equalsIgnoreCase(OPER)) {


 583                 new IllegalArgumentException("Descriptor Type is invalid"),
 584                 "Exception occurred trying to find the descriptors of the MBean");
 585 
 586     }
 587 
 588 
 589 
 590     public void setDescriptor(Descriptor inDescriptor,
 591             String inDescriptorType)
 592             throws MBeanException, RuntimeOperationsException {
 593         final String excMsg =
 594                 "Exception occurred trying to set the descriptors of the MBean";
 595         if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
 596             MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
 597         }
 598 
 599         if (inDescriptor==null) {
 600             inDescriptor = new DescriptorSupport();
 601         }
 602 
 603         if ((inDescriptorType == null) || (inDescriptorType.equals(""))) {
 604             inDescriptorType =
 605                     (String) inDescriptor.getFieldValue("descriptorType");
 606 
 607             if (inDescriptorType == null) {
 608                    MODELMBEAN_LOGGER.log(Level.TRACE,
 609                                 "descriptorType null in both String parameter " +
 610                                 "and Descriptor, defaulting to "+ MMB);
 611                 inDescriptorType = MMB;
 612             }
 613         }
 614 
 615         String inDescriptorName =
 616                 (String) inDescriptor.getFieldValue("name");
 617         if (inDescriptorName == null) {
 618             MODELMBEAN_LOGGER.log(Level.TRACE,
 619                                 "descriptor name null, defaulting to " +
 620                                 this.getClassName());
 621             inDescriptorName = this.getClassName();
 622         }
 623         boolean found = false;




 350     /**
 351      * Returns a shallow clone of this instance.  Neither the Descriptor nor
 352      * the contained arrays ({@code ModelMBeanAttributeInfo[]} etc) are
 353      * cloned.  This method is chiefly of interest to modify the Descriptor
 354      * of the clone via {@link #setDescriptor setDescriptor} without affecting
 355      * the Descriptor of the original object.
 356      *
 357      * @return a shallow clone of this instance.
 358      */
 359     public Object clone() {
 360         return(new ModelMBeanInfoSupport(this));
 361     }
 362 
 363 
 364     public Descriptor[] getDescriptors(String inDescriptorType)
 365     throws MBeanException, RuntimeOperationsException {
 366         if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
 367             MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
 368         }
 369 
 370         if ((inDescriptorType == null) || (inDescriptorType.isEmpty())) {
 371             inDescriptorType = "all";
 372         }
 373 
 374         // if no descriptors of that type, will return empty array
 375         //
 376         final Descriptor[] retList;
 377 
 378         if (inDescriptorType.equalsIgnoreCase(MMB)) {
 379             retList = new Descriptor[] {modelMBeanDescriptor};
 380         } else if (inDescriptorType.equalsIgnoreCase(ATTR)) {
 381             final MBeanAttributeInfo[] attrList = modelMBeanAttributes;
 382             int numAttrs = 0;
 383             if (attrList != null) numAttrs = attrList.length;
 384 
 385             retList = new Descriptor[numAttrs];
 386             for (int i=0; i < numAttrs; i++) {
 387                 retList[i] = (((ModelMBeanAttributeInfo)
 388                     attrList[i]).getDescriptor());
 389             }
 390         } else if (inDescriptorType.equalsIgnoreCase(OPER)) {


 583                 new IllegalArgumentException("Descriptor Type is invalid"),
 584                 "Exception occurred trying to find the descriptors of the MBean");
 585 
 586     }
 587 
 588 
 589 
 590     public void setDescriptor(Descriptor inDescriptor,
 591             String inDescriptorType)
 592             throws MBeanException, RuntimeOperationsException {
 593         final String excMsg =
 594                 "Exception occurred trying to set the descriptors of the MBean";
 595         if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
 596             MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
 597         }
 598 
 599         if (inDescriptor==null) {
 600             inDescriptor = new DescriptorSupport();
 601         }
 602 
 603         if ((inDescriptorType == null) || (inDescriptorType.isEmpty())) {
 604             inDescriptorType =
 605                     (String) inDescriptor.getFieldValue("descriptorType");
 606 
 607             if (inDescriptorType == null) {
 608                    MODELMBEAN_LOGGER.log(Level.TRACE,
 609                                 "descriptorType null in both String parameter " +
 610                                 "and Descriptor, defaulting to "+ MMB);
 611                 inDescriptorType = MMB;
 612             }
 613         }
 614 
 615         String inDescriptorName =
 616                 (String) inDescriptor.getFieldValue("name");
 617         if (inDescriptorName == null) {
 618             MODELMBEAN_LOGGER.log(Level.TRACE,
 619                                 "descriptor name null, defaulting to " +
 620                                 this.getClassName());
 621             inDescriptorName = this.getClassName();
 622         }
 623         boolean found = false;


< prev index next >