Extension SDK

oracle.ide.model
Class TextNode

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

public class TextNode
extends DefaultNode
implements TextDocument

The TextNode class extends DefaultNodeand should be used for all objects that can be opened as a text file inside a code editor.

See Also:
TextDocument

Field Summary
 
Fields inherited from interface oracle.ide.addin.Subject
OBJECT_MODIFIED
 
Fields inherited from interface oracle.ide.model.Category
UNDEFINED
 
Constructor Summary
TextNode()
           
TextNode(java.net.URL url)
           
 
Method Summary
 TextBuffer acquireTextBuffer()
          Requests the data from the Document in the format of a TextBuffer instance so that it can be used by the code editor.
 void close()
          Empties the current TextBuffer and calls setOpen(false).
 java.io.InputStream getInputStream()
          Deprecated.  
protected  java.lang.String getLoadEncoding()
          Returns a Java supported encoding name to use to create the InputStreamReader for reading data from the URL into the TextBuffer (called from reopen()).
 java.io.Reader getReader()
           
protected  java.lang.String getSaveEncoding()
          Returns a Java supported encoding name to use to create the OutputStreamWriter for writing the TextBuffer to a file (called from save()).
protected  TextBuffer getTextBufferDirectly()
          Directly sets the TextBuffer.
 boolean hasEmptyTextBuffer()
           
 boolean isDirty()
          First checks if the superclass has its dirty flag set; if so, returns true.
 boolean isReadOnly()
          Part of Document interface.
 void markDirty(boolean dirty)
          Two things happen: The superclass markDirty(dirty) method is called.
 void open()
          Document method.
 void releaseTextBuffer()
          Informs the document that the previously acquired TextBuffer instance is no longer needed.
 void reopen()
          Loads the contents at the current URL into a TextBuffer.
 void save(boolean shallow)
          Saves the contents of the current TextBuffer to the location specified by the current URL.
protected  void setTextBufferDirectly(TextBuffer textBuffer)
          Direclty sets the TextBuffer.
protected  void updateReadOnlyFlag(boolean readOnly)
          In general, this method should only be used by the TextNode class itself or any subclasses that need to override TextNode behavior. This method modifies the read-only flag of the underlying TextBuffer.
 
Methods inherited from class oracle.ide.model.DefaultNode
equalsImpl, getCategory, setURL
 
Methods inherited from class oracle.ide.model.DefaultDocument
attach, copyToImpl, createSubject, detach, ensureOpen, equalsImpl, getLongLabel, getShortLabel, getSubject, getTimestamp, getTimestampDirectly, getToolTipText, getURL, isNew, isOpen, notifyObservers, refreshTimestamp, setOpen, setTimestampDirectly
 
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.Document
getTimestamp, isNew
 
Methods inherited from interface oracle.ide.model.Locatable
getURL, setURL
 
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, getLongLabel, getShortLabel, getToolTipText, toString
 
Methods inherited from interface oracle.ide.addin.Subject
attach, detach, notifyObservers
 
Methods inherited from interface oracle.ide.model.LazyLoadable
isOpen
 

Constructor Detail

TextNode

public TextNode()

TextNode

public TextNode(java.net.URL url)
Method Detail

isDirty

public boolean isDirty()
First checks if the superclass has its dirty flag set; if so, returns true. Otherwise, the determination of the dirty state is delegated to the underlying TextBuffer implementation. If the current TextBuffer is null, false is returned.

Specified by:
isDirty in interface Dirtyable
Overrides:
isDirty in class DefaultDocument

markDirty

public void markDirty(boolean dirty)
Two things happen:
  1. The superclass markDirty(dirty) method is called.
  2. If the dirty parameter is false, the modified state of the underlying TextBuffer is cleared.

Specified by:
markDirty in interface Dirtyable
Overrides:
markDirty in class DefaultDocument

open

