src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SearchIndexItem.java
changeset 47216 71c04702a3d5
parent 40511 1b3c502e0bdc
child 50167 cc705c956798
equal deleted inserted replaced
47215:4ebc2e2fb97c 47216:71c04702a3d5
       
     1 /*
       
     2  * Copyright (c) 2015, 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
       
    23  * questions.
       
    24  */
       
    25 
       
    26 package jdk.javadoc.internal.doclets.formats.html;
       
    27 
       
    28 /**
       
    29  * Index item for search.
       
    30  *
       
    31  *  <p><b>This is NOT part of any supported API.
       
    32  *  If you write code that depends on this, you do so at your own risk.
       
    33  *  This code and its internal interfaces are subject to change or
       
    34  *  deletion without notice.</b>
       
    35  */
       
    36 public class SearchIndexItem {
       
    37 
       
    38     private String label = "";
       
    39     private String url = "";
       
    40     private String category = "";
       
    41     private String containingModule = "";
       
    42     private String containingPackage = "";
       
    43     private String containingClass = "";
       
    44     private String holder = "";
       
    45     private String description = "";
       
    46 
       
    47     public void setLabel(String l) {
       
    48         label = l;
       
    49     }
       
    50 
       
    51     public String getLabel() {
       
    52         return label;
       
    53     }
       
    54 
       
    55     public void setUrl(String u) {
       
    56         url = u;
       
    57     }
       
    58 
       
    59     public String getUrl() {
       
    60         return url;
       
    61     }
       
    62 
       
    63     public void setContainingModule(String m) {
       
    64         containingModule = m;
       
    65     }
       
    66 
       
    67     public void setContainingPackage(String p) {
       
    68         containingPackage = p;
       
    69     }
       
    70 
       
    71     public void setContainingClass(String c) {
       
    72         containingClass = c;
       
    73     }
       
    74 
       
    75     public void setCategory(String c) {
       
    76         category = c;
       
    77     }
       
    78 
       
    79     public void setHolder(String h) {
       
    80         holder = h;
       
    81     }
       
    82 
       
    83     public String getHolder() {
       
    84         return holder;
       
    85     }
       
    86 
       
    87     public void setDescription(String d) {
       
    88         description = d;
       
    89     }
       
    90 
       
    91     public String getDescription() {
       
    92         return description;
       
    93     }
       
    94 
       
    95     public String toString() {
       
    96         StringBuilder item = new StringBuilder("");
       
    97         if (category.equals("Modules")) {
       
    98             item.append("{")
       
    99                     .append("\"l\":\"").append(label).append("\"")
       
   100                     .append("}");
       
   101         } else if (category.equals("Packages")) {
       
   102             item.append("{");
       
   103             if (!containingModule.isEmpty()) {
       
   104                 item.append("\"m\":\"").append(containingModule).append("\",");
       
   105             }
       
   106             item.append("\"l\":\"").append(label).append("\"")
       
   107                     .append("}");
       
   108         } else if (category.equals("Types")) {
       
   109             item.append("{")
       
   110                     .append("\"p\":\"").append(containingPackage).append("\",")
       
   111                     .append("\"l\":\"").append(label).append("\"")
       
   112                     .append("}");
       
   113         } else if (category.equals("Members")) {
       
   114             item.append("{")
       
   115                     .append("\"p\":\"").append(containingPackage).append("\",")
       
   116                     .append("\"c\":\"").append(containingClass).append("\",")
       
   117                     .append("\"l\":\"").append(label).append("\"");
       
   118             if (!url.equals("")) {
       
   119                 item.append(",\"url\":\"").append(url).append("\"");
       
   120             }
       
   121             item.append("}");
       
   122         } else {
       
   123             item.append("{")
       
   124                     .append("\"l\":\"").append(label).append("\",")
       
   125                     .append("\"h\":\"").append(holder).append("\",");
       
   126             if (!description.equals("")) {
       
   127                 item.append("\"d\":\"").append(description).append("\",");
       
   128             }
       
   129             item.append("\"u\":\"").append(url).append("\"")
       
   130                     .append("}");
       
   131         }
       
   132         return item.toString();
       
   133     }
       
   134 }