OSDN Git Service

Imported Classpath 0.18.
[pf3gnuchains/gcc-fork.git] / libjava / classpath / javax / swing / text / html / HTMLEditorKit.java
1 /* HTMLEditorKit.java --
2    Copyright (C) 2005 Free Software Foundation, Inc.
3
4 This file is part of GNU Classpath.
5
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)
9 any later version.
10
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.
15
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
19 02110-1301 USA.
20
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
24 combination.
25
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. */
37
38
39 package javax.swing.text.html;
40
41 import java.io.IOException;
42 import java.io.Reader;
43 import java.io.Serializable;
44
45 import javax.swing.text.BadLocationException;
46 import javax.swing.text.MutableAttributeSet;
47 import javax.swing.text.StyledEditorKit;
48
49 /**
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.
53  *
54  * @author No authorship is taken, implement the class and be!
55  * TODO: replace this header after implementing the class.
56  */
57 public class HTMLEditorKit
58   extends StyledEditorKit
59   implements Serializable, Cloneable
60 {
61   /**
62    * The abstract HTML parser declaration.
63    */
64   public abstract static class Parser
65   {
66     /**
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
71      * HTML structures
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.
75      */
76     public abstract void parse(Reader reader, ParserCallback callback,
77                                boolean ignoreCharSet
78                               )
79                         throws IOException;
80   }
81
82   /**
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.
86    */
87   public static class ParserCallback
88   {
89     /**
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.
93      */
94     public static final Object IMPLIED = "_implied_";
95
96     /**
97      * The parser calls this method after it finishes parsing the document.
98      */
99     public void flush()
100                throws BadLocationException
101     {
102     }
103
104     /**
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.
108      */
109     public void handleComment(char[] comment, int position)
110     {
111     }
112
113     /**
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.
118      */
119     public void handleEndOfLineString(String end_of_line)
120     {
121     }
122
123     /**
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.
129      */
130     public void handleEndTag(HTML.Tag tag, int position)
131     {
132     }
133
134     /**
135      * Handle the error.
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.
139      */
140     public void handleError(String message, int position)
141     {
142     }
143
144     /**
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.
150      */
151     public void handleSimpleTag(HTML.Tag tag, MutableAttributeSet attributes,
152                                 int position
153                                )
154     {
155     }
156
157     /**
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
163      */
164     public void handleStartTag(HTML.Tag tag, MutableAttributeSet attributes,
165                                int position
166                               )
167     {
168     }
169
170     /**
171      * Handle the text section.
172      * @param text A section text.
173      * @param position The text position in the HTML document text being parsed.
174      */
175     public void handleText(char[] text, int position)
176     {
177     }
178   }
179
180   /**
181    * Use serialVersionUID (v1.4) for interoperability.
182    */
183   private static final long serialVersionUID = 8751997116710384592L;
184
185   /**
186    * Default cascading stylesheed file ("default.css").
187    */
188   public static final String DEFAULT_CSS = "default.css";
189
190   /**
191    * The <b>bold</b> action identifier.
192    */
193   public static final String BOLD_ACTION = "html-bold-action";
194
195   /**
196    * The <i>italic</i> action identifier.
197    */
198   public static final String ITALIC_ACTION = "html-italic-action";
199
200   /**
201    * The <font color="#FF0000">color</font> action indentifier
202    * (passing the color as an argument).
203    */
204   public static final String COLOR_ACTION = "html-color-action";
205
206   /**
207    * The <font size="+1">increase</font> font action identifier.
208    */
209   public static final String FONT_CHANGE_BIGGER = "html-font-bigger";
210
211   /**
212    * The <font size="-1">decrease</font> font action identifier.
213    */
214   public static final String FONT_CHANGE_SMALLER = "html-font-smaller";
215
216   /**
217    * Align images at the bottom.
218    */
219   public static final String IMG_ALIGN_BOTTOM = "html-image-align-bottom";
220
221   /**
222    * Align images at the middle.
223    */
224   public static final String IMG_ALIGN_MIDDLE = "html-image-align-middle";
225
226   /**
227    * Align images at the top.
228    */
229   public static final String IMG_ALIGN_TOP = "html-image-align-top";
230
231   /**
232    * Align images at the border.
233    */
234   public static final String IMG_BORDER = "html-image-border";
235
236   /**
237    * The "logical style" action identifier, passing that style as parameter.
238    */
239   public static final String LOGICAL_STYLE_ACTION = "html-logical-style-action";
240
241   /**
242    * The "ident paragraph left" action.
243    */
244   public static final String PARA_INDENT_LEFT = "html-para-indent-left";
245
246   /**
247    * The "ident paragraph right" action.
248    */
249   public static final String PARA_INDENT_RIGHT = "html-para-indent-right";
250 }