public void open()
Document method. This implementation first checks if the document is already open. If it is not open, then the task of opening the document is delegated to reopen().

Specified by:
open in interface Document
Overrides:
open in class DefaultDocument
See Also:
Document.open()

close

public void close()
Empties the current TextBuffer and calls setOpen(false). The contents of the TextBuffer are not saved.

Specified by:
close in interface Document
Overrides:
close in class DefaultDocument
See Also:
Document.close()

reopen

public void reopen()
Loads the contents at the current URL into a TextBuffer. If the current URL points to a non-existent resource, then the TextBuffer is initialized with no contents.


save

public void save(boolean shallow)
          throws java.io.IOException
Saves the contents of the current TextBuffer to the location specified by the current URL.

Specified by:
save in interface Document
Overrides:
save in class DefaultDocument
Throws:
java.io.IOException
See Also:
Document.save(boolean)

isReadOnly

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

We override this here in order to force the underlying buffer to be read only.

Specified by:
isReadOnly in interface Document
Overrides:
isReadOnly in class DefaultDocument
See Also:
Document.isReadOnly()

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Deprecated.  

NOTE: Use of TextNode.getInputStream() is highly discouraged because of the NLS issues raised by using byte streams for text and the associated poor performance caused by char-to-byte conversion. Use TextNode.getReader() instead whenever possible.

Returns an InputStream that's backed by the current TextBuffer.

Specified by:
getInputStream in interface Document
Overrides:
getInputStream in class DefaultDocument
Throws:
java.lang.IllegalStateException - if the current TextBuffer is null.
java.io.IOException - if an I/O error occurs when trying to open the InputStream.
See Also:
Document.getInputStream()

acquireTextBuffer

public TextBuffer acquireTextBuffer()
Requests the data from the Document in the format of a TextBuffer instance so that it can be used by the code editor. Note that the acquisition and release of TextBuffer instances are reference counted - this is to allow TextDocument implementations the freedom to drop the use of the TextBuffer instance when it is no longer needed and revert to a more "compressed" form of storage.

Specified by:
acquireTextBuffer in interface TextDocument
Returns:
the TextBuffer instance for accessing this Document in text form

releaseTextBuffer

public void releaseTextBuffer()
Informs the document that the previously acquired TextBuffer instance is no longer needed. This frees up the need for the Document to maintain the TextBuffer instance.

Specified by:
releaseTextBuffer in interface TextDocument

getReader

public java.io.Reader getReader()
                         throws java.io.IOException
Throws:
java.io.IOException

hasEmptyTextBuffer

public boolean hasEmptyTextBuffer()

getTextBufferDirectly

protected TextBuffer getTextBufferDirectly()
Directly sets the TextBuffer. This method is primarily intended for subclass customization of TextNode.


setTextBufferDirectly

protected void setTextBufferDirectly(TextBuffer textBuffer)
Direclty sets the TextBuffer. This method is primarily intended for subclass customization of TextNode.


updateReadOnlyFlag

protected void updateReadOnlyFlag(boolean readOnly)
In general, this method should only be used by the TextNode class itself or any subclasses that need to override TextNode behavior. This method modifies the read-only flag of the underlying TextBuffer.


getLoadEncoding

protected java.lang.String getLoadEncoding()
Returns a Java supported encoding name to use to create the InputStreamReader for reading data from the URL into the TextBuffer (called from reopen()). The base implementation returns the IDE default encoding, however subclasses (like XMLSourceNode) may override this with a different encoding determined from the URL data

Returns:
a Java supported encoding name for reading

getSaveEncoding

protected java.lang.String getSaveEncoding()
Returns a Java supported encoding name to use to create the OutputStreamWriter for writing the TextBuffer to a file (called from save()). The base implementation returns the IDE default encoding, subclasses (like XMLSourceNode) may override this with a different encoding determined from the TextBuffer data

Returns:
a Java supported encoding name for writing

Extension SDK

 

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