author | mcimadamore |
Mon, 07 Mar 2011 14:31:50 +0000 | |
changeset 8635 | 383a416a2bdf |
parent 6149 | 48de3564aa13 |
child 34752 | 9c262a013456 |
permissions | -rw-r--r-- |
6149
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
1 |
/* |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
2 |
* Copyright (c) 1996,2010, Oracle and/or its affiliates. All rights reserved. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
4 |
* |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
8 |
* |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
13 |
* accompanied this code). |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
14 |
* |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
18 |
* |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
21 |
* questions. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
22 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
23 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
24 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
25 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
26 |
import java.io.BufferedWriter; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
27 |
import java.io.File; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
28 |
import java.io.IOException; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
29 |
import java.io.Writer; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
30 |
import java.net.URL; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
31 |
import java.text.MessageFormat; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
32 |
import java.util.ResourceBundle; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
33 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
34 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
35 |
* A class to facilitate writing HTML via a stream. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
36 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
37 |
public class HTMLWriter |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
38 |
{ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
39 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
40 |
* Create an HTMLWriter object, using a default doctype for HTML 3.2. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
41 |
* @param out a Writer to which to write the generated HTML |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
42 |
* @throws IOException if there is a problem writing to the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
43 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
44 |
public HTMLWriter(Writer out) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
45 |
this(out, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">"); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
46 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
47 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
48 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
49 |
* Create an HTMLWriter object, using a specifed doctype header. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
50 |
* @param out a Writer to which to write the generated HTML |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
51 |
* @param docType a string containing a doctype header for the HTML to be generetaed |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
52 |
* @throws IOException if there is a problem writing to the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
53 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
54 |
public HTMLWriter(Writer out, String docType) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
55 |
if (out instanceof BufferedWriter) |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
56 |
this.out = (BufferedWriter) out; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
57 |
else |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
58 |
this.out = new BufferedWriter(out); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
59 |
this.out.write(docType); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
60 |
this.out.newLine(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
61 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
62 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
63 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
64 |
* Create an HTMLWriter object, using a specified bundle for localizing messages. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
65 |
* @param out a Writer to which to write the generated HTML |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
66 |
* @param i18n a resource bundle to use to localize messages |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
67 |
* @throws IOException if there is a problem writing to the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
68 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
69 |
public HTMLWriter(Writer out, ResourceBundle i18n) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
70 |
this(out); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
71 |
this.i18n = i18n; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
72 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
73 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
74 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
75 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
76 |
* Create an HTMLWriter object, using a specifed doctype header and |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
77 |
* using a specified bundle for l0calizing messages. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
78 |
* @param out a Writer to which to write the generated HTML |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
79 |
* @param docType a string containing a doctype header for the HTML to be generetaed |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
80 |
* @param i18n a resource bundle to use to localize messages |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
81 |
* @throws IOException if there is a problem writing to the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
82 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
83 |
public HTMLWriter(Writer out, String docType, ResourceBundle i18n) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
84 |
this(out, docType); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
85 |
this.i18n = i18n; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
86 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
87 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
88 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
89 |
* Set the reource bundle to be used for localizing messages. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
90 |
* @param i18n the resource bundle to be used for localizing messages |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
91 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
92 |
public void setResourceBundle(ResourceBundle i18n) { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
93 |
this.i18n = i18n; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
94 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
95 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
96 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
97 |
* Flush the stream, and the underlying output stream. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
98 |
* @throws IOException if there is a problem writing to the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
99 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
100 |
public void flush() throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
101 |
out.flush(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
102 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
103 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
104 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
105 |
* Close the stream, and the underlying output stream. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
106 |
* @throws IOException if there is a problem closing the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
107 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
108 |
public void close() throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
109 |
out.close(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
110 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
111 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
112 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
113 |
* Write a newline to the underlying output stream. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
114 |
* @throws IOException if there is a problem writing to the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
115 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
116 |
public void newLine() throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
117 |
out.newLine(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
118 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
119 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
120 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
121 |
* Start an HTML tag. If a prior tag has been started, it will |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
122 |
* be closed first. Once a tag has been opened, attributes for the |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
123 |
* tag may be written out, followed by body content before finally |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
124 |
* ending the tag. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
125 |
* @param tag the tag to be started |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
126 |
* @throws IOException if there is a problem writing to the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
127 |
* @see #writeAttr |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
128 |
* @see #write |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
129 |
* @see #endTag |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
130 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
131 |
public void startTag(String tag) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
132 |
if (state == IN_TAG) { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
133 |
out.write(">"); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
134 |
state = IN_BODY; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
135 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
136 |
//newLine(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
137 |
out.write("<"); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
138 |
out.write(tag); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
139 |
state = IN_TAG; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
140 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
141 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
142 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
143 |
* Finish an HTML tag. It is expected that a call to endTag will match |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
144 |
* a corresponding earlier call to startTag, but there is no formal check |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
145 |
* for this. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
146 |
* @param tag the tag to be closed. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
147 |
* @throws IOException if there is a problem writing to the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
148 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
149 |
public void endTag(String tag) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
150 |
if (state == IN_TAG) { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
151 |
out.write(">"); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
152 |
state = IN_BODY; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
153 |
out.newLine(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
154 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
155 |
out.write("</"); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
156 |
out.write(tag); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
157 |
out.write(">"); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
158 |
//out.newLine(); // PATCHED, jjg |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
159 |
state = IN_BODY; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
160 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
161 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
162 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
163 |
* Finish an empty element tag, such as a META, BASE or LINK tag. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
164 |
* This is expected to correspond with a startTag. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
165 |
* @param tag the tag which is being closed. this is only useful for |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
166 |
* validation, it is not written out |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
167 |
* @throws IllegalStateException if this call does not follow startTag |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
168 |
* (stream is not currently inside a tag) |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
169 |
* @throws IOException if there is a problem writing to the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
170 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
171 |
public void endEmptyTag(String tag) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
172 |
if (state != IN_TAG) |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
173 |
throw new IllegalStateException(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
174 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
175 |
out.write(">"); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
176 |
state = IN_BODY; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
177 |
out.newLine(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
178 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
179 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
180 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
181 |
* Write an attribute for a tag. A tag must previously have been started. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
182 |
* All tag attributes must be written before any body text is written. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
183 |
* The value will be quoted if necessary when writing it to the underlying |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
184 |
* stream. No check is made that the attribute is valid for the current tag. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
185 |
* @param name the name of the attribute to be written |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
186 |
* @param value the value of the attribute to be written |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
187 |
* @throws IllegalStateException if the stream is not in a state to |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
188 |
* write attributes -- e.g. if this call does not follow startTag or other |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
189 |
* calls of writteAttr |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
190 |
* @throws IOException if there is a problem writing to the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
191 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
192 |
public void writeAttr(String name, String value) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
193 |
if (state != IN_TAG) |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
194 |
throw new IllegalStateException(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
195 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
196 |
out.write(" "); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
197 |
out.write(name); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
198 |
out.write("="); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
199 |
boolean alpha = true; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
200 |
for (int i = 0; i < value.length() && alpha; i++) |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
201 |
alpha = Character.isLetter(value.charAt(i)); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
202 |
if (!alpha) |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
203 |
out.write("\""); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
204 |
out.write(value); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
205 |
if (!alpha) |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
206 |
out.write("\""); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
207 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
208 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
209 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
210 |
* Write an attribute for a tag. A tag must previously have been started. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
211 |
* All tag attributes must be written before any body text is written. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
212 |
* The value will be quoted if necessary when writing it to the underlying |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
213 |
* stream. No check is made that the attribute is valid for the current tag. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
214 |
* @param name the name of the attribute to be written |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
215 |
* @param value the value of the attribute to be written |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
216 |
* @throws IllegalStateException if the stream is not in a state to |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
217 |
* write attributes -- e.g. if this call does not follow startTag or other |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
218 |
* calls of writteAttr |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
219 |
* @throws IOException if there is a problem writing to the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
220 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
221 |
public void writeAttr(String name, int value) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
222 |
writeAttr(name, Integer.toString(value)); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
223 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
224 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
225 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
226 |
* Write a line of text, followed by a newline. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
227 |
* The text will be escaped as necessary. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
228 |
* @param text the text to be written. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
229 |
* @throws IOException if there is a problem closing the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
230 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
231 |
public void writeLine(String text) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
232 |
write(text); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
233 |
out.newLine(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
234 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
235 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
236 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
237 |
* Write body text, escaping it as necessary. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
238 |
* If this call follows a call of startTag, the open tag will be |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
239 |
* closed -- meaning that no more attributes can be written until another |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
240 |
* tag is started. If the text value is null, the current tag will still |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
241 |
* be closed, but no other text will be written. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
242 |
* @param text the text to be written, may be null or zero length. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
243 |
* @throws IOException if there is a problem writing to the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
244 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
245 |
public void write(String text) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
246 |
if (state == IN_TAG) { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
247 |
out.write(">"); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
248 |
state = IN_BODY; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
249 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
250 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
251 |
if (text == null) |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
252 |
return; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
253 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
254 |
// check to see if there are any special characters |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
255 |
boolean specialChars = false; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
256 |
for (int i = 0; i < text.length() && !specialChars; i++) { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
257 |
switch (text.charAt(i)) { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
258 |
case '<': case '>': case '&': |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
259 |
specialChars = true; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
260 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
261 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
262 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
263 |
// if there are special characters write the string character at a time; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
264 |
// otherwise, write it out as is |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
265 |
if (specialChars) { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
266 |
for (int i = 0; i < text.length(); i++) { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
267 |
char c = text.charAt(i); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
268 |
switch (c) { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
269 |
case '<': out.write("<"); break; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
270 |
case '>': out.write(">"); break; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
271 |
case '&': out.write("&"); break; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
272 |
default: out.write(c); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
273 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
274 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
275 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
276 |
else |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
277 |
out.write(text); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
278 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
279 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
280 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
281 |
* Write a basic HTML entity, such as or { . |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
282 |
* @param entity the entity to write |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
283 |
* @throws IOException if there is a problem writing to the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
284 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
285 |
public void writeEntity(String entity) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
286 |
if (state == IN_TAG) { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
287 |
out.write(">"); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
288 |
state = IN_BODY; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
289 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
290 |
out.write(entity); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
291 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
292 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
293 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
294 |
* Write an image tag, using a specified path for the image source attribute. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
295 |
* @param imagePath the path for the image source |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
296 |
* @throws IOException if there is a problem closing the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
297 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
298 |
public void writeImage(String imagePath) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
299 |
startTag(IMAGE); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
300 |
writeAttr(SRC, imagePath); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
301 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
302 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
303 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
304 |
* Write an image tag, using a specified path for the image source attribute. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
305 |
* @param imageURL the url for the image source |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
306 |
* @throws IOException if there is a problem closing the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
307 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
308 |
public void writeImage(URL imageURL) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
309 |
writeImage(imageURL.toString()); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
310 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
311 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
312 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
313 |
* Write a hypertext link. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
314 |
* @param anchor the target for the link |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
315 |
* @param body the body text for the link |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
316 |
* @throws IOException if there is a problem closing the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
317 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
318 |
public void writeLink(String anchor, String body) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
319 |
startTag(A); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
320 |
writeAttr(HREF, anchor); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
321 |
write(body); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
322 |
endTag(A); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
323 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
324 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
325 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
326 |
* Write a hypertext link. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
327 |
* @param file the target for the link |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
328 |
* @param body the body text for the link |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
329 |
* @throws IOException if there is a problem closing the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
330 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
331 |
public void writeLink(File file, String body) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
332 |
startTag(A); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
333 |
StringBuffer sb = new StringBuffer(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
334 |
String path = file.getPath().replace(File.separatorChar, '/'); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
335 |
if (file.isAbsolute() && !path.startsWith("/")) |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
336 |
sb.append('/'); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
337 |
sb.append(path); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
338 |
writeAttr(HREF, sb.toString()); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
339 |
write(body); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
340 |
endTag(A); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
341 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
342 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
343 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
344 |
* Write a hypertext link. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
345 |
* @param file the target and body for the link |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
346 |
* @throws IOException if there is a problem closing the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
347 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
348 |
public void writeLink(File file) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
349 |
writeLink(file, file.getPath()); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
350 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
351 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
352 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
353 |
* Write a hypertext link. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
354 |
* @param url the target for the link |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
355 |
* @param body the body text for the link |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
356 |
* @throws IOException if there is a problem closing the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
357 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
358 |
public void writeLink(URL url, String body) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
359 |
startTag(A); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
360 |
writeAttr(HREF, url.toString()); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
361 |
write(body); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
362 |
endTag(A); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
363 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
364 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
365 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
366 |
* Write the destination marker for a hypertext link. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
367 |
* @param anchor the destination marker for hypertext links |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
368 |
* @param body the body text for the marker |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
369 |
* @throws IOException if there is a problem closing the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
370 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
371 |
public void writeLinkDestination(String anchor, String body) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
372 |
startTag(A); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
373 |
writeAttr(NAME, anchor); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
374 |
write(body); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
375 |
endTag(A); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
376 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
377 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
378 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
379 |
* Write a parameter tag. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
380 |
* @param name the name of the parameter |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
381 |
* @param value the value of the parameter |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
382 |
* @throws IOException if there is a problem closing the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
383 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
384 |
public void writeParam(String name, String value) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
385 |
startTag(PARAM); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
386 |
writeAttr(NAME, name); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
387 |
writeAttr(VALUE, value); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
388 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
389 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
390 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
391 |
* Write a style attribute. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
392 |
* @param value the value for the style atrtribute |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
393 |
* @throws IOException if there is a problem closing the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
394 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
395 |
public void writeStyleAttr(String value) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
396 |
writeAttr(STYLE, value); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
397 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
398 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
399 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
400 |
* Write a localized message, using a specified resource bundle. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
401 |
* @param i18n the resource bundle used to localize the message |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
402 |
* @param key the key for the message to be localized |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
403 |
* @throws IOException if there is a problem closing the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
404 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
405 |
public void write(ResourceBundle i18n, String key) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
406 |
write(getString(i18n, key)); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
407 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
408 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
409 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
410 |
* Write a localized message, using a specified resource bundle. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
411 |
* @param i18n the resource bundle used to localize the message |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
412 |
* @param key the key for the message to be localized |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
413 |
* @param arg an argument to be formatted into the localized message |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
414 |
* @throws IOException if there is a problem closing the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
415 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
416 |
public void write(ResourceBundle i18n, String key, Object arg) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
417 |
write(getString(i18n, key, arg)); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
418 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
419 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
420 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
421 |
* Write a localized message, using a specified resource bundle. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
422 |
* @param i18n the resource bundle used to localize the message |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
423 |
* @param key the key for the message to be localized |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
424 |
* @param args arguments to be formatted into the localized message |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
425 |
* @throws IOException if there is a problem closing the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
426 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
427 |
public void write(ResourceBundle i18n, String key, Object[] args) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
428 |
write(getString(i18n, key, args)); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
429 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
430 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
431 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
432 |
* Write a localized message, using the default resource bundle. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
433 |
* @param key the key for the message to be localized |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
434 |
* @throws IOException if there is a problem closing the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
435 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
436 |
public void writeI18N(String key) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
437 |
write(getString(i18n, key)); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
438 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
439 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
440 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
441 |
* Write a localized message, using the default resource bundle. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
442 |
* @param key the key for the message to be localized |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
443 |
* @param arg an argument to be formatted into the localized message |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
444 |
* @throws IOException if there is a problem closing the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
445 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
446 |
public void writeI18N(String key, Object arg) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
447 |
write(getString(i18n, key, arg)); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
448 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
449 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
450 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
451 |
* Write a localized message, using the default resource bundle. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
452 |
* @param key the key for the message to be localized |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
453 |
* @param args arguments to be formatted into the localized message |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
454 |
* @throws IOException if there is a problem closing the underlying stream |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
455 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
456 |
public void writeI18N(String key, Object[] args) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
457 |
write(getString(i18n, key, args)); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
458 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
459 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
460 |
private String getString(ResourceBundle rb, String key, Object... args) { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
461 |
String s = rb.getString(key); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
462 |
return MessageFormat.format(s, args); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
463 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
464 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
465 |
/** The HTML "a" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
466 |
public static final String A = "a"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
467 |
/** The HTML "align" attribute. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
468 |
public static final String ALIGN = "align"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
469 |
/** The HTML "b" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
470 |
public static final String B = "b"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
471 |
/** The HTML "body" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
472 |
public static final String BODY = "body"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
473 |
/** The HTML "border" attribute. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
474 |
public static final String BORDER = "border"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
475 |
/** The HTML "br" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
476 |
public static final String BR = "br"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
477 |
/** The HTML "class" attribute. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
478 |
public static final String CLASS = "class"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
479 |
/** The HTML "classid" attribute. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
480 |
public static final String CLASSID = "classid"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
481 |
/** The HTML "code" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
482 |
public static final String CODE = "code"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
483 |
/** The HTML "color" attribte. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
484 |
public static final String COLOR = "color"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
485 |
/** The HTML "col" attribute value. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
486 |
public static final String COL = "col"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
487 |
/** The HTML "dd" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
488 |
public static final String DD = "dd"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
489 |
/** The HTML "div" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
490 |
public static final String DIV = "div"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
491 |
/** The HTML "dl" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
492 |
public static final String DL = "dl"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
493 |
/** The HTML "dt" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
494 |
public static final String DT = "dt"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
495 |
/** The HTML "font" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
496 |
public static final String FONT = "font"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
497 |
/** The HTML "h1" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
498 |
public static final String H1 = "h1"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
499 |
/** The HTML "h2" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
500 |
public static final String H2 = "h2"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
501 |
/** The HTML "h3" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
502 |
public static final String H3 = "h3"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
503 |
/** The HTML "h4" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
504 |
public static final String H4 = "h4"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
505 |
/** The HTML "h5" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
506 |
public static final String H5 = "h5"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
507 |
/** The HTML "head" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
508 |
public static final String HEAD = "head"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
509 |
/** The HTML "href" attribute. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
510 |
public static final String HREF = "href"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
511 |
/** The HTML "html" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
512 |
public static final String HTML = "html"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
513 |
/** The HTML "hr" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
514 |
public static final String HR = "hr"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
515 |
/** The HTML "i" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
516 |
public static final String I = "i"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
517 |
/** The HTML "id" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
518 |
public static final String ID = "id"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
519 |
/** The HTML "image" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
520 |
public static final String IMAGE = "image"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
521 |
/** The HTML "left" attribute value. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
522 |
public static final String LEFT = "left"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
523 |
/** The HTML "li" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
524 |
public static final String LI = "li"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
525 |
/** The HTML "link" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
526 |
public static final String LINK = "link"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
527 |
/** The HTML "name" attribute. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
528 |
public static final String NAME = "name"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
529 |
/** The HTML "object" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
530 |
public static final String OBJECT = "object"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
531 |
/** The HTML "p" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
532 |
public static final String PARAM = "param"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
533 |
/** The HTML "param" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
534 |
public static final String P = "p"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
535 |
/** The HTML "rel" attribute value. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
536 |
public static final String REL = "rel"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
537 |
/** The HTML "right" attribute value. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
538 |
public static final String RIGHT = "right"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
539 |
/** The HTML "row" attribute value. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
540 |
public static final String ROW = "row"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
541 |
/** The HTML "script" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
542 |
public static final String SCRIPT = "script"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
543 |
/** The HTML "small" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
544 |
public static final String SMALL = "small"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
545 |
/** The HTML "span" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
546 |
public static final String SPAN = "span"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
547 |
/** The HTML "src" attribute. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
548 |
public static final String SRC = "src"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
549 |
/** The HTML "scope" attribute. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
550 |
public static final String SCOPE = "scope"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
551 |
/** The HTML "style" attribute. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
552 |
public static final String STYLE = "style"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
553 |
/** The HTML "table" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
554 |
public static final String TABLE = "table"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
555 |
/** The HTML "td" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
556 |
public static final String TD = "td"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
557 |
/** The HTML type for JavaScript. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
558 |
public static final String TEXT_JAVASCRIPT = "text/javascript"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
559 |
/** The HTML "title"attribute. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
560 |
public static final String TITLE = "title"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
561 |
/** The HTML "th" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
562 |
public static final String TH = "th"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
563 |
/** The HTML "top" attribute value. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
564 |
public static final String TOP = "top"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
565 |
/** The HTML "tr" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
566 |
public static final String TR = "tr"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
567 |
/** The HTML "type" attribute. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
568 |
public static final String TYPE = "type"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
569 |
/** The HTML "ul" tag. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
570 |
public static final String UL = "ul"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
571 |
/** The HTML "valign" attribute. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
572 |
public static final String VALIGN = "valign"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
573 |
/** The HTML "value" attribute. */ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
574 |
public static final String VALUE = "value"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
575 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
576 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
577 |
private BufferedWriter out; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
578 |
private int state; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
579 |
private ResourceBundle i18n; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
580 |
private static final int IN_TAG = 1; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
581 |
private static final int IN_BODY = 2; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
582 |
} |