1 /* |
1 /* |
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 package com.sun.tools.doclets.internal.toolkit.taglets; |
25 package com.sun.tools.doclets.internal.toolkit.taglets; |
26 |
26 |
27 import java.util.Map; |
27 import java.util.Map; |
|
28 |
|
29 import com.sun.javadoc.Doc; |
28 import com.sun.javadoc.Tag; |
30 import com.sun.javadoc.Tag; |
29 import com.sun.tools.doclets.Taglet; |
|
30 |
31 |
31 |
32 |
32 /** |
33 /** |
33 * An inline Taglet used to denote literal text. |
34 * An inline Taglet used to denote literal text. |
34 * The enclosed text is interpreted as not containing HTML markup or |
35 * The enclosed text is interpreted as not containing HTML markup or |
45 * |
46 * |
46 * @author Scott Seligman |
47 * @author Scott Seligman |
47 * @since 1.5 |
48 * @since 1.5 |
48 */ |
49 */ |
49 |
50 |
50 public class LiteralTaglet implements Taglet { |
51 public class LiteralTaglet extends BaseInlineTaglet { |
51 |
52 |
52 private static final String NAME = "literal"; |
53 private static final String NAME = "literal"; |
53 |
54 |
54 public static void register(Map<String,Taglet> map) { |
55 public static void register(Map<String, Taglet> map) { |
55 map.remove(NAME); |
56 map.remove(NAME); |
56 map.put(NAME, new LiteralTaglet()); |
57 map.put(NAME, new LiteralTaglet()); |
57 } |
58 } |
58 |
59 |
59 public String getName() { |
60 public String getName() { |
60 return NAME; |
61 return NAME; |
61 } |
62 } |
62 |
63 |
63 public String toString(Tag tag) { |
64 /** |
64 return textToString(tag.text()); |
65 * {@inheritDoc} |
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 */ |
66 */ |
86 protected static String textToString(String text) { |
67 public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) { |
87 StringBuilder buf = new StringBuilder(); |
68 return writer.literalTagOutput(tag); |
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 } |
69 } |
106 } |
70 } |