< prev index next >

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SearchIndexItem.java

Print this page
rev 52881 : 8214971: Replace use of string.equals("") with isEmpty()


  97     }
  98 
  99     public String getDescription() {
 100         return description;
 101     }
 102 
 103     public String toString() {
 104         StringBuilder item = new StringBuilder("");
 105         switch (category) {
 106         case MODULES:
 107             item.append("{")
 108                     .append("\"l\":\"").append(label).append("\"")
 109                     .append("}");
 110             break;
 111         case PACKAGES:
 112             item.append("{");
 113             if (!containingModule.isEmpty()) {
 114                 item.append("\"m\":\"").append(containingModule).append("\",");
 115             }
 116             item.append("\"l\":\"").append(label).append("\"");
 117             if (!url.equals("")) {
 118                 item.append(",\"url\":\"").append(url).append("\"");
 119             }
 120             item.append("}");
 121             break;
 122         case TYPES:
 123             item.append("{");
 124             if (!containingPackage.equals("")) {
 125                 item.append("\"p\":\"").append(containingPackage).append("\",");
 126             }
 127             item.append("\"l\":\"").append(label).append("\"");
 128             if (!url.equals("")) {
 129                 item.append(",\"url\":\"").append(url).append("\"");
 130             }
 131             item.append("}");
 132             break;
 133         case MEMBERS:
 134             item.append("{")
 135                     .append("\"p\":\"").append(containingPackage).append("\",")
 136                     .append("\"c\":\"").append(containingClass).append("\",")
 137                     .append("\"l\":\"").append(label).append("\"");
 138             if (!url.equals("")) {
 139                 item.append(",\"url\":\"").append(url).append("\"");
 140             }
 141             item.append("}");
 142             break;
 143         case SEARCH_TAGS:
 144             item.append("{")
 145                     .append("\"l\":\"").append(label).append("\",")
 146                     .append("\"h\":\"").append(holder).append("\",");
 147             if (!description.equals("")) {
 148                 item.append("\"d\":\"").append(description).append("\",");
 149             }
 150             item.append("\"u\":\"").append(url).append("\"")
 151                     .append("}");
 152             break;
 153         default:
 154             throw new IllegalStateException("category not set");
 155         }
 156         return item.toString();
 157     }
 158 
 159     /**
 160      * Get the part of the label after the last dot, or whole label if no dots.
 161      *
 162      * @return the simple name
 163      */
 164     public String getSimpleName() {
 165         return label.substring(label.lastIndexOf('.') + 1);
 166     }
 167 }


  97     }
  98 
  99     public String getDescription() {
 100         return description;
 101     }
 102 
 103     public String toString() {
 104         StringBuilder item = new StringBuilder("");
 105         switch (category) {
 106         case MODULES:
 107             item.append("{")
 108                     .append("\"l\":\"").append(label).append("\"")
 109                     .append("}");
 110             break;
 111         case PACKAGES:
 112             item.append("{");
 113             if (!containingModule.isEmpty()) {
 114                 item.append("\"m\":\"").append(containingModule).append("\",");
 115             }
 116             item.append("\"l\":\"").append(label).append("\"");
 117             if (!url.isEmpty()) {
 118                 item.append(",\"url\":\"").append(url).append("\"");
 119             }
 120             item.append("}");
 121             break;
 122         case TYPES:
 123             item.append("{");
 124             if (!containingPackage.isEmpty()) {
 125                 item.append("\"p\":\"").append(containingPackage).append("\",");
 126             }
 127             item.append("\"l\":\"").append(label).append("\"");
 128             if (!url.isEmpty()) {
 129                 item.append(",\"url\":\"").append(url).append("\"");
 130             }
 131             item.append("}");
 132             break;
 133         case MEMBERS:
 134             item.append("{")
 135                     .append("\"p\":\"").append(containingPackage).append("\",")
 136                     .append("\"c\":\"").append(containingClass).append("\",")
 137                     .append("\"l\":\"").append(label).append("\"");
 138             if (!url.isEmpty()) {
 139                 item.append(",\"url\":\"").append(url).append("\"");
 140             }
 141             item.append("}");
 142             break;
 143         case SEARCH_TAGS:
 144             item.append("{")
 145                     .append("\"l\":\"").append(label).append("\",")
 146                     .append("\"h\":\"").append(holder).append("\",");
 147             if (!description.isEmpty()) {
 148                 item.append("\"d\":\"").append(description).append("\",");
 149             }
 150             item.append("\"u\":\"").append(url).append("\"")
 151                     .append("}");
 152             break;
 153         default:
 154             throw new IllegalStateException("category not set");
 155         }
 156         return item.toString();
 157     }
 158 
 159     /**
 160      * Get the part of the label after the last dot, or whole label if no dots.
 161      *
 162      * @return the simple name
 163      */
 164     public String getSimpleName() {
 165         return label.substring(label.lastIndexOf('.') + 1);
 166     }
 167 }
< prev index next >