Source Code Cross Referenced for EditorKit.java in  » 6.0-JDK-Core » swing » javax » swing » text » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » swing » javax.swing.text 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 1997-1999 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025        package javax.swing.text;
026
027        import java.io.*;
028        import javax.swing.Action;
029        import javax.swing.JEditorPane;
030
031        /**
032         * Establishes the set of things needed by a text component
033         * to be a reasonably functioning editor for some <em>type</em>
034         * of text content.  The EditorKit acts as a factory for some
035         * kind of policy.  For example, an implementation 
036         * of html and rtf can be provided that is replaceable 
037         * with other implementations.
038         * <p>
039         * A kit can safely store editing state as an instance
040         * of the kit will be dedicated to a text component.
041         * New kits will normally be created by cloning a 
042         * prototype kit.  The kit will have it's 
043         * <code>setComponent</code> method called to establish
044         * it's relationship with a JTextComponent.
045         *
046         * @author  Timothy Prinzing
047         * @version 1.26 05/05/07
048         */
049        public abstract class EditorKit implements  Cloneable, Serializable {
050
051            /**
052             * Construct an EditorKit.
053             */
054            public EditorKit() {
055            }
056
057            /**
058             * Creates a copy of the editor kit.  This is implemented
059             * to use Object.clone</em>.  If the kit cannot be cloned,
060             * null is returned.
061             *
062             * @return the copy
063             */
064            public Object clone() {
065                Object o;
066                try {
067                    o = super .clone();
068                } catch (CloneNotSupportedException cnse) {
069                    o = null;
070                }
071                return o;
072            }
073
074            /**
075             * Called when the kit is being installed into the
076             * a JEditorPane.  
077             *
078             * @param c the JEditorPane
079             */
080            public void install(JEditorPane c) {
081            }
082
083            /**
084             * Called when the kit is being removed from the
085             * JEditorPane.  This is used to unregister any 
086             * listeners that were attached.
087             *
088             * @param c the JEditorPane
089             */
090            public void deinstall(JEditorPane c) {
091            }
092
093            /**
094             * Gets the MIME type of the data that this
095             * kit represents support for.
096             *
097             * @return the type
098             */
099            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
143             *   content >= 0.
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
158             *   content from >= 0.
159             * @param len The amount to write out >= 0.
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,
165                    int len) 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
180             *   content >= 0.
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
200             *   content >= 0.
201             * @param len The amount to write out >= 0.
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,
207                    int len) throws IOException, BadLocationException;
208
209        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.