org.wings.text
Class DefaultDocument

java.lang.Object
  extended by org.wings.text.DefaultDocument
All Implemented Interfaces:
Serializable, SDelayedEventModel, SDocument

public class DefaultDocument
extends Object
implements SDocument

Author:
hengels
See Also:
Serialized Form

Field Summary
protected  ArrayList delayedEvents
          All delayed events are stored here
 
Constructor Summary
DefaultDocument()
           
DefaultDocument(String text)
           
 
Method Summary
 void addDocumentListener(SDocumentListener listener)
          Registers the given observer to begin receiving notifications when changes are made to the document.
protected  void fireChangeUpdate(int offset, int length)
           
 void fireDelayedFinalEvents()
          fire remaining delayed events.
 void fireDelayedIntermediateEvents()
          fire delayed events which describes a "in progress" state change, like TreeWillExpand, or ListSelectionEvent with getIsAdjusting() true, ...
protected  void fireInsertUpdate(int offset, int length)
           
protected  void fireRemoveUpdate(int offset, int length)
           
 boolean getDelayEvents()
           
 SDocumentListener[] getDocumentListeners()
          Returns an array of all the SDocumentListeners added to this SDocument via addDocumentListener().
 int getLength()
          Returns number of characters of content currently in the document.
 String getText()
           
 String getText(int offset, int length)
          Fetches the text contained within the given portion of the document.
 void insert(int offset, String string)
          Inserts a string of content.
 void remove(int offset, int length)
          Removes a portion of the content of the document.
 void removeDocumentListener(SDocumentListener listener)
          Unregisters the given observer from the notification list so it will no longer receive change updates.
 void setDelayEvents(boolean b)
          if this is set to true, events are not fired immediately.
 void setText(String text)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

delayedEvents

protected final ArrayList delayedEvents
All delayed events are stored here

Constructor Detail

DefaultDocument

public DefaultDocument()

DefaultDocument

public DefaultDocument(String text)
Method Detail

setText

public void setText(String text)
Specified by:
setText in interface SDocument

getText

public String getText()
Specified by:
getText in interface SDocument

getText

public String getText(int offset,
                      int length)
               throws BadLocationException
Description copied from interface: SDocument
Fetches the text contained within the given portion of the document.

Specified by:
getText in interface SDocument
Parameters:
offset - the offset into the document representing the desired start of the text >= 0
length - the length of the desired string >= 0
Returns:
the text, in a String of length >= 0
Throws:
BadLocationException - some portion of the given range was not a valid part of the document. The location in the exception is the first bad position encountered.

getLength

public int getLength()
Description copied from interface: SDocument
Returns number of characters of content currently in the document.

Specified by:
getLength in interface SDocument
Returns:
number of characters >= 0

remove

public void remove(int offset,
                   int length)
            throws BadLocationException
Description copied from interface: SDocument
Removes a portion of the content of the document. This will cause a DocumentEvent of type DocumentEvent.EventType.REMOVE to be sent to the registered DocumentListeners, unless an exception is thrown. The notification will be sent to the listeners by calling the removeUpdate method on the DocumentListeners.

Specified by:
remove in interface SDocument
Parameters:
offset - the offset from the beginning >= 0
length - the number of characters to remove >= 0
Throws:
BadLocationException - some portion of the removal range was not a valid part of the document. The location in the exception is the first bad position encountered.
See Also:
DocumentEvent, DocumentListener, UndoableEditEvent, UndoableEditListener

insert

public void insert(int offset,
                   String string)
            throws BadLocationException
Description copied from interface: SDocument
Inserts a string of content. This will cause a DocumentEvent of type DocumentEvent.EventType.INSERT to be sent to the registered DocumentListers, unless an exception is thrown. The DocumentEvent will be delivered by calling the insertUpdate method on the DocumentListener. The offset and length of the generated DocumentEvent will indicate what change was actually made to the Document.

Specified by:
insert in interface SDocument
Parameters:
offset - the offset into the document to insert the content >= 0. All positions that track change at or after the given location will move.
string - the string to insert
Throws:
BadLocationException

getDocumentListeners

public SDocumentListener[] getDocumentListeners()
Description copied from interface: SDocument
Returns an array of all the SDocumentListeners added to this SDocument via addDocumentListener().

Specified by:
getDocumentListeners in interface SDocument
Returns:
all of the SDocumentListeners added or an empty array if no listeners are present
See Also:
SDocument.addDocumentListener(org.wings.event.SDocumentListener), SDocument.removeDocumentListener(org.wings.event.SDocumentListener)

addDocumentListener

public void addDocumentListener(SDocumentListener listener)
Description copied from interface: SDocument
Registers the given observer to begin receiving notifications when changes are made to the document.

Specified by:
addDocumentListener in interface SDocument
Parameters:
listener - the observer to register
See Also:
SDocument.removeDocumentListener(org.wings.event.SDocumentListener)

removeDocumentListener

public void removeDocumentListener(SDocumentListener listener)
Description copied from interface: SDocument
Unregisters the given observer from the notification list so it will no longer receive change updates.

Specified by:
removeDocumentListener in interface SDocument
Parameters:
listener - the observer to register
See Also:
SDocument.addDocumentListener(org.wings.event.SDocumentListener)

fireInsertUpdate

protected void fireInsertUpdate(int offset,
                                int length)

fireRemoveUpdate

protected void fireRemoveUpdate(int offset,
                                int length)

fireChangeUpdate

protected void fireChangeUpdate(int offset,
                                int length)

getDelayEvents

public boolean getDelayEvents()
Specified by:
getDelayEvents in interface SDelayedEventModel

setDelayEvents

public void setDelayEvents(boolean b)
Description copied from interface: SDelayedEventModel
if this is set to true, events are not fired immediately. They are collected and fired after setting this to false...

Specified by:
setDelayEvents in interface SDelayedEventModel

fireDelayedIntermediateEvents

public void fireDelayedIntermediateEvents()
Description copied from interface: SDelayedEventModel
fire delayed events which describes a "in progress" state change, like TreeWillExpand, or ListSelectionEvent with getIsAdjusting() true, ...

Specified by:
fireDelayedIntermediateEvents in interface SDelayedEventModel

fireDelayedFinalEvents

public void fireDelayedFinalEvents()
Description copied from interface: SDelayedEventModel
fire remaining delayed events. In this level all events, which are important to an application should be fired. All listeners, which are notified in this level can assume that the components are in a consistent (considering user interaction) state.

Specified by:
fireDelayedFinalEvents in interface SDelayedEventModel


wingS Swings ;-)