/[classpath]/classpath/javax/swing/text/Document.java
ViewVC logotype

Diff of /classpath/javax/swing/text/Document.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by mkoch, Fri Oct 22 18:16:01 2004 UTC revision 1.9 by rabbit78, Sat Apr 23 09:30:31 2005 UTC
# Line 40  package javax.swing.text; Line 40  package javax.swing.text;
40  import javax.swing.event.DocumentListener;  import javax.swing.event.DocumentListener;
41  import javax.swing.event.UndoableEditListener;  import javax.swing.event.UndoableEditListener;
42    
43    /**
44     * A Document is the model that backs up all text components in Swing.
45     * This interface supports different kinds of implementations, from
46     * simple plain text model up to complex styled HTML or RTF models.
47     */
48  public interface Document  public interface Document
49  {  {
50      /**
51       * The key for the property that describes the source of a document.
52       */
53    String StreamDescriptionProperty = "stream";    String StreamDescriptionProperty = "stream";
54    
55      /**
56       * The key for the property that is the title of a document.
57       */
58    String TitleProperty = "title";    String TitleProperty = "title";
59    
60      /**
61       * Adds a {@link DocumentListener} to this document.
62       *
63       * @param listener the DocumentListener to add
64       */
65    void addDocumentListener(DocumentListener listener);    void addDocumentListener(DocumentListener listener);
66    
67      /**
68       * Adds an {@link UndoableEditListener} to this document.
69       *
70       * @param listener the UndoableEditListener to add
71       */
72    void addUndoableEditListener(UndoableEditListener listener);    void addUndoableEditListener(UndoableEditListener listener);
73    
74      /**
75       * Creates a mark in the character content at the specified offset.
76       *
77       * @param offs the offset where to place the mark
78       *
79       * @return the created Position object
80       *
81       * @throws BadLocationException of the specified offset is not a valid
82       *         position in the documents content
83       */
84    Position createPosition(int offs)    Position createPosition(int offs)
85      throws BadLocationException;      throws BadLocationException;
86    
87      /**
88       * Returns the default root element. Views should be using this element
89       * unless other mechanisms for assigning views to element structure is
90       * provided.
91       *
92       * @return the default root element
93       */
94    Element getDefaultRootElement();    Element getDefaultRootElement();
95    
96      /**
97       * Returns the position that marks the end of the document.
98       *
99       * @return the position that marks the end of the document
100       */
101    Position getEndPosition();    Position getEndPosition();
102    
103      /**
104       * Returns the length of the document content.
105       *
106       * @return the length of the document content
107       */
108    int getLength();    int getLength();
109    
110      /**
111       * Returns a document property with the specified key.
112       *
113       * @param key the (non-null) key for the property to fetch
114       *
115       * @return the property for <code>key</code> or null if no such property
116       *         is stored
117       */
118    Object getProperty(Object key);    Object getProperty(Object key);
119    
120      /**
121       * Returns the root elements of the document content.
122       *
123       * @return the root elements of the document content
124       */
125    Element[] getRootElements();    Element[] getRootElements();
126    
127      /**
128       * Returns the position that marks the beginning of the document
129       * content.
130       *
131       * @return the start position
132       */
133    Position getStartPosition();    Position getStartPosition();
134    
135      /**
136       * Returns the textual content starting at <code>offset</code> with
137       * a length of <code>length</code>.
138       *
139       * @param offset the beginning of the text fragment to fetch
140       * @param length the length of the text fragment to fetch
141       *
142       * @return the text fragment starting at <code>offset</code> with
143       *         a length of <code>length</code>
144       *
145       * @throws BadLocationException if <code>offset</code> or <code>length</code>
146       *         are no valid locations in the document content
147       */
148    String getText(int offset, int length)    String getText(int offset, int length)
149      throws BadLocationException;      throws BadLocationException;
150    
151      /**
152       * Fetch the textual content starting at <code>offset</code> with
153       * a length of <code>length</code> and store it in <code>txt</code>.
154       *
155       * @param offset the beginning of the text fragment to fetch
156       * @param length the length of the text fragment to fetch
157       * @param txt the Segment where to store the text fragment
158       *
159       * @throws BadLocationException if <code>offset</code> or <code>length</code>
160       *         are no valid locations in the document content
161       */
162    void getText(int offset, int length, Segment txt)    void getText(int offset, int length, Segment txt)
163      throws BadLocationException;      throws BadLocationException;
164    
165      /**
166       * Inserts a piece of text with an AttributeSet at the specified
167       * <code>offset</code>.
168       *
169       * @param offset the location where to insert the content
170       * @param str the textual content to insert
171       * @param a the Attributes associated with the piece of text
172       *
173       * @throws BadLocationException if <code>offset</code>
174       *         is not a valid location in the document content
175       */
176    void insertString(int offset, String str, AttributeSet a)    void insertString(int offset, String str, AttributeSet a)
177      throws BadLocationException;      throws BadLocationException;
178    
179      /**
180       * Sets a document property.
181       *
182       * @param key the key of the property
183       * @param value the value of the property
184       */
185    void putProperty(Object key, Object value);    void putProperty(Object key, Object value);
186    
187      /**
188       * Removes a piece of content.
189       *
190       * @param offs the location of the fragment to remove
191       * @param len the length of the fragment to remove
192       *
193       * @throws BadLocationException if <code>offs</code> or <code>len</code>
194       *         are no valid locations in the document content
195       */
196    void remove(int offs, int len)    void remove(int offs, int len)
197      throws BadLocationException;      throws BadLocationException;
198    
199      /**
200       * Removes a DocumentListener from this Document.
201       *
202       * @param listener the DocumentListener to remove
203       */
204    void removeDocumentListener(DocumentListener listener);    void removeDocumentListener(DocumentListener listener);
205    
206      /**
207       * Removes an UndoableEditListener from this Document.
208       *
209       * @param listener the UndoableEditListener to remove
210       */
211    void removeUndoableEditListener(UndoableEditListener listener);    void removeUndoableEditListener(UndoableEditListener listener);
212    
213      /**
214       * This allows the Document to be rendered safely. It is made sure that
215       * the Runnable can read the document without any changes while reading.
216       * The Runnable is not allowed to change the Document itself.
217       *
218       * @param r the Runnable that renders the Document
219       */
220    void render(Runnable r);    void render(Runnable r);
221  }  }

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26