10
|
1 |
/*
|
14260
|
2 |
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
10
|
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
|
5520
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
10
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
5520
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
10
|
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 |
*
|
5520
|
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.
|
10
|
24 |
*/
|
|
25 |
package com.sun.tools.doclets.internal.toolkit.taglets;
|
|
26 |
|
|
27 |
import java.util.Map;
|
|
28 |
import com.sun.javadoc.Tag;
|
|
29 |
import com.sun.tools.doclets.Taglet;
|
|
30 |
|
|
31 |
|
|
32 |
/**
|
|
33 |
* An inline Taglet used to denote literal text.
|
|
34 |
* The enclosed text is interpreted as not containing HTML markup or
|
|
35 |
* nested javadoc tags.
|
|
36 |
* For example, the text:
|
|
37 |
* <blockquote> {@code {@literal a<B>c}} </blockquote>
|
|
38 |
* displays as:
|
|
39 |
* <blockquote> {@literal a<B>c} </blockquote>
|
|
40 |
*
|
14260
|
41 |
* <p><b>This is NOT part of any supported API.
|
|
42 |
* If you write code that depends on this, you do so at your own risk.
|
|
43 |
* This code and its internal interfaces are subject to change or
|
|
44 |
* deletion without notice.</b>
|
|
45 |
*
|
10
|
46 |
* @author Scott Seligman
|
|
47 |
* @since 1.5
|
|
48 |
*/
|
|
49 |
|
|
50 |
public class LiteralTaglet implements Taglet {
|
|
51 |
|
|
52 |
private static final String NAME = "literal";
|
|
53 |
|
868
|
54 |
public static void register(Map<String,Taglet> map) {
|
10
|
55 |
map.remove(NAME);
|
|
56 |
map.put(NAME, new LiteralTaglet());
|
|
57 |
}
|
|
58 |
|
|
59 |
public String getName() {
|
|
60 |
return NAME;
|
|
61 |
}
|
|
62 |
|
|
63 |
public String toString(Tag tag) {
|
|
64 |
return textToString(tag.text());
|
|
65 |
}
|
|
66 |
|
|
67 |
public String toString(Tag[] tags) { return null; }
|
|
68 |
|
|
69 |
public boolean inField() { return false; }
|
|
70 |
|
|
71 |
public boolean inConstructor() { return false; }
|
|
72 |
|
|
73 |
public boolean inMethod() { return false; }
|
|
74 |
|
|
75 |
public boolean inOverview() { return false; }
|
|
76 |
|
|
77 |
public boolean inPackage() { return false; }
|
|
78 |
|
|
79 |
public boolean inType() { return false; }
|
|
80 |
|
|
81 |
public boolean isInlineTag() { return true; }
|
|
82 |
|
|
83 |
/*
|
|
84 |
* Replace occurrences of the following characters: < > &
|
|
85 |
*/
|
|
86 |
protected static String textToString(String text) {
|
|
87 |
StringBuffer buf = new StringBuffer();
|
|
88 |
for (int i = 0; i < text.length(); i++) {
|
|
89 |
char c = text.charAt(i);
|
|
90 |
switch (c) {
|
|
91 |
case '<':
|
|
92 |
buf.append("<");
|
|
93 |
break;
|
|
94 |
case '>':
|
|
95 |
buf.append(">");
|
|
96 |
break;
|
|
97 |
case '&':
|
|
98 |
buf.append("&");
|
|
99 |
break;
|
|
100 |
default:
|
|
101 |
buf.append(c);
|
|
102 |
}
|
|
103 |
}
|
|
104 |
return buf.toString();
|
|
105 |
}
|
|
106 |
}
|