1 /* HTMLEditorKit.java --
2 Copyright (C) 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package javax.swing.text.html;
41 import java.io.IOException;
42 import java.io.Reader;
43 import java.io.Serializable;
45 import javax.swing.text.BadLocationException;
46 import javax.swing.text.MutableAttributeSet;
47 import javax.swing.text.StyledEditorKit;
50 * This class is NOT implemented. This file currently holds only
51 * declarations of the two enclosing classes, necessary for testing
52 * the implemented javax.swing.text.html.parser package.
54 * @author No authorship is taken, implement the class and be!
55 * TODO: replace this header after implementing the class.
57 public class HTMLEditorKit
58 extends StyledEditorKit
59 implements Serializable, Cloneable
62 * The abstract HTML parser declaration.
64 public abstract static class Parser
67 * Parse the HTML text, calling various methods of the provided callback
68 * in response to the occurence of the corresponding HTML constructions.
69 * @param reader The reader to read the source HTML from.
70 * @param callback The callback to receive information about the parsed
72 * @param ignoreCharSet If true, the parser ignores all charset information
73 * that may be present in HTML documents.
74 * @throws IOException, normally if the reader throws one.
76 public abstract void parse(Reader reader, ParserCallback callback,
83 * The "hook" that receives all information about the HTML document
84 * structure while parsing it. The methods are invoked by parser
85 * and should be normally overridden.
87 public static class ParserCallback
90 * If the tag does not occurs in the html stream directly, but
91 * is supposed by parser, the tag attribute set contains this additional
92 * attribute, having value Boolean.True.
94 public static final Object IMPLIED = "_implied_";
97 * The parser calls this method after it finishes parsing the document.
100 throws BadLocationException
105 * Handle HTML comment, present in the given position.
106 * @param comment the comment
107 * @position the position of the comment in the text being parsed.
109 public void handleComment(char[] comment, int position)
114 * Notifies about the character sequences, used to separate lines in
115 * this document. The parser calls this method after it finishes
116 * parsing the document, but before flush().
117 * @param end_of_line The "end of line sequence", one of: \r or \n or \r\n.
119 public void handleEndOfLineString(String end_of_line)
124 * The method is called when the HTML closing tag ((like </table>)
125 * is found or if the parser concludes that the one should be present
126 * in the current position.
127 * @param tag The tag being handled
128 * @param position the tag position in the text being parsed.
130 public void handleEndTag(HTML.Tag tag, int position)
136 * @param message The message, explaining the error.
137 * @param position The starting position of the fragment that has caused
138 * the error in the html document being parsed.
140 public void handleError(String message, int position)
145 * Handle the tag with no content, like <br>. The method is
146 * called for the elements that, in accordance with the current DTD,
147 * has an empty content.
148 * @param tag The tag being handled.
149 * @param position The tag position in the text being parsed.
151 public void handleSimpleTag(HTML.Tag tag, MutableAttributeSet attributes,
158 * The method is called when the HTML opening tag ((like <table>)
159 * is found or if the parser concludes that the one should be present
160 * in the current position.
161 * @param tag The tag being handled
162 * @param position The tag position in the text being parsed
164 public void handleStartTag(HTML.Tag tag, MutableAttributeSet attributes,
171 * Handle the text section.
172 * @param text A section text.
173 * @param position The text position in the HTML document text being parsed.
175 public void handleText(char[] text, int position)
181 * Use serialVersionUID (v1.4) for interoperability.
183 private static final long serialVersionUID = 8751997116710384592L;
186 * Default cascading stylesheed file ("default.css").
188 public static final String DEFAULT_CSS = "default.css";
191 * The <b>bold</b> action identifier.
193 public static final String BOLD_ACTION = "html-bold-action";
196 * The <i>italic</i> action identifier.
198 public static final String ITALIC_ACTION = "html-italic-action";
201 * The <font color="#FF0000">color</font> action indentifier
202 * (passing the color as an argument).
204 public static final String COLOR_ACTION = "html-color-action";
207 * The <font size="+1">increase</font> font action identifier.
209 public static final String FONT_CHANGE_BIGGER = "html-font-bigger";
212 * The <font size="-1">decrease</font> font action identifier.
214 public static final String FONT_CHANGE_SMALLER = "html-font-smaller";
217 * Align images at the bottom.
219 public static final String IMG_ALIGN_BOTTOM = "html-image-align-bottom";
222 * Align images at the middle.
224 public static final String IMG_ALIGN_MIDDLE = "html-image-align-middle";
227 * Align images at the top.
229 public static final String IMG_ALIGN_TOP = "html-image-align-top";
232 * Align images at the border.
234 public static final String IMG_BORDER = "html-image-border";
237 * The "logical style" action identifier, passing that style as parameter.
239 public static final String LOGICAL_STYLE_ACTION = "html-logical-style-action";
242 * The "ident paragraph left" action.
244 public static final String PARA_INDENT_LEFT = "html-para-indent-left";
247 * The "ident paragraph right" action.
249 public static final String PARA_INDENT_RIGHT = "html-para-indent-right";