Extension SDK 10.1.2

oracle.ide.model
Class DefaultDocument

java.lang.Object
  extended byoracle.ide.model.DefaultDisplayable
      extended byoracle.ide.model.DefaultElement
          extended byoracle.ide.model.DefaultDocument
All Implemented Interfaces:
Data, Dirtyable, Displayable, Document, Element, LazyLoadable, Locatable, Subject
Direct Known Subclasses:
DefaultNode

public abstract class DefaultDocument
extends DefaultElement
implements Document

The DefaultDocument class is a default implementation of the Document interface.

See Also:
Document, Element, DefaultElement

Field Summary
 
Fields inherited from interface oracle.ide.addin.Subject
OBJECT_MODIFIED
 
Constructor Summary
DefaultDocument()
          Default constructor is required for JavaBean status.
DefaultDocument(java.net.URL url)
          Constructor that takes an URL pointing to the persistent location of the document's contents.
 
Method Summary
 void attach(Observer observer)
          Registers an observer interested in being notified when the internal state of the class implementing the Subject interface changes.
 void close()
          Part of Document interface.
protected  void copyToImpl(DefaultDocument copy)
          Design pattern for supporting strongly typed copying.
protected  Subject createSubject()
          Creates an instance of a Subject implementation.
 void detach(Observer observer)
          Unregisters an observer that is not interested anymore in being notified when the internal state of the class implementing the Subject interface changes.
protected  boolean ensureOpen()
          Call this method to make sure that the document is properly opened before accessing its data.
protected  boolean equalsImpl(DefaultDocument document)
          This is a helper method for Object.equals(Object) that can also be used by subclasses that implement Object.equals(Object).
 java.io.InputStream getInputStream()
          Part of Document interface.
 java.lang.String getLongLabel()
          Part of the Displayable interface.
 java.lang.String getShortLabel()
          Part of the Displayable interface.
protected  Subject getSubject()
          Gets the implementation of the Subject interface.
 long getTimestamp()
          Part of Document interface.
protected  long getTimestampDirectly()
          Accessor for allowing subclasses to get the timestamp directly.
 java.lang.String getToolTipText()
          Part of the Displayable interface.
 java.net.URL getURL()
          Part of Locatable interface.
 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()
          Part of Document interface.
 boolean isReadOnly()
          Part of Document interface.
 void markDirty(boolean dirty)
          Marks the data with the specified dirty state.
 void notifyObservers(java.lang.Object observed, UpdateMessage change)
          Notifies all observers that the state of the subject has changed.
 void open()
          Part of Document interface.
protected  long refreshTimestamp()
          Protected method that can be used to refresh the timestamp of the DefaultDocument based on the timestamp that can be obtained through the URL.
 void save(boolean shallow)
          Part of Document interface.
protected  void setOpen(boolean isOpen)
          Protected accessor for the #_isOpen flag.
protected  void setTimestampDirectly(long timestamp)
          Accessor for allowing subclasses to set the timestamp directly.
 void setURL(java.net.URL url)
          Part of Locatable interface.
protected  void setURLDirectly(java.net.URL url)
          Set the URL directly.
 
Methods inherited from class oracle.ide.model.DefaultElement
getAttributes, getChildren, getData, mayHaveChildren
 
Methods inherited from class oracle.ide.model.DefaultDisplayable
getIcon, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface oracle.ide.model.Element
getAttributes, getChildren, mayHaveChildren
 
Methods inherited from interface oracle.ide.model.Data
getData
 
Methods inherited from interface oracle.ide.model.Displayable
getIcon, toString
 

Constructor Detail

DefaultDocument

public DefaultDocument()
Default constructor is required for JavaBean status. All subclasses must have a public default constructor.


DefaultDocument

public DefaultDocument(java.net.URL url)
Constructor that takes an URL pointing to the persistent location of the document's contents.

Parameters:
url - URL identifying the persistent document for the content represented by this DefaultDocument.
Method Detail

getURL

public java.net.URL getURL()
Part of Locatable interface. The default implementation returns the currently set URL.

Specified by:
getURL in interface Locatable
Returns:
The URL identifying this Locatable.
See Also:
Locatable.getURL()

setURL

public void setURL(java.net.URL url)
Part of Locatable interface. The default implementation sets the URL to the specified value.

Specified by:
setURL in interface Locatable
Parameters:
url - The URL to set.
See Also:
Locatable.setURL(URL)

isDirty

public boolean isDirty()
Description copied from interface: Dirtyable
True if the data in the object has been modified.

Specified by:
isDirty in interface Dirtyable
Returns:
true if the data in the object has been modified.

markDirty

public void markDirty(boolean dirty)
Description copied from interface: Dirtyable
Marks the data with the specified dirty state. This method is called markDirty(...) instead of setDirty(...) so that the JavaBeans Introspector will not mistakenly identify "dirty" as a JavaBean property.

Specified by:
markDirty in interface Dirtyable
Parameters:
dirty - If true, sets the object as being dirty; if false, sets the object as being up-to-date.

getShortLabel

public java.lang.String getShortLabel()
Part of the Displayable interface. The default implementation returns the file name part of the currently set URL. If the currently set URL is null, then this method returns "<null>".

Specified by:
getShortLabel in interface Displayable
Overrides:
getShortLabel in class DefaultDisplayable
See Also:
Displayable.getShortLabel()

getLongLabel

public java.lang.String getLongLabel()
Part of the Displayable interface. The default implementation returns the path name part of the currently set URL. If the currently set URL is null, then this method returns "<null>".

