src/java.management/share/classes/javax/management/openmbean/CompositeType.java

Print this page
rev 10552 : 8055723[core]: Replace concat String to append in StringBuilder parameters
Contributed-by: Otavio Santana <otaviojava@java.net>


 446      */
 447     public String toString() {
 448 
 449         // Calculate the string representation if it has not yet been done (ie 1st call to toString())
 450         //
 451         if (myToString == null) {
 452             final StringBuilder result = new StringBuilder();
 453             result.append(this.getClass().getName());
 454             result.append("(name=");
 455             result.append(getTypeName());
 456             result.append(",items=(");
 457             int i=0;
 458             Iterator<String> k=nameToType.keySet().iterator();
 459             String key;
 460             while (k.hasNext()) {
 461                 key = k.next();
 462                 if (i > 0) result.append(",");
 463                 result.append("(itemName=");
 464                 result.append(key);
 465                 result.append(",itemType=");
 466                 result.append(nameToType.get(key).toString() +")");
 467                 i++;
 468             }
 469             result.append("))");
 470             myToString = result.toString();
 471         }
 472 
 473         // return always the same string representation for this instance (immutable)
 474         //
 475         return myToString;
 476     }
 477 
 478 }


 446      */
 447     public String toString() {
 448 
 449         // Calculate the string representation if it has not yet been done (ie 1st call to toString())
 450         //
 451         if (myToString == null) {
 452             final StringBuilder result = new StringBuilder();
 453             result.append(this.getClass().getName());
 454             result.append("(name=");
 455             result.append(getTypeName());
 456             result.append(",items=(");
 457             int i=0;
 458             Iterator<String> k=nameToType.keySet().iterator();
 459             String key;
 460             while (k.hasNext()) {
 461                 key = k.next();
 462                 if (i > 0) result.append(",");
 463                 result.append("(itemName=");
 464                 result.append(key);
 465                 result.append(",itemType=");
 466                 result.append(nameToType.get(key)).append(')');
 467                 i++;
 468             }
 469             result.append("))");
 470             myToString = result.toString();
 471         }
 472 
 473         // return always the same string representation for this instance (immutable)
 474         //
 475         return myToString;
 476     }
 477 
 478 }