author | darcy |
Tue, 22 Apr 2014 17:55:25 -0700 | |
changeset 24528 | 21c5bb3d76cc |
parent 24148 | d6e18bb8a7f0 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
23697 | 2 |
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
package javax.swing.text; |
|
26 |
||
27 |
import java.io.*; |
|
28 |
import javax.swing.Action; |
|
29 |
import javax.swing.JEditorPane; |
|
30 |
||
31 |
/** |
|
32 |
* Establishes the set of things needed by a text component |
|
33 |
* to be a reasonably functioning editor for some <em>type</em> |
|
34 |
* of text content. The EditorKit acts as a factory for some |
|
35 |
* kind of policy. For example, an implementation |
|
36 |
* of html and rtf can be provided that is replaceable |
|
37 |
* with other implementations. |
|
38 |
* <p> |
|
39 |
* A kit can safely store editing state as an instance |
|
40 |
* of the kit will be dedicated to a text component. |
|
41 |
* New kits will normally be created by cloning a |
|
24148
d6e18bb8a7f0
7052708: Grammar error in EditorKit documentation
alexsch
parents:
23697
diff
changeset
|
42 |
* prototype kit. The kit will have its |
2 | 43 |
* <code>setComponent</code> method called to establish |
24148
d6e18bb8a7f0
7052708: Grammar error in EditorKit documentation
alexsch
parents:
23697
diff
changeset
|
44 |
* its relationship with a JTextComponent. |
2 | 45 |
* |
46 |
* @author Timothy Prinzing |
|
47 |
*/ |
|
23697 | 48 |
@SuppressWarnings("serial") // Same-version serialization only |
2 | 49 |
public abstract class EditorKit implements Cloneable, Serializable { |
50 |
||
51 |
/** |
|
52 |
* Construct an EditorKit. |
|
53 |
*/ |
|
54 |
public EditorKit() { |
|
55 |
} |
|
56 |
||
57 |
/** |
|
58 |
* Creates a copy of the editor kit. This is implemented |
|
20158
1c5d22e5b898
8025117: [cleanup] Eliminate doclint errors in javax/swing/text classes
yan
parents:
5506
diff
changeset
|
59 |
* to use <code>Object.clone()</code>. If the kit cannot be cloned, |
2 | 60 |
* null is returned. |
61 |
* |
|
62 |
* @return the copy |
|
63 |
*/ |
|
64 |
public Object clone() { |
|
65 |
Object o; |
|
66 |
try { |
|
67 |
o = super.clone(); |
|
68 |
} catch (CloneNotSupportedException cnse) { |
|
69 |
o = null; |
|
70 |
} |
|
71 |
return o; |
|
72 |
} |
|
73 |
||
74 |
/** |
|
75 |
* Called when the kit is being installed into the |
|
76 |
* a JEditorPane. |
|
77 |
* |
|
78 |
* @param c the JEditorPane |
|
79 |
*/ |
|
80 |
public void install(JEditorPane c) { |
|
81 |
} |
|
82 |
||
83 |
/** |
|
84 |
* Called when the kit is being removed from the |
|
85 |
* JEditorPane. This is used to unregister any |
|
86 |
* listeners that were attached. |
|
87 |
* |
|
88 |
* @param c the JEditorPane |
|
89 |
*/ |
|
90 |
public void deinstall(JEditorPane c) { |
|
91 |
} |
|
92 |
||
93 |
/** |
|
94 |
* Gets the MIME type of the data that this |
|
95 |
* kit represents support for. |
|
96 |
* |
|
97 |
* @return the type |
|
98 |
*/ |
|
99 |
public abstract String getContentType(); |
|
100 |
||
101 |
/** |
|
102 |
* Fetches a factory that is suitable for producing |
|
103 |
* views of any models that are produced by this |
|
104 |
* kit. |
|
105 |
* |
|
106 |
* @return the factory |
|
107 |
*/ |
|
108 |
public abstract ViewFactory getViewFactory(); |
|
109 |
||
110 |
/** |
|
111 |
* Fetches the set of commands that can be used |
|
112 |
* on a text component that is using a model and |
|
113 |
* view produced by this kit. |
|
114 |
* |
|
115 |
* @return the set of actions |
|
116 |
*/ |
|
117 |
public abstract Action[] getActions(); |
|
118 |
||
119 |
/** |
|
120 |
* Fetches a caret that can navigate through views |
|
121 |
* produced by the associated ViewFactory. |
|
122 |
* |
|
123 |
* @return the caret |
|
124 |
*/ |
|
125 |
public abstract Caret createCaret(); |
|
126 |
||
127 |
/** |
|
128 |
* Creates an uninitialized text storage model |
|
129 |
* that is appropriate for this type of editor. |
|
130 |
* |
|
131 |
* @return the model |
|
132 |
*/ |
|
133 |
public abstract Document createDefaultDocument(); |
|
134 |
||
135 |
/** |
|
136 |
* Inserts content from the given stream which is expected |
|
137 |
* to be in a format appropriate for this kind of content |
|
138 |
* handler. |
|
139 |
* |
|
140 |
* @param in The stream to read from |
|
141 |
* @param doc The destination for the insertion. |
|
142 |
* @param pos The location in the document to place the |
|
20158
1c5d22e5b898
8025117: [cleanup] Eliminate doclint errors in javax/swing/text classes
yan
parents:
5506
diff
changeset
|
143 |
* content >= 0. |
2 | 144 |
* @exception IOException on any I/O error |
145 |
* @exception BadLocationException if pos represents an invalid |
|
146 |
* location within the document. |
|
147 |
*/ |
|
148 |
public abstract void read(InputStream in, Document doc, int pos) |
|
149 |
throws IOException, BadLocationException; |
|
150 |
||
151 |
/** |
|
152 |
* Writes content from a document to the given stream |
|
153 |
* in a format appropriate for this kind of content handler. |
|
154 |
* |
|
155 |
* @param out The stream to write to |
|
156 |
* @param doc The source for the write. |
|
157 |
* @param pos The location in the document to fetch the |
|
20158
1c5d22e5b898
8025117: [cleanup] Eliminate doclint errors in javax/swing/text classes
yan
parents:
5506
diff
changeset
|
158 |
* content from >= 0. |
1c5d22e5b898
8025117: [cleanup] Eliminate doclint errors in javax/swing/text classes
yan
parents:
5506
diff
changeset
|
159 |
* @param len The amount to write out >= 0. |
2 | 160 |
* @exception IOException on any I/O error |
161 |
* @exception BadLocationException if pos represents an invalid |
|
162 |
* location within the document. |
|
163 |
*/ |
|
164 |
public abstract void write(OutputStream out, Document doc, int pos, int len) |
|
165 |
throws IOException, BadLocationException; |
|
166 |
||
167 |
/** |
|
168 |
* Inserts content from the given stream which is expected |
|
169 |
* to be in a format appropriate for this kind of content |
|
170 |
* handler. |
|
171 |
* <p> |
|
172 |
* Since actual text editing is unicode based, this would |
|
173 |
* generally be the preferred way to read in the data. |
|
174 |
* Some types of content are stored in an 8-bit form however, |
|
175 |
* and will favor the InputStream. |
|
176 |
* |
|
177 |
* @param in The stream to read from |
|
178 |
* @param doc The destination for the insertion. |
|
179 |
* @param pos The location in the document to place the |
|
20158
1c5d22e5b898
8025117: [cleanup] Eliminate doclint errors in javax/swing/text classes
yan
parents:
5506
diff
changeset
|
180 |
* content >= 0. |
2 | 181 |
* @exception IOException on any I/O error |
182 |
* @exception BadLocationException if pos represents an invalid |
|
183 |
* location within the document. |
|
184 |
*/ |
|
185 |
public abstract void read(Reader in, Document doc, int pos) |
|
186 |
throws IOException, BadLocationException; |
|
187 |
||
188 |
/** |
|
189 |
* Writes content from a document to the given stream |
|
190 |
* in a format appropriate for this kind of content handler. |
|
191 |
* <p> |
|
192 |
* Since actual text editing is unicode based, this would |
|
193 |
* generally be the preferred way to write the data. |
|
194 |
* Some types of content are stored in an 8-bit form however, |
|
195 |
* and will favor the OutputStream. |
|
196 |
* |
|
197 |
* @param out The stream to write to |
|
198 |
* @param doc The source for the write. |
|
199 |
* @param pos The location in the document to fetch the |
|
20158
1c5d22e5b898
8025117: [cleanup] Eliminate doclint errors in javax/swing/text classes
yan
parents:
5506
diff
changeset
|
200 |
* content >= 0. |
1c5d22e5b898
8025117: [cleanup] Eliminate doclint errors in javax/swing/text classes
yan
parents:
5506
diff
changeset
|
201 |
* @param len The amount to write out >= 0. |
2 | 202 |
* @exception IOException on any I/O error |
203 |
* @exception BadLocationException if pos represents an invalid |
|
204 |
* location within the document. |
|
205 |
*/ |
|
206 |
public abstract void write(Writer out, Document doc, int pos, int len) |
|
207 |
throws IOException, BadLocationException; |
|
208 |
||
209 |
} |