src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/LiteralTaglet.java

Sun, 24 Feb 2013 11:36:58 -0800

author
jjg
date
Sun, 24 Feb 2013 11:36:58 -0800
changeset 1606
ccbe7ffdd867
parent 1362
c46e0c9940d6
child 1742
7af0fa419a2b
permissions
-rw-r--r--

7112427: The doclet needs to be able to generate JavaFX documentation.
Reviewed-by: jjg
Contributed-by: jan.valenta@oracle.com

duke@1 1 /*
jjg@1359 2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
ohair@554 7 * published by the Free Software Foundation. Oracle designates this
duke@1 8 * particular file as subject to the "Classpath" exception as provided
ohair@554 9 * by Oracle in the LICENSE file that accompanied this code.
duke@1 10 *
duke@1 11 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 14 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 15 * accompanied this code).
duke@1 16 *
duke@1 17 * You should have received a copy of the GNU General Public License version
duke@1 18 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 20 *
ohair@554 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 22 * or visit www.oracle.com if you need additional information or have any
ohair@554 23 * questions.
duke@1 24 */
duke@1 25 package com.sun.tools.doclets.internal.toolkit.taglets;
duke@1 26
duke@1 27 import java.util.Map;
duke@1 28 import com.sun.javadoc.Tag;
duke@1 29 import com.sun.tools.doclets.Taglet;
duke@1 30
duke@1 31
duke@1 32 /**
duke@1 33 * An inline Taglet used to denote literal text.
duke@1 34 * The enclosed text is interpreted as not containing HTML markup or
duke@1 35 * nested javadoc tags.
duke@1 36 * For example, the text:
duke@1 37 * <blockquote> {@code {@literal a<B>c}} </blockquote>
duke@1 38 * displays as:
duke@1 39 * <blockquote> {@literal a<B>c} </blockquote>
duke@1 40 *
jjg@1359 41 * <p><b>This is NOT part of any supported API.
jjg@1359 42 * If you write code that depends on this, you do so at your own risk.
jjg@1359 43 * This code and its internal interfaces are subject to change or
jjg@1359 44 * deletion without notice.</b>
jjg@1359 45 *
duke@1 46 * @author Scott Seligman
duke@1 47 * @since 1.5
duke@1 48 */
duke@1 49
duke@1 50 public class LiteralTaglet implements Taglet {
duke@1 51
duke@1 52 private static final String NAME = "literal";
duke@1 53
jjg@74 54 public static void register(Map<String,Taglet> map) {
duke@1 55 map.remove(NAME);
duke@1 56 map.put(NAME, new LiteralTaglet());
duke@1 57 }
duke@1 58
duke@1 59 public String getName() {
duke@1 60 return NAME;
duke@1 61 }
duke@1 62
duke@1 63 public String toString(Tag tag) {
duke@1 64 return textToString(tag.text());
duke@1 65 }
duke@1 66
duke@1 67 public String toString(Tag[] tags) { return null; }
duke@1 68
duke@1 69 public boolean inField() { return false; }
duke@1 70
duke@1 71 public boolean inConstructor() { return false; }
duke@1 72
duke@1 73 public boolean inMethod() { return false; }
duke@1 74
duke@1 75 public boolean inOverview() { return false; }
duke@1 76
duke@1 77 public boolean inPackage() { return false; }
duke@1 78
duke@1 79 public boolean inType() { return false; }
duke@1 80
duke@1 81 public boolean isInlineTag() { return true; }
duke@1 82
duke@1 83 /*
duke@1 84 * Replace occurrences of the following characters: < > &
duke@1 85 */
duke@1 86 protected static String textToString(String text) {
jjg@1362 87 StringBuilder buf = new StringBuilder();
duke@1 88 for (int i = 0; i < text.length(); i++) {
duke@1 89 char c = text.charAt(i);
duke@1 90 switch (c) {
duke@1 91 case '<':
duke@1 92 buf.append("&lt;");
duke@1 93 break;
duke@1 94 case '>':
duke@1 95 buf.append("&gt;");
duke@1 96 break;
duke@1 97 case '&':
duke@1 98 buf.append("&amp;");
duke@1 99 break;
duke@1 100 default:
duke@1 101 buf.append(c);
duke@1 102 }
duke@1 103 }
duke@1 104 return buf.toString();
duke@1 105 }
duke@1 106 }

mercurial