author | rriggs |
Fri, 07 Dec 2018 11:51:17 -0500 | |
changeset 52902 | e3398b2e1ab0 |
parent 52695 | 99eb43bc3595 |
permissions | -rw-r--r-- |
33920 | 1 |
/* |
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. |
33920 | 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 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
26 |
package jdk.javadoc.internal.doclets.formats.html; |
33920 | 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 |
||
52695
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
50856
diff
changeset
|
38 |
enum Category { |
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
50856
diff
changeset
|
39 |
MODULES, |
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
50856
diff
changeset
|
40 |
PACKAGES, |
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
50856
diff
changeset
|
41 |
TYPES, |
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
50856
diff
changeset
|
42 |
MEMBERS, |
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
50856
diff
changeset
|
43 |
SEARCH_TAGS |
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
50856
diff
changeset
|
44 |
} |
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
50856
diff
changeset
|
45 |
|
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
50856
diff
changeset
|
46 |
private Category category; |
33920 | 47 |
private String label = ""; |
48 |
private String url = ""; |
|
40511 | 49 |
private String containingModule = ""; |
33920 | 50 |
private String containingPackage = ""; |
51 |
private String containingClass = ""; |
|
52 |
private String holder = ""; |
|
53 |
private String description = ""; |
|
54 |
||
55 |
public void setLabel(String l) { |
|
56 |
label = l; |
|
57 |
} |
|
58 |
||
59 |
public String getLabel() { |
|
60 |
return label; |
|
61 |
} |
|
62 |
||
63 |
public void setUrl(String u) { |
|
64 |
url = u; |
|
65 |
} |
|
66 |
||
67 |
public String getUrl() { |
|
68 |
return url; |
|
69 |
} |
|
70 |
||
40511 | 71 |
public void setContainingModule(String m) { |
72 |
containingModule = m; |
|
73 |
} |
|
74 |
||
33920 | 75 |
public void setContainingPackage(String p) { |
76 |
containingPackage = p; |
|
77 |
} |
|
78 |
||
79 |
public void setContainingClass(String c) { |
|
80 |
containingClass = c; |
|
81 |
} |
|
82 |
||
52695
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
50856
diff
changeset
|
83 |
public void setCategory(Category c) { |
33920 | 84 |
category = c; |
85 |
} |
|
86 |
||
87 |
public void setHolder(String h) { |
|
88 |
holder = h; |
|
89 |
} |
|
90 |
||
91 |
public String getHolder() { |
|
92 |
return holder; |
|
93 |
} |
|
94 |
||
95 |
public void setDescription(String d) { |
|
96 |
description = d; |
|
97 |
} |
|
98 |
||
99 |
public String getDescription() { |
|
100 |
return description; |
|
101 |
} |
|
102 |
||
103 |
public String toString() { |
|
104 |
StringBuilder item = new StringBuilder(""); |
|
52695
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
50856
diff
changeset
|
105 |
switch (category) { |
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
50856
diff
changeset
|
106 |
case MODULES: |
33920 | 107 |
item.append("{") |
108 |
.append("\"l\":\"").append(label).append("\"") |
|
109 |
.append("}"); |
|
52695
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
50856
diff
changeset
|
110 |
break; |
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
50856
diff
changeset
|
111 |
case PACKAGES: |
40511 | 112 |
item.append("{"); |
113 |
if (!containingModule.isEmpty()) { |
|
114 |
item.append("\"m\":\"").append(containingModule).append("\","); |
|
115 |
} |
|
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
116 |
item.append("\"l\":\"").append(label).append("\""); |
52902
e3398b2e1ab0
8214971: Replace use of string.equals("") with isEmpty()
rriggs
parents:
52695
diff
changeset
|
117 |
if (!url.isEmpty()) { |
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
118 |
item.append(",\"url\":\"").append(url).append("\""); |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
119 |
} |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
120 |
item.append("}"); |
52695
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
50856
diff
changeset
|
121 |
break; |
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
50856
diff
changeset
|
122 |
case TYPES: |
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
123 |
item.append("{"); |
52902
e3398b2e1ab0
8214971: Replace use of string.equals("") with isEmpty()
rriggs
parents:
52695
diff
changeset
|
124 |
if (!containingPackage.isEmpty()) { |
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
125 |
item.append("\"p\":\"").append(containingPackage).append("\","); |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
126 |
} |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
127 |
item.append("\"l\":\"").append(label).append("\""); |
52902
e3398b2e1ab0
8214971: Replace use of string.equals("") with isEmpty()
rriggs
parents:
52695
diff
changeset
|
128 |
if (!url.isEmpty()) { |
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
129 |
item.append(",\"url\":\"").append(url).append("\""); |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
130 |
} |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
47216
diff
changeset
|
131 |
item.append("}"); |
52695
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
50856
diff
changeset
|
132 |
break; |
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
50856
diff
changeset
|
133 |
case MEMBERS: |
33920 | 134 |
item.append("{") |
135 |
.append("\"p\":\"").append(containingPackage).append("\",") |
|
136 |
.append("\"c\":\"").append(containingClass).append("\",") |
|
137 |
.append("\"l\":\"").append(label).append("\""); |
|
52902
e3398b2e1ab0
8214971: Replace use of string.equals("") with isEmpty()
rriggs
parents:
52695
diff
changeset
|
138 |
if (!url.isEmpty()) { |
33920 | 139 |
item.append(",\"url\":\"").append(url).append("\""); |
140 |
} |
|
141 |
item.append("}"); |
|
52695
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
50856
diff
changeset
|
142 |
break; |
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
50856
diff
changeset
|
143 |
case SEARCH_TAGS: |
33920 | 144 |
item.append("{") |
145 |
.append("\"l\":\"").append(label).append("\",") |
|
146 |
.append("\"h\":\"").append(holder).append("\","); |
|
52902
e3398b2e1ab0
8214971: Replace use of string.equals("") with isEmpty()
rriggs
parents:
52695
diff
changeset
|
147 |
if (!description.isEmpty()) { |
33920 | 148 |
item.append("\"d\":\"").append(description).append("\","); |
149 |
} |
|
150 |
item.append("\"u\":\"").append(url).append("\"") |
|
151 |
.append("}"); |
|
52695
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
50856
diff
changeset
|
152 |
break; |
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
50856
diff
changeset
|
153 |
default: |
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
50856
diff
changeset
|
154 |
throw new IllegalStateException("category not set"); |
33920 | 155 |
} |
156 |
return item.toString(); |
|
157 |
} |
|
50856
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
158 |
|
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
159 |
/** |
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
160 |
* Get the part of the label after the last dot, or whole label if no dots. |
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
161 |
* |
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
162 |
* @return the simple name |
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
163 |
*/ |
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
164 |
public String getSimpleName() { |
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
165 |
return label.substring(label.lastIndexOf('.') + 1); |
1857ca5aca37
8190876: javadoc search on "java.se" shows "java.se" the last one among other modules
hannesw
parents:
50167
diff
changeset
|
166 |
} |
33920 | 167 |
} |