Extension SDK 10.1.3.36.73

oracle.ide.model
Class TextNode

java.lang.Object
  extended byoracle.ide.model.Node
      extended byoracle.ide.model.TextNode
All Implemented Interfaces:
oracle.javatools.data.Dirtyable, Dirtyable, Displayable, Element, LazyLoadable, Locatable, Subject
Direct Known Subclasses:
DeployableTextNode, TextMergeNode

public class TextNode
extends Node

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


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.
protected  void closeImpl()
          Subclasses should override this method to customize the close() behavior.
protected  java.io.OutputStreamWriter createOutputStreamWriter(java.io.OutputStream outStream)
           
protected  java.io.Reader createReader(java.net.URL url)
          Fetch a Reader for reading the contents of this node from the given URL.
protected  void dataExpired()
          Cleanup any meta data based on the underlying TextBuffer.
 java.io.InputStream getInputStream()
          Deprecated.  
 java.io.InputStream getInputStream(boolean warn)
          Deprecated.  
 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 revert()).
 java.io.Reader getReader()
          Fetch a Reader for accessing the buffer contents of this TextNode.
 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 gets the TextBuffer.
 boolean hasEmptyTextBuffer()
          Checks whether the TextBuffer for this TextNode is empty (zero-length).
 boolean isDirty()
          First checks if the superclass has its dirty flag set; if so, returns true.
 boolean isReadOnly()
          Part of Node interface.
 void markDirty(boolean dirty)
          Two things happen: The superclass markDirty(dirty) method is called.
protected  void openImpl()
          Subclasses should override this method to customize the open() behavior.
 void releaseTextBuffer()
          Informs the document that the previously acquired TextBuffer instance is no longer needed.
 void removeTextBufferListener(TextBufferListener listener)
          Informs the TextBuffer that the given listener no longer needs to track it.
protected  void reportOpenException(java.lang.Exception e)
          This routine is given a chance to handle or report an Exception that occurred during open().
protected  void revertImpl()
          Subclasses should override this method to customize the revert() behavior.
protected  void saveImpl()
          Subclasses should override this method to customize the save() behavior.
protected  void setDefaultLineTerminator(TextBuffer textBuffer)
          Sets up the default line terminator to use for the text buffer.
 void setLoadEncoding(java.lang.String loadEncoding)
          Sets a Java supported encoding name to use to create the InputStreamReader for reading data from the URL into the TextBuffer (called from revert()).
 boolean setReadOnly(boolean readOnly)
          Sets the read-only status of URL for this TextNode.
 void setSaveEncoding(java.lang.String saveEncoding)
          Sets a Java supported encoding name to use to create the OutputStreamWriter for writing the TextBuffer to a file (called from save()).
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.
 
Methods inherited from class oracle.ide.model.Node
_getReadWriteLockInternal, addNodeListener, addNodeListenerForType, addNodeListenerForTypeHierarchy, attach, close, createSubject, delete, deleteImpl, detach, ensureOpen, equalsImpl, getAttributes, getChildren, getData, getIcon, getLongLabel, getShortLabel, getSubject, getTimestamp, getToolTipText, getURL, isNew, isOpen, isTrackedInNodeCache, mayHaveChildren, notifyObservers, open, postCloseImpl, refreshTimestamp, removeNodeListener, removeNodeListenerForType, removeNodeListenerForTypeHierarchy, rename, renameImpl, revert, runWhileSynchronized, save, setOpen, setTimestampDirectly, setURL, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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 oracle.javatools.data.Dirtyable
Overrides:
isDirty in class Node

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 oracle.javatools.data.Dirtyable
Overrides:
markDirty in class Node

openImpl

protected void openImpl()
                 throws java.io.IOException
Description copied from class: Node
Subclasses should override this method to customize the open() behavior.

Overrides:
openImpl in class Node
Throws:
java.io.IOException - if an I/O error occurred while opening

reportOpenException

protected void reportOpenException(java.lang.Exception e)
This routine is given a chance to handle or report an Exception that occurred during open(). Note that clients that want to receive the IOException on open() should call open() directly instead of ensureOpen().

Overrides:
reportOpenException in class Node

closeImpl

protected void closeImpl()
                  throws java.io.IOException
Description copied from class: Node
Subclasses should override this method to customize the close() behavior.

Overrides:
closeImpl in class Node
Throws:
java.io.IOException - if an I/O error occurred while closing

saveImpl

protected void saveImpl()
                 throws java.io.IOException
Description copied from class: Node
Subclasses should override this method to customize the save() behavior.

