Runtime

## org.eclipse.gmf.runtime.diagram.ui.resources.editor.document
Interface IDocument

All Known Subinterfaces:
  IDiagramDocument

All Known Implementing Classes:
  AbstractDocument, DiagramDocument

public interface IDocument

An `IDocument` represents extensible content providing support A document allows to set its content and to manipulate it. On each document change, all registered document listeners are informed exactly once.

See Also:
  `IDocumentListener`

Field Summary
`static long` `UNKNOWN_MODIFICATION_STAMP` The unknown modification stamp.

Method Summary
`void` `addDocumentListener(IDocumentListener listener)` Registers the document listener with the document.
`void` `addPrenotifiedDocumentListener(IDocumentListener documentAdapter)` Adds the given document listener as one which is notified before those document listeners added with `addDocumentListener` are notified.
`java.lang.Object` `getContent()` Returns this document's contents.
`long` `getModificationStamp()` Returns the modification stamp of this document.
`void` `removeDocumentListener(IDocumentListener listener)` Removes the listener from the document's list of document listeners.
`void` `removePrenotifiedDocumentListener(IDocumentListener documentAdapter)` Removes the given document listener from the document's list of pre-notified document listeners.
`void` `resumeListenerNotification()` Resumes the notification of document listeners which must previously have been stopped by a call to `stopListenerNotification`.
`void` `setContent(java.lang.Object documentContent)` Replaces the content of the document with the given content.
`void` `setContent(java.lang.Object content, long modificationStamp)` Replaces the content of the document with the given text.
`void` `stopListenerNotification()` The affect of these calls is that no document listener is notified until `resumeListenerNotification` is called.

Field Detail

### UNKNOWN_MODIFICATION_STAMP

    public static final long UNKNOWN_MODIFICATION_STAMP

  The unknown modification stamp.

  See Also:
    Constant Field Values

Method Detail

### getModificationStamp

    public long getModificationStamp()

  Returns the modification stamp of this document. The modification stamp is updated each time a modifying operation is called on this document. If two modification stamps of the same document are identical then the document content is too, however, same content does not imply same modification stamp.

  The magnitude or sign of the numerical difference between two modification stamps is not significant.

  Returns:
    the modification stamp of this document or `UNKNOWN_MODIFICATION_STAMP`

### addDocumentListener

    public void addDocumentListener(IDocumentListener listener)

  Registers the document listener with the document. After registration the IDocumentListener is informed about each change of this document. If the listener is already registered nothing happens.

  An `IDocumentListener` may call back to this method when being inside a document notification.

  Parameters:
    `listener` - the listener to be registered

### removeDocumentListener

    public void removeDocumentListener(IDocumentListener listener)

  Removes the listener from the document's list of document listeners. If the listener is not registered with the document nothing happens.

  An `IDocumentListener` may call back to this method when being inside a document notification.

  Parameters:
    `listener` - the listener to be removed

### addPrenotifiedDocumentListener

    public void addPrenotifiedDocumentListener(IDocumentListener documentAdapter)

  Adds the given document listener as one which is notified before those document listeners added with `addDocumentListener` are notified. If the given listener is also registered using `addDocumentListener` it will be notified twice. If the listener is already registered nothing happens.

  This method is not for public use.

  Parameters:
    `documentAdapter` - the listener to be added as pre-notified document listener
  See Also:
    `IDocument.removePrenotifiedDocumentListener(IDocumentListener)`

### removePrenotifiedDocumentListener

    public void removePrenotifiedDocumentListener(IDocumentListener documentAdapter)

  Removes the given document listener from the document's list of pre-notified document listeners. If the listener is not registered with the document nothing happens.

  This method is not for public use.

  Parameters:
    `documentAdapter` - the listener to be removed
  See Also:
    `IDocument.addPrenotifiedDocumentListener(IDocumentListener)`

### getContent

    public java.lang.Object getContent()

  Returns this document's contents.

  Returns:
    the document's contents

### setContent

    public void setContent(java.lang.Object documentContent)

  Replaces the content of the document with the given content. Sends a `DocumentEvent` to all registered `IDocumentListener`.

  Parameters:
    `documentContent` - the new content of the document
  See Also:
    `DocumentEvent`, `IDocumentListener`

### setContent

    public void setContent(java.lang.Object content,
                           long modificationStamp)

  Replaces the content of the document with the given text. Sends a `DocumentEvent` to all registered `IDocumentListener`.

  Parameters:
    `content` - the new content of the document
    `modificationStamp` - of the document after setting the content
  See Also:
    `DocumentEvent`, `IDocumentListener`

### stopListenerNotification

    public void stopListenerNotification()

  The affect of these calls is that no document listener is notified until `resumeListenerNotification` is called. This allows clients to update structure before any listener is informed about the change.

  Listener notification can only be stopped for a single `replace` operation. Otherwise, document change notifications will be lost.

### resumeListenerNotification

    public void resumeListenerNotification()

  Resumes the notification of document listeners which must previously have been stopped by a call to `stopListenerNotification`.

Runtime

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.