Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.1.0)

E17493-02

javax.ide.model
Class Document

java.lang.Object
  extended by javax.ide.model.Element
      extended by javax.ide.model.Document
Direct Known Subclasses:
Project, TextDocument

public class Document
extends Element

The Document interface is implemented by objects that can be saved and restored. These objects are generally persisted on some file system and are address using an unique URI.

Documents are generally created using the DocumentFactory. This ensures that there is always one instance of a document pointed to by the same URI.

The specification defines following types of documents:

Extension writers that need to introduce custom document classes, should extend this class.

When a new document class is introduced, the DocumentFactory must be told how to recognize the new document. Extension writers tell the document factory how to recognize newly introduced document classes in the extension deployment descriptor.


Constructor Summary
Document()
           
 
Method Summary
 void addDocumentListener(DocumentListener listener)
          Add a DocumentListener to the listener list.
 void close()
          Closes the Document and unloads any associated data.
 boolean equals(java.lang.Object other)
           
 ElementDisplayInfo getDisplayInfo()
           
protected  javax.ide.model.spi.ElementImpl getElementImpl()
           
 java.io.Reader getReader()
          Gets an Reader that can be used to read the contents of this object.
 long getTimestamp()
          Returns the timestamp associated with the Document, which indicates the time at which the document was last modified.
 java.net.URI getURI()
          Returns the URI that identifies this Document.
 int hashCode()
           
 boolean isDirty()
          True if the data in the object has been modified.
 boolean isNew()
          Returns true if the document's data has never been saved.
 boolean isOpen()
          Returns true if the object's data has already been loaded.
 boolean isReadOnly()
          Returns true if the document's data has never been saved.
 void markDirty(boolean dirty)
          Marks the data with the specified dirty state.
 void open()
          Opens the Document and loads any associated data into the appropriate data structures.
 void removeDocumentListener(DocumentListener listener)
          Removes a DocumentListener from the listener list.
 void save()
          Saves the contents of the document.
protected  void setDisplayInfo(ElementDisplayInfo displayInfo)
          Set the display info for this element.
 void setURI(java.net.URI uri)
          Sets the URI associated with this Document.
 
Methods inherited from class javax.ide.model.Element
getIcon, getLabel, getLongLabel, getToolTip
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Document

public Document()
Method Detail

getElementImpl

protected final javax.ide.model.spi.ElementImpl getElementImpl()
Specified by:
getElementImpl in class Element

setDisplayInfo

protected final void setDisplayInfo(ElementDisplayInfo displayInfo)
Set the display info for this element. This can be used by custom documents to customize their display in the IDE.

Parameters:
displayInfo - the display info for this document. If null, the IDE will display this element in whatever the default way is standard for elements of this type.

getDisplayInfo

public ElementDisplayInfo getDisplayInfo()

getURI

public final java.net.URI getURI()
Returns the URI that identifies this Document. Parts of the IDE will use the value of this URI as a hash key for caching UI components for this Document. Therefore, URI uniqueness is important.

Returns:
The URI identifying this Document.

setURI

public final void setURI(java.net.URI uri)
Sets the URI associated with this Document. It is important that the URI only be changed when the Document has just been created or when all caches keyed on the previous URI can also be updated.

Parameters:
uri - The URI to set.

isOpen

public final boolean isOpen()
Returns true if the object's data has already been loaded.


isNew

public final boolean isNew()
Returns true if the document's data has never been saved.


open

public final void open()
                throws java.io.IOException
Opens the Document and loads any associated data into the appropriate data structures. This method notifies listeners if the document is successfully opened.

Throws:
java.io.IOException - if the document cannot be opened.

close

public final void close()
                 throws java.io.IOException
Closes the Document and unloads any associated data. When this method returns, the state of the Document object should be equivalent to when the Document object has just been instantiated but not yet opened.

Throws:
java.io.IOException - if the document cannot be closed.

save

public final void save()
                throws java.io.IOException
Saves the contents of the document.

Throws:
java.io.IOException

isReadOnly

public final boolean isReadOnly()
Returns true if the document's data has never been saved.

Returns:
true if the document's data has never been saved.

isDirty

public final boolean isDirty()
True if the data in the object has been modified.

Returns:
true if the data in the object has been modified.

markDirty

public final void markDirty(boolean dirty)
Marks the data with the specified dirty state.

Parameters:
dirty - If true, sets the object as being dirty; if false, sets the object as being up-to-date.

getTimestamp

public final long getTimestamp()
Returns the timestamp associated with the Document, which indicates the time at which the document was last modified. The returned long is expressed in milliseconds since 00:00:00 GMT Jan 1, 1970.

Returns:
the Document's time stamp.

getReader

public final java.io.Reader getReader()
                               throws java.io.IOException
Gets an Reader that can be used to read the contents of this object.

Returns:
an Reader, or null if the document has no contents.
Throws:
java.io.IOException - if a security manager exists and its checkRead method denies read access.

addDocumentListener

public final void addDocumentListener(DocumentListener listener)
Add a DocumentListener to the listener list. A DocumentEvent will be fired in response modifying the contents of this document.


removeDocumentListener

public final void removeDocumentListener(DocumentListener listener)
Removes a DocumentListener from the listener list.


hashCode

public final int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.1.0)

E17493-02

Copyright © 1997, 2011, Oracle. All rights reserved.