oracle.ide.model
Class TextNode
java.lang.Object
|
+--oracle.ide.model.DefaultDisplayable
|
+--oracle.ide.model.DefaultElement
|
+--oracle.ide.model.DefaultDocument
|
+--oracle.ide.model.DefaultNode
|
+--oracle.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 DefaultNode
and should
be used for all objects that can be opened as a text file inside a
code editor.
- See Also:
TextDocument
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()
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. |
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.DefaultDocument |
attach, copyToImpl, createSubject, detach, ensureOpen, equalsImpl, getLongLabel, getShortLabel, getSubject, getTimestamp, getTimestampDirectly, getToolTipText, getURL, isNew, isOpen, notifyObservers, refreshTimestamp, setOpen, setTimestampDirectly |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface oracle.ide.model.Data |
getData |
TextNode
public TextNode()
TextNode
public TextNode(java.net.URL url)
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
- Following copied from interface:
oracle.ide.model.Dirtyable
- Returns:
true
if the data in the object has been modified.
markDirty
public void markDirty(boolean dirty)
- Two things happen:
- The superclass
markDirty(dirty)
method is
called.
- 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
- Following copied from interface:
oracle.ide.model.Dirtyable
- Parameters:
dirty
- If true
, sets the object as being
dirty; if false
, sets the object as being up-to-date.
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
- Following copied from class:
oracle.ide.model.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
- Following copied from class:
oracle.ide.model.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
- Following copied from interface:
oracle.ide.model.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.
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
- 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
.
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
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