Overrides:
saveImpl in class Node
Throws:
java.io.IOException - if an I/O error occurred while saving

revertImpl

protected void revertImpl()
                   throws java.io.IOException
Description copied from class: Node
Subclasses should override this method to customize the revert() behavior.

Overrides:
revertImpl in class Node
Throws:
java.io.IOException - if an I/O error occurred while reverting

setDefaultLineTerminator

protected void setDefaultLineTerminator(TextBuffer textBuffer)
Sets up the default line terminator to use for the text buffer. Note that the TextNode will still use the regular behavior of maintaining the EOL for existing files.

Parameters:
textBuffer - the text buffer that backs up the contents of this node

createOutputStreamWriter

protected java.io.OutputStreamWriter createOutputStreamWriter(java.io.OutputStream outStream)
                                                       throws java.io.UnsupportedEncodingException
Throws:
java.io.UnsupportedEncodingException

setReadOnly

public boolean setReadOnly(boolean readOnly)
Sets the read-only status of URL for this TextNode. This will update the read-only status of the underlying TextBuffer instance appropriately. The return value indicates whether or not the setting of the read-only flag succeeded.

Parameters:
readOnly - true to make the resource indicated by the URL as read-only
Returns:
true of the setting of the read-only status flag succeeded

isReadOnly

public boolean isReadOnly()
Part of Node 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.

Overrides:
isReadOnly in class Node
See Also:
Node.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.

Overrides:
getInputStream in class Node
Returns:
an InputStream, or null if the document has no contents.
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.

getInputStream

public java.io.InputStream getInputStream(boolean warn)
                                   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.

Throws:
java.lang.IllegalStateException - if the current TextBuffer is null.
java.io.IOException

acquireTextBuffer

public final 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 TextNode 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.

Returns:
the TextBuffer instance for accessing this Document in text form

releaseTextBuffer

public final 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.


getTextBufferDirectly

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


removeTextBufferListener

public void removeTextBufferListener(TextBufferListener listener)
Informs the TextBuffer that the given listener no longer needs to track it. This helps us avoid the situation where the TextBuffer might have been GC'd, and we want to avoid having to acquire the TextBuffer (and reloading it, potentially from network storage) in order to remove the TextBufferListener.

Parameters:
listener - the text buffer listener

setLoadEncoding

public void setLoadEncoding(java.lang.String loadEncoding)
Sets a Java supported encoding name to use to create the InputStreamReader for reading data from the URL into the TextBuffer (called from revert()). This default encoding will be effective if a subclass does not override getLoadEncoding() with a different encoding determined from the TextBuffer data

Parameters:
loadEncoding - a Java supported encoding name for reading

setSaveEncoding

public void setSaveEncoding(java.lang.String saveEncoding)
Sets a Java supported encoding name to use to create the OutputStreamWriter for writing the TextBuffer to a file (called from save()). This default encoding will be effective if a subclass does not override getSaveEncoding() with a different encoding determined from the TextBuffer data

Parameters:
saveEncoding - a Java supported encoding name for writing

dataExpired

protected void dataExpired()
Cleanup any meta data based on the underlying TextBuffer. When called as a result of garbage collection, Subclasses can safely assume that the data collected was in fact the current TextBuffer and not a stale reference that has since been replaced on the fly.


getReader

public java.io.Reader getReader()
                         throws java.io.IOException
Fetch a Reader for accessing the buffer contents of this TextNode. The TextBuffer will be locked with a read-level lock for the life of this Reader. Clients must remember to close this Reader instance when it is no longer needed to avoid holding the read-level lock for longer than necessary.

Returns:
a Reader for accessing the buffer contents of this node
Throws:
java.io.IOException

hasEmptyTextBuffer

public boolean hasEmptyTextBuffer()
Checks whether the TextBuffer for this TextNode is empty (zero-length).

Returns:
true if the buffer contents for this TextNode is empty

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

public 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 revert()). The base implementation returns the explicitly set encoding, or the IDE default encoding. Subclasses (like XMLSourceNode) may override this with a different encoding determined from the URL data

Returns:
a Java supported encoding name for reading

getSaveEncoding

public 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 explicitly set encoding, or 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

createReader

protected java.io.Reader createReader(java.net.URL url)
                               throws java.io.IOException
Fetch a Reader for reading the contents of this node from the given URL. Subclasses may override this if they have special requirements for creating the Reader.

Parameters:
url - the URL to fetch a Reader for
Returns:
a Reader for loading the contents of this node from storage
Throws:
java.io.IOException

Extension SDK 10.1.3.36.73

 

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