KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > wings > text > SDocument


1 /* $Id $ */
2 /*
3  * $Id: SDocument.java,v 1.3 2004/12/01 07:54:29 hengels Exp $
4  * Copyright 2000,2005 wingS development team.
5  *
6  * This file is part of wingS (http://www.j-wings.org).
7  *
8  * wingS is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version 2.1
11  * of the License, or (at your option) any later version.
12  *
13  * Please see COPYING for the complete licence.
14  */

15 package org.wings.text;
16
17 import org.wings.event.SDocumentListener;
18
19 import javax.swing.text.BadLocationException JavaDoc;
20
21 /**
22  * @author hengels
23  * @version $Revision: 1.3 $
24  */

25 public interface SDocument {
26     /**
27      * Returns number of characters of content currently
28      * in the document.
29      *
30      * @return number of characters >= 0
31      */

32     public int getLength();
33
34     /**
35      * Registers the given observer to begin receiving notifications
36      * when changes are made to the document.
37      *
38      * @param listener the observer to register
39      * @see SDocument#removeDocumentListener
40      */

41     public void addDocumentListener(SDocumentListener listener);
42
43     /**
44      * Unregisters the given observer from the notification list
45      * so it will no longer receive change updates.
46      *
47      * @param listener the observer to register
48      * @see SDocument#addDocumentListener
49      */

50     public void removeDocumentListener(SDocumentListener listener);
51
52     /**
53      * Removes a portion of the content of the document.
54      * This will cause a DocumentEvent of type
55      * DocumentEvent.EventType.REMOVE to be sent to the
56      * registered DocumentListeners, unless an exception
57      * is thrown. The notification will be sent to the
58      * listeners by calling the removeUpdate method on the
59      * DocumentListeners.
60      *
61      * @param offs the offset from the beginning >= 0
62      * @param len the number of characters to remove >= 0
63      * @throws BadLocationException some portion of the removal range
64      * was not a valid part of the document. The location in the exception
65      * is the first bad position encountered.
66      * @see javax.swing.event.DocumentEvent
67      * @see javax.swing.event.DocumentListener
68      * @see javax.swing.event.UndoableEditEvent
69      * @see javax.swing.event.UndoableEditListener
70      */

71     public void remove(int offs, int len) throws BadLocationException JavaDoc;
72
73     /**
74      * Inserts a string of content. This will cause a DocumentEvent
75      * of type DocumentEvent.EventType.INSERT to be sent to the
76      * registered DocumentListers, unless an exception is thrown.
77      * The DocumentEvent will be delivered by calling the
78      * insertUpdate method on the DocumentListener.
79      * The offset and length of the generated DocumentEvent
80      * will indicate what change was actually made to the Document.
81      *
82      * @param offset the offset into the document to insert the content >= 0.
83      * All positions that track change at or after the given location
84      * will move.
85      * @param string the string to insert
86      */

87     public void insert(int offset, String JavaDoc string) throws BadLocationException JavaDoc;
88
89
90     /**
91      * Fetches the text contained within the given portion
92      * of the document.
93      *
94      * @param offset the offset into the document representing the desired
95      * start of the text >= 0
96      * @param length the length of the desired string >= 0
97      * @return the text, in a String of length >= 0
98      * @throws BadLocationException some portion of the given range
99      * was not a valid part of the document. The location in the exception
100      * is the first bad position encountered.
101      */

102     public String JavaDoc getText(int offset, int length) throws BadLocationException JavaDoc;
103
104     public String JavaDoc getText();
105
106     public void setText(String JavaDoc text);
107 }
108
Popular Tags