javax.swing.text
Class AbstractDocument.DefaultDocumentEvent

java.lang.Object
  extended by javax.swing.undo.AbstractUndoableEdit
      extended by javax.swing.undo.CompoundEdit
          extended by javax.swing.text.AbstractDocument.DefaultDocumentEvent
All Implemented Interfaces:
Serializable, DocumentEvent, UndoableEdit
Enclosing class:
AbstractDocument

public class AbstractDocument.DefaultDocumentEvent
extends CompoundEdit
implements DocumentEvent

Stores the changes when a Document is beeing modified.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface javax.swing.event.DocumentEvent
DocumentEvent.ElementChange, DocumentEvent.EventType
 
Field Summary
 
Fields inherited from class javax.swing.undo.CompoundEdit
edits
 
Fields inherited from class javax.swing.undo.AbstractUndoableEdit
RedoName, UndoName
 
Constructor Summary
AbstractDocument.DefaultDocumentEvent(int offset, int length, DocumentEvent.EventType type)
          Creates a new DefaultDocumentEvent.
 
Method Summary
 boolean addEdit(UndoableEdit edit)
          Adds an UndoableEdit to this DocumentEvent.
 DocumentEvent.ElementChange getChange(Element elem)
          Returns the changes for an element.
 Document getDocument()
          Returns the document that has been modified.
 int getLength()
          Returns the length of the modification.
 int getOffset()
          Returns the start offset of the modification.
 DocumentEvent.EventType getType()
          Returns the type of the modification.
 String toString()
          Returns a String description of the change event.
 
Methods inherited from class javax.swing.undo.CompoundEdit
canRedo, canUndo, die, end, getPresentationName, getRedoPresentationName, getUndoPresentationName, isInProgress, isSignificant, lastEdit, redo, undo
 
Methods inherited from class javax.swing.undo.AbstractUndoableEdit
replaceEdit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractDocument.DefaultDocumentEvent

public AbstractDocument.DefaultDocumentEvent(int offset,
                                             int length,
                                             DocumentEvent.EventType type)
Creates a new DefaultDocumentEvent.

Parameters:
offset - the starting offset of the change
length - the length of the change
type - the type of change
Method Detail

addEdit

public boolean addEdit(UndoableEdit edit)
Adds an UndoableEdit to this DocumentEvent. If this edit is an instance of AbstractDocument.ElementEdit, then this record can later be fetched by calling getChange(javax.swing.text.Element).

Specified by:
addEdit in interface UndoableEdit
Overrides:
addEdit in class CompoundEdit
Parameters:
edit - the undoable edit to add
Returns:
true if edit could somehow be incorporated; false if edit has not been incorporated because CompoundEdit.end() was called before.

getDocument

public Document getDocument()
Returns the document that has been modified.

Specified by:
getDocument in interface DocumentEvent
Returns:
the document that has been modified

getLength

public int getLength()
Returns the length of the modification.

Specified by:
getLength in interface DocumentEvent
Returns:
the length of the modification

getOffset

public int getOffset()
Returns the start offset of the modification.

Specified by:
getOffset in interface DocumentEvent
Returns:
the start offset of the modification

getType

public DocumentEvent.EventType getType()
Returns the type of the modification.

Specified by:
getType in interface DocumentEvent
Returns:
the type of the modification

getChange

public DocumentEvent.ElementChange getChange(Element elem)
Returns the changes for an element.

Specified by:
getChange in interface DocumentEvent
Parameters:
elem - the element for which the changes are requested
Returns:
the changes for elem or null if elem has not been changed

toString

public String toString()
Returns a String description of the change event. This returns the toString method of the Vector of edits.

Overrides:
toString in class CompoundEdit
Returns:
the String representing this Object, which may be null
See Also:
Object.getClass(), Object.hashCode(), Class.getName(), Integer.toHexString(int)