public class GuardedTextBuffer extends TextBufferDecorator
A range of offsets can be marked as guarded or unguarded via the guard and unguard methods. The guard can be turned on or off via setGuardActive().
Any attempt to modify a guarded section, when the guard is active, will result in a GuardedException.
_forwarder, _tbuffer_rbufferEOL_CR, EOL_CRLF, EOL_LF, EOL_MACINTOSH, EOL_UNIX, EOL_WINDOWS, READ_ONLY, WRITABLELOCK_STATUS_NONE, LOCK_STATUS_READ, LOCK_STATUS_UNSUPPORTED, LOCK_STATUS_WRITE| Constructor and Description | 
|---|
GuardedTextBuffer(TextBuffer textBuffer)
Create a guarded text buffer by wrapping a TextBuffer. 
 | 
GuardedTextBuffer(TextBuffer textBuffer, boolean forwardListeners)
Create a guarded text buffer by wrapping a TextBuffer. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
addGuardedTextBufferListener(GuardedTextBufferListener listener)
Add a listener to be notified when sections become guarded and unguarded. 
 | 
int | 
findInsertableOffset(int offset, int count, boolean admitInsertToGuardedBeginning)
Finds first insertable unguarded offset for specified range. 
 | 
java.util.List<OffsetRegion> | 
getRegions()  | 
void | 
guard(int offset, int length)
Guard a section of the buffer. 
 | 
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 | 
isGuardActive()  | 
boolean | 
isOffsetGuarded(int offset)  | 
boolean | 
isOffsetRangeGuarded(int offset, int count)  | 
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 | 
removeGuardedTextBufferListener(GuardedTextBufferListener listener)  | 
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 | 
setGuardActive(boolean isGuardActive)
Turn the guard on or off. 
 | 
void | 
unguard(int offset, int length)
Stop guarding a section of the buffer. 
 | 
addOffsetMark, addOffsetMark, addTextBufferListener, addWriteLockRequestListener, append, beginEdit, clearModified, endEdit, getChangeId, getEOLType, getLineMap, getPlatformEOLType, getTextBuffer, isModified, isReadOnly, removeOffsetMark, removeTextBufferListener, removeWriteLockRequestListener, setEOLType, setReadOnly, setTextBuffer, tryWriteLock, write, write, writeLock, writeLock, writeLockInterruptibly, writeUnlockgetChar, getChars, getLength, getLockStatus, getString, getText, readLock, readLockInterruptibly, readUnlock, tryReadLockclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetChar, getChars, getLength, getLockStatus, getString, getText, readLock, readLockInterruptibly, readUnlock, tryReadLockpublic GuardedTextBuffer(TextBuffer textBuffer)
textBuffer -public GuardedTextBuffer(TextBuffer textBuffer, boolean forwardListeners)
textBuffer -forwardListeners - whether listeners attached to GuardedTextBuffer should be attached to the delegate buffer, use true if you don't listen to the delegate buffer directly
public void guard(int offset,
         int length)
offset -length -
public void unguard(int offset,
           int length)
offset -length -public boolean isOffsetGuarded(int offset)
offset -
public boolean isOffsetRangeGuarded(int offset,
                           int count)
offset -count -
public int findInsertableOffset(int offset,
                       int count,
                       boolean admitInsertToGuardedBeginning)
admitInsertToGuardedBeginning if insert should be admissible at the beginning of a guarded block - possibility to insert between two adjacent guarded blocks. See insert(int, char[]) implementation.offset - Start of offsetcount - Length of offsetadmitInsertToGuardedBeginning - Should be insert at beginning of guarded block admissible?public java.util.List<OffsetRegion> getRegions()
public void setGuardActive(boolean isGuardActive)
isGuardActive -public boolean isGuardActive()
public javax.swing.undo.UndoableEdit insert(int offset,
                                   char[] data)
                                     throws java.lang.IndexOutOfBoundsException,
                                            ReadOnlyException
TextBufferDecoratorinsertUpdate(). 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 TextBufferinsert in class TextBufferDecoratoroffset - 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 insert(int offset,
                                   java.io.Reader reader)
                                     throws java.lang.IndexOutOfBoundsException,
                                            java.io.IOException,
                                            ReadOnlyException
TextBufferDecoratorinsertUpdate(). 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 TextBufferinsert in class TextBufferDecoratoroffset - the offset at which to insert the new datareader - a Reader instance from which to read text datajava.lang.IndexOutOfBoundsException - if offset is invalidjava.io.IOException - as thrown by the stream if an error occurs while reading dataReadOnlyException - 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 remove(int offset,
                                   int count)
                                     throws java.lang.IndexOutOfBoundsException,
                                            ReadOnlyException
TextBufferDecoratorremoveUpdate(). 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 TextBufferremove in class TextBufferDecoratoroffset - 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
TextBufferDecoratorremoveUpdate notification. The UndoableEdit representing this removal will be returned unless a compound edit is in progress.removeToEnd in interface TextBufferremoveToEnd in class TextBufferDecoratoroffset - 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 void read(java.io.Reader reader)
          throws java.io.IOException
TextBufferDecoratorNote that this call will reset the read-only status of the text buffer back to WRITABLE.
read in interface TextBufferread in class TextBufferDecoratorreader - a Reader instance from which to read text datajava.io.IOException - as thrown by the stream if an error occurs while reading datapublic void addGuardedTextBufferListener(GuardedTextBufferListener listener)
listener -public void removeGuardedTextBufferListener(GuardedTextBufferListener listener)