KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > text > IDocumentExtension4


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jface.text;
12
13 /**
14  * Extension interface for {@link org.eclipse.jface.text.IDocument}. It adds the
15  * following concepts:
16  * <ul>
17  * <li>Rewrite sessions. A rewrite session is a sequence of replace operations
18  * that form a semantic unit.</li>
19  * <li>A modification stamp on the document</li>
20  * <li>The ability to set the initial line delimiter and to query the default
21  * line delimiter</li>
22  * </ul>
23  *
24  * @since 3.1
25  */

26 public interface IDocumentExtension4 {
27
28     /**
29      * Tells the document that it is about to be rewritten. That is, a sequence
30      * of replace operations that form a semantic unit will be performed on this
31      * document. A specification of the nature of the operation sequence is
32      * given in form of the session type.
33      * <p>
34      * The document is considered being in rewrite mode as long as
35      * <code>stopRewriteSession</code> has not been called.
36      *
37      * @param sessionType the session type
38      * @return the started rewrite session
39      * @throws IllegalStateException in case there is already an active rewrite session
40      */

41     DocumentRewriteSession startRewriteSession(DocumentRewriteSessionType sessionType) throws IllegalStateException JavaDoc;
42
43     /**
44      * Tells the document to stop the rewrite session. This method has only any
45      * effect if <code>startRewriteSession</code> has been called before.
46      * <p>
47      * This method does not have any effect if the given session is not the
48      * active rewrite session.
49      *
50      * @param session the session to stop
51      */

52     void stopRewriteSession(DocumentRewriteSession session);
53
54     /**
55      * Returns the active rewrite session of this document or <code>null</code>.
56      *
57      * @return the active rewrite session or <code>null</code>
58      */

59     DocumentRewriteSession getActiveRewriteSession();
60
61     /**
62      * Registers the document rewrite session listener with the document. After
63      * registration the <code>IDocumentRewriteSessionListener</code> is
64      * informed about each state change of rewrite sessions performed on this
65      * document.
66      * <p>
67      * If the listener is already registered nothing happens.
68      * <p>
69      * An <code>IRewriteSessionDocumentListener</code> may call back to this
70      * document when being inside a document notification.
71      *
72      * @param listener the listener to be registered
73      */

74     void addDocumentRewriteSessionListener(IDocumentRewriteSessionListener listener);
75
76     /**
77      * Removes the listener from the document's list of document rewrite session
78      * listeners. If the listener is not registered with the document nothing
79      * happens.
80      * <p>
81      * An <code>IDocumentRewriteSessionListener</code> may call back to this
82      * document when being inside a document notification.
83      *
84      * @param listener the listener to be removed
85      */

86     void removeDocumentRewriteSessionListener(IDocumentRewriteSessionListener listener);
87
88     /**
89      * Substitutes the given text for the specified document range.
90      * Sends a <code>DocumentEvent</code> to all registered <code>IDocumentListener</code>.
91      *
92      * @param offset the document offset
93      * @param length the length of the specified range
94      * @param text the substitution text
95      * @param modificationStamp of the document after replacing
96      * @exception BadLocationException if the offset is invalid in this document
97      *
98      * @see DocumentEvent
99      * @see IDocumentListener
100      */

101     void replace(int offset, int length, String JavaDoc text, long modificationStamp) throws BadLocationException;
102
103     /**
104      * Replaces the content of the document with the given text.
105      * Sends a <code>DocumentEvent</code> to all registered <code>IDocumentListener</code>.
106      * This method is a convenience method for <code>replace(0, getLength(), text)</code>.
107      *
108      * @param text the new content of the document
109      * @param modificationStamp of the document after setting the content
110      *
111      * @see DocumentEvent
112      * @see IDocumentListener
113      */

114     void set(String JavaDoc text, long modificationStamp);
115
116     /**
117      * The unknown modification stamp.
118      */

119     long UNKNOWN_MODIFICATION_STAMP= -1;
120
121     /**
122      * Returns the modification stamp of this document. The modification stamp
123      * is updated each time a modifying operation is called on this document. If
124      * two modification stamps of the same document are identical then the document
125      * content is too, however, same content does not imply same modification stamp.
126      * <p>
127      * The magnitude or sign of the numerical difference between two modification stamps
128      * is not significant.
129      * </p>
130      *
131      * @return the modification stamp of this document or <code>UNKNOWN_MODIFICATION_STAMP</code>
132      */

133     long getModificationStamp();
134     
135     /**
136      * Returns this document's default line delimiter.
137      * <p>
138      * This default line delimiter should be used by clients who
139      * want unique delimiters (e.g. 'CR's) in the document.</p>
140      *
141      * @return the default line delimiter or <code>null</code> if none
142      */

143     String JavaDoc getDefaultLineDelimiter();
144     
145     /**
146      * Sets this document's initial line delimiter i.e. the one
147      * which is returned by <code>getDefaultLineDelimiter</code>
148      * if the document does not yet contain any line delimiter.
149      *
150      * @param lineDelimiter the default line delimiter
151      */

152     void setInitialLineDelimiter(String JavaDoc lineDelimiter);
153 }
154
Popular Tags