Specified by:
getLongLabel in interface Displayable
Overrides:
getLongLabel in class DefaultDisplayable
See Also:
Displayable.getLongLabel()

getToolTipText

public java.lang.String getToolTipText()
Part of the Displayable interface. The default implementation returns the same result as the getLongLabel() method.

Specified by:
getToolTipText in interface Displayable
Overrides:
getToolTipText in class DefaultDisplayable
See Also:
Displayable.getToolTipText()

attach

public void attach(Observer observer)
Description copied from interface: Subject
Registers an observer interested in being notified when the internal state of the class implementing the Subject interface changes. Implementors should do nothing when the same observer is added more than once.

Specified by:
attach in interface Subject
Parameters:
observer - the Observer interested in change notification messages.

detach

public void detach(Observer observer)
Description copied from interface: Subject
Unregisters an observer that is not interested anymore in being notified when the internal state of the class implementing the Subject interface changes. Implementors should do nothing when the same observer is removed more than once.

Specified by:
detach in interface Subject
Parameters:
observer - the Observer disinterested in change notification messages.

notifyObservers

public void notifyObservers(java.lang.Object observed,
                            UpdateMessage change)
Description copied from interface: Subject
Notifies all observers that the state of the subject has changed.

Specified by:
notifyObservers in interface Subject
Parameters:
observed - the subject whose state has changed.
change - what changed.

open

public void open()
          throws java.io.IOException
Part of Document interface. This implementation simply calls setOpen(true) and refreshes the timestamp.

Specified by:
open in interface Document
Throws:
java.io.IOException - Signals that an I/O exception of some sort occurred.
See Also:
Document.open()

close

public void close()
           throws java.io.IOException
Part of Document interface. This implementation simply calls setOpen(false).

Specified by:
close in interface Document
Throws:
java.io.IOException - Signals that an I/O exception of some sort occurred.
See Also:
Document.close()

save

public void save(boolean shallow)
          throws java.io.IOException
Part of Document interface. This implementation simply clears the dirty flag by calling markDirty(false).

Specified by:
save in interface Document
Parameters:
shallow - The value of this parameter only matters if the Document is also a Container. If shallow is true, children should not be saved; if shallow is false, children should also be saved.
Throws:
java.io.IOException - Signals that an I/O exception of some sort occurred.
See Also:
Document.save(boolean)

isOpen

public boolean isOpen()
Part of Document interface. This implementataion returns the current state of the #_isOpen flag.

Specified by:
isOpen in interface LazyLoadable
See Also:
LazyLoadable.isOpen()

isReadOnly

public boolean isReadOnly()
Part of Document interface. This implementation delegates to the URLFileSystem to determine whether or not this document is read-only.

Specified by:
isReadOnly in interface Document
Returns:
true if the document is a read-only document.
See Also:
Document.isReadOnly()

getTimestamp

public long getTimestamp()
Part of Document interface. This implementation gets the timestamp based on the last time that this document was either opened or saved.

Specified by:
getTimestamp in interface Document
Returns:
the Document's time stamp.
See Also:
Document.getTimestamp()

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Part of Document interface. The default implementation returns a raw InputStream based on the URL associated with the Document. The InputStream is obtained through the URLFileSystem class. The caller is responsible for closing the InputStream when done.

Specified by:
getInputStream in interface Document
Returns:
an InputStream, or null if the document has no contents.
Throws:
java.net.UnknownServiceException - if the URL's protocol does not support input; this exception is a subclass of IOException.
java.io.IOException - if an I/O error occurs when trying to open the InputStream.
See Also:
Document.getInputStream()

isNew

public boolean isNew()
Description copied from interface: Document
Returns true if the document's data has never been saved.

Specified by:
isNew in interface Document
Returns:
true if the document's data has never been saved.

setOpen

protected void setOpen(boolean isOpen)
Protected accessor for the #_isOpen flag. This method must remain protected in order to avoid being picked up by the Introspector as a read/writeable JavaBean property.


refreshTimestamp

protected long refreshTimestamp()
Protected method that can be used to refresh the timestamp of the DefaultDocument based on the timestamp that can be obtained through the URL.

Returns:
the refreshed timestamp that is now associated with this document.

getTimestampDirectly

protected long getTimestampDirectly()
Accessor for allowing subclasses to get the timestamp directly.


setTimestampDirectly

protected void setTimestampDirectly(long timestamp)
Accessor for allowing subclasses to set the timestamp directly.


copyToImpl

protected final void copyToImpl(DefaultDocument copy)
Design pattern for supporting strongly typed copying.

This method is intended to be helper method that subclasses can use, if they implement the Copyable interface.


equalsImpl

protected final boolean equalsImpl(DefaultDocument document)
This is a helper method for Object.equals(Object) that can also be used by subclasses that implement Object.equals(Object). It assumes that the argument is not null.


getSubject

protected Subject getSubject()
Gets the implementation of the Subject interface. This implementation returns an IdeSubject but subclasses should override the createSubject method in order to provide a different implementation of a Subject.


createSubject

protected Subject createSubject()
Creates an instance of a Subject implementation. This method is called from getSubject() the first time the subject is created. Subclasses should override this method to provide their own Subject implementation.


ensureOpen

protected boolean ensureOpen()
Call this method to make sure that the document is properly opened before accessing its data.


setURLDirectly

protected void setURLDirectly(java.net.URL url)
Set the URL directly. This method just sets the url on the node. The method is intended to provide a way to create a document without having the node put in the node factory cache.

Parameters:
url - the node's url.

Extension SDK

 

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