|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.9.0) E52944-01 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.javatools.buffer.ReadTextBufferDecorator
oracle.javatools.buffer.TextBufferDecorator
public abstract class TextBufferDecorator
The TextBufferDecorator
is a base decorator for a TextBuffer
. This allows additional behavior to be added to a TextBuffer
.
Field Summary | |
---|---|
protected ForwardingTextBufferListener |
_forwarder |
protected TextBuffer |
_tbuffer The delegate TextBuffer. |
Fields inherited from class oracle.javatools.buffer.ReadTextBufferDecorator |
---|
_rbuffer |
Fields inherited from interface oracle.javatools.buffer.TextBuffer |
---|
EOL_CR, EOL_CRLF, EOL_LF, EOL_MACINTOSH, EOL_UNIX, EOL_WINDOWS, READ_ONLY, WRITABLE |
Fields inherited from interface oracle.javatools.buffer.ReadTextBuffer |
---|
LOCK_STATUS_NONE, LOCK_STATUS_READ, LOCK_STATUS_UNSUPPORTED, LOCK_STATUS_WRITE |
Constructor Summary | |
---|---|
TextBufferDecorator(TextBuffer buffer) Constructs the decorator for the delegate buffer. |
Method Summary | |
---|---|
OffsetMark |
addOffsetMark(int offset) Create a new OffsetMark at the given location. |
OffsetMark |
addOffsetMark(int offset, boolean bias) Create a new OffsetMark at the given location. |
void |
addTextBufferListener(TextBufferListener listener) Registers the given observer to begin receiving notifications when changes are made to the text buffer either by an insert or remove. |
boolean |
addWriteLockRequestListener(WriteLockRequestListener listener) Add a write lock request listener on this text buffer. |
javax.swing.undo.UndoableEdit |
append(char[] data) Appends the indicated data into the text buffer at the end of the buffer. |
void |
beginEdit() Used to instruct to the text buffer to start a compound edit such that all the changes made between this point and when the endEdit() is called should be combined into a single UndoableEdit record. |
void |
clearModified() Clears the modification status of the buffer so that it indicates that it has not been modified. |
javax.swing.undo.UndoableEdit |
endEdit() Used to indicate to the text buffer to end an in progress compound edit. |
int |
getChangeId() Fetches a change, or incarnation, number that represents the current version of the buffer contents. |
java.lang.String |
getEOLType() Fetches the EOL terminator type found in the document when its data was read with read( Reader ) . |
LineMap |
getLineMap() Fetches a line map for the text buffer. |
java.lang.String |
getPlatformEOLType() Fetches the default EOL terminator type associated with this platform as defined by the 'line.separator' property in the system properties. |
javax.swing.undo.UndoableEdit |
insert(int offset, char[] data) Inserts the indicated data into the text buffer at the given offset. |
javax.swing.undo.UndoableEdit |
insert(int offset, java.io.Reader reader) Inserts the data from a Reader instance into the text buffer at the given offset. |
boolean |
isModified() Fetches whether the buffer has been modified since its modification flag was last reset. |
boolean |
isReadOnly() Fetches whether this TextBuffer is in read-only mode or not. |
void |
read(java.io.Reader reader) Replaces the current contents of the text buffer with the data from a reader instance. |
javax.swing.undo.UndoableEdit |
remove(int offset, int count) Removes a range of data from the text buffer. |
void |
removeOffsetMark(OffsetMark offsetMark) Remove an existing OffsetMark from the text buffer. |
void |
removeTextBufferListener(TextBufferListener listener) Unregisters the given observer from the notification list so that it will no longer receive change updates. |
javax.swing.undo.UndoableEdit |
removeToEnd(int offset) Removes data from the text buffer starting at the given offset to the end of the buffer. |
void |
removeWriteLockRequestListener(WriteLockRequestListener listener) Remove a write lock request listener from this text buffer. |
void |
setEOLType(java.lang.String eolType) Changes the EOL terminator type associated with this document to the type specified. |
void |
setReadOnly(boolean readOnly) Sets the read-only mode of this TextBuffer to the requested mode. |
boolean |
tryWriteLock() Attempts to acquire a write lock on this text buffer in a non-blocking manner. |
void |
write(java.io.Writer writer) Writes the current contents of the text buffer to a writer instance for the purpose of saving the data. |
void |
write(java.io.Writer writer, boolean clearModified) Writes the current contents of the text buffer to a writer instance for the purpose of saving the data. |
void |
writeLock() Attempts to acquire a write lock on this text buffer for the purposes of writing to the text buffer - this is a blocking call. |
void |
writeLock(boolean checkIfReadOnly) Attempts to acquire a write lock on this text buffer for the purposes of writing to the text buffer - this is a blocking call. |
void |
writeUnlock() Releases a held write lock on this text buffer. |
Methods inherited from class oracle.javatools.buffer.ReadTextBufferDecorator |
---|
getChar, getChars, getLength, getLockStatus, getString, getText, readLock, readUnlock, tryReadLock |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface oracle.javatools.buffer.ReadTextBuffer |
---|
getChar, getChars, getLength, getLockStatus, getString, getText, readLock, readUnlock, tryReadLock |
Field Detail |
---|
protected TextBuffer _tbuffer
protected ForwardingTextBufferListener _forwarder
Constructor Detail |
---|
public TextBufferDecorator(TextBuffer buffer)
buffer
- the buffer that the decorator delegates toMethod Detail |
---|
public void beginEdit() throws ReadOnlyException
endEdit()
is called should be combined into a single UndoableEdit record. This guarantees to the client that the buffer will be locked for the duration between beginEdit()
and endEdit()
for data consistency. This also takes care of locking the buffer, and collecting the individual UndoableEdit
objects into a larger compound one.
Note that compound edits may not be nested - it is illegal to call beginEdit()
twice in a row without calling endEdit()
in between.
beginEdit
in interface TextBuffer
ReadOnlyException
- if the buffer is in read only modeTextBuffer.endEdit()
public javax.swing.undo.UndoableEdit endEdit()
UndoableEdit
representing all of the changes made between the calls to beginEdit()
and endEdit()
. If no modifications were made to the buffer since beginEdit()
was called, null will be returned.endEdit
in interface TextBuffer
TextBuffer.beginEdit()
public javax.swing.undo.UndoableEdit insert(int offset, char[] data) throws java.lang.IndexOutOfBoundsException, ReadOnlyException
insertUpdate()
. This will return an UndoableEdit representing this insert change unless a compound edit is in progress in which case null is returned.insert
in interface TextBuffer
offset
- the offset at which to insert the new datadata
- the text to insertjava.lang.IndexOutOfBoundsException
- if offset is invalidReadOnlyException
- if the buffer is in read only modeTextBuffer.beginEdit()
, TextBuffer.endEdit()
, TextBuffer.addTextBufferListener(oracle.javatools.buffer.TextBufferListener)
, TextBuffer.removeTextBufferListener(oracle.javatools.buffer.TextBufferListener)
public javax.swing.undo.UndoableEdit append(char[] data) throws java.lang.IndexOutOfBoundsException, ReadOnlyException
insertUpdate()
notification. The UndoableEdit representing this append will be returned unless a compound edit is in progress.append
in interface TextBuffer
data
- the text to insertReadOnlyException
- if the buffer is in read only modejava.lang.IndexOutOfBoundsException
- this exception is not expected as there are no offsets being passed. It is just to be consistent since internally, append just cals insert.TextBuffer.insert(int, char[])
, TextBuffer.beginEdit()
, TextBuffer.endEdit()
, TextBuffer.addTextBufferListener(oracle.javatools.buffer.TextBufferListener)
, TextBuffer.removeTextBufferListener(oracle.javatools.buffer.TextBufferListener)
public javax.swing.undo.UndoableEdit remove(int offset, int count) throws java.lang.IndexOutOfBoundsException, ReadOnlyException
removeUpdate()
. This will return an UndoableEdit representing this removal change unless a compound edit is in progress in which case null is returned.remove
in interface TextBuffer
offset
- the offset at which to remove datacount
- number of characters to removejava.lang.IndexOutOfBoundsException
- if offset or count is invalidReadOnlyException
- if the buffer is in read only modeTextBuffer.beginEdit()
, TextBuffer.endEdit()
public javax.swing.undo.UndoableEdit removeToEnd(int offset) throws java.lang.IndexOutOfBoundsException, ReadOnlyException
removeUpdate
notification. The UndoableEdit representing this removal will be returned unless a compound edit is in progress.removeToEnd
in interface TextBuffer
offset
- the offset at which to remove datajava.lang.IndexOutOfBoundsException
- if offset is invalidReadOnlyException
- if the buffer is in read only modeTextBuffer.remove(int, int)
, TextBuffer.beginEdit()
, TextBuffer.endEdit()
public LineMap getLineMap()
getLineMap
in interface TextBuffer
public void addTextBufferListener(TextBufferListener listener)
addTextBufferListener
in interface TextBuffer
listener
- the observer to registerReadTextBuffer.readLock()
public void removeTextBufferListener(TextBufferListener listener)
removeTextBufferListener
in interface TextBuffer
listener
- the observer to unregisterpublic void setReadOnly(boolean readOnly)
TextBuffer
to the requested mode.setReadOnly
in interface TextBuffer
readOnly
- the new mode to set, READ_ONLY to mark as read-only, WRITABLE to allow modificationspublic boolean isReadOnly()
TextBuffer
is in read-only mode or not.isReadOnly
in interface TextBuffer
public void writeLock() throws ReadOnlyException
Clients may acquire a writeLock explicitly if they have multiple changes to make in the text buffer, to ensure that the changes will not be interleaved with another client's changes.
writeLock
in interface TextBuffer
ReadOnlyException
- if the buffer is in read only modeReadTextBuffer.readLock()
public void writeLock(boolean checkIfReadOnly) throws ReadOnlyException
Clients may acquire a writeLock explicitly if they have multiple changes to make in the text buffer, to ensure that the changes will not be interleaved with another client's changes.
This version of the writeLock() method takes a boolean parameter that controls whether or not an exception is thrown if you attempt to acquire a write lock on a read only text buffer. Note that in most cases, clients should pass true (or use the writeLock() method that takes no arguments) so that they are immediately notified that write operations will fail.
writeLock
in interface TextBuffer
ReadOnlyException
- if the buffer is in read only mode and checkIfReadOnly is trueReadTextBuffer.readLock()
public boolean tryWriteLock() throws ReadOnlyException
tryWriteLock()
(i.e., where it returns true) must be matched by a call to writeUnlock()
.tryWriteLock
in interface TextBuffer
ReadOnlyException
- if the buffer is in read only modewriteLock()
, ReadTextBuffer.tryReadLock()
public void writeUnlock()
writeUnlock
in interface TextBuffer
public boolean addWriteLockRequestListener(WriteLockRequestListener listener)
TextBuffer
addWriteLockRequestListener
in interface TextBuffer
listener
- the listener to be adddedtrue
if there are already other threads waiting for the write lock, false
otherwisepublic void removeWriteLockRequestListener(WriteLockRequestListener listener)
TextBuffer
removeWriteLockRequestListener
in interface TextBuffer
listener
- the listener to be removedpublic OffsetMark addOffsetMark(int offset)
OffsetMark
at the given location. This OffsetMark
will bias to the right of the given location.addOffsetMark
in interface TextBuffer
offset
- the offset to stick toOffsetMark
for tracking the offsetOffsetMark
, removeOffsetMark(oracle.javatools.buffer.OffsetMark)
public OffsetMark addOffsetMark(int offset, boolean bias)
OffsetMark
at the given location. The bias can be either OffsetMark.BIAS_RIGHT
or OffsetMark.BIAS_LEFT
.addOffsetMark
in interface TextBuffer
offset
- the offset to stick tobias
- the side of the offset to bias or stick toOffsetMark
for tracking the offsetOffsetMark
, removeOffsetMark(oracle.javatools.buffer.OffsetMark)
public void removeOffsetMark(OffsetMark offsetMark)
OffsetMark
from the text buffer. Since OffsetMarks
persist until they are removed explicitly, clients must remove OffsetMarks
they created to ensure proper resource release.removeOffsetMark
in interface TextBuffer
offsetMark
- the mark to removeOffsetMark
, addOffsetMark(int)
public boolean isModified()
isModified
in interface TextBuffer
public void clearModified()
clearModified
in interface TextBuffer
public int getChangeId()
int's
is exhausted (at which point they may repeat.)getChangeId
in interface TextBuffer
public void read(java.io.Reader reader) throws java.io.IOException
Note that this call will reset the read-only status of the text buffer back to WRITABLE.
read
in interface TextBuffer
reader
- a Reader instance from which to read text datajava.io.IOException
- as thrown by the stream if an error occurs while reading datapublic javax.swing.undo.UndoableEdit insert(int offset, java.io.Reader reader) throws java.lang.IndexOutOfBoundsException, java.io.IOException, ReadOnlyException
insertUpdate()
. This will return an UndoableEdit representing this insert change unless a compound edit is in progress in which case null is returned.insert
in interface TextBuffer
offset
- the offset at which to insert the new datareader
- a Reader instance from which to read text datajava.lang.IndexOutOfBoundsException
- if offset is invalidReadOnlyException
- if the buffer is in read only modejava.io.IOException
- as thrown by the stream if an error occurs while reading dataTextBuffer.beginEdit()
, TextBuffer.endEdit()
, TextBuffer.addTextBufferListener(oracle.javatools.buffer.TextBufferListener)
, TextBuffer.removeTextBufferListener(oracle.javatools.buffer.TextBufferListener)
public void write(java.io.Writer writer) throws java.io.IOException
write
in interface TextBuffer
writer
- a Writer instance to which to write the text datajava.io.IOException
- as thrown by the stream if an error occurs while writing datapublic void write(java.io.Writer writer, boolean clearModified) throws java.io.IOException
write
in interface TextBuffer
writer
- a Writer instance to which to write the text dataclearModified
- whether the "modified" state of the buffer should be clearedjava.io.IOException
- as thrown by the stream if an error occurs while writing datapublic java.lang.String getPlatformEOLType()
getPlatformEOLType
in interface TextBuffer
public java.lang.String getEOLType()
read( Reader )
. The default EOL terminator is defined as the predominant (majority) terminator used in the document.getEOLType
in interface TextBuffer
public void setEOLType(java.lang.String eolType) throws ReadOnlyException
setEOLType
in interface TextBuffer
eolType
- the EOL terminator type to useReadOnlyException
- if the buffer is in read only mode
|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.9.0) E52944-01 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |