public abstract class ReadTextBufferDecorator extends java.lang.Object implements ReadTextBuffer
ReadTextBufferDecorator is a base decorator for a
ReadTextBuffer. This allows additional behavior to be added
to a ReadTextBuffer.| Modifier and Type | Field and Description |
|---|---|
protected ReadTextBuffer |
_rbuffer
The delegate ReadTextBuffer.
|
LOCK_STATUS_NONE, LOCK_STATUS_READ, LOCK_STATUS_UNSUPPORTED, LOCK_STATUS_WRITE| Constructor and Description |
|---|
ReadTextBufferDecorator(ReadTextBuffer buffer)
Constructs the decorator for the delegate buffer.
|
| Modifier and Type | Method and Description |
|---|---|
char |
getChar(int offset)
Fetches the character from the given offset.
|
char[] |
getChars(int offset,
int length)
Fetches a number of characters from the indicated offset in the
buffer.
|
int |
getLength()
Fetches the number of characters in this buffer.
|
int |
getLockStatus()
Fetch the lock status for the current thread only.
|
java.lang.String |
getString(int offset,
int length)
Fetches a number of characters from the indicated offset in the
buffer and returns it as a String.
|
void |
getText(int offset,
int length,
javax.swing.text.Segment segment)
Fetches the text contained within the given section of the
TextBuffer The Segment object is
provided by the caller. |
void |
readLock()
Attempts to acquire a read lock on this text buffer for the
purposes of reading the buffer - this is a blocking call.
|
void |
readLockInterruptibly()
Attempts to acquire a read lock on this text buffer for the
purposes of reading the buffer - this is a blocking call.
|
void |
readUnlock()
Releases a held read lock on this text buffer.
|
boolean |
tryReadLock()
Attempts to acquire a read lock on this buffer in a non-blocking
manner.
|
protected final ReadTextBuffer _rbuffer
public ReadTextBufferDecorator(ReadTextBuffer buffer)
buffer - the buffer that the decorator delegates topublic int getLength()
getLength in interface ReadTextBufferpublic char getChar(int offset)
throws java.lang.IndexOutOfBoundsException
getChar in interface ReadTextBufferoffset - the offset in the buffer to get the character fromjava.lang.IndexOutOfBoundsException - if offset is invalidpublic char[] getChars(int offset,
int length)
throws java.lang.IndexOutOfBoundsException
getChars in interface ReadTextBufferoffset - the offset in the buffer to start fromlength - number of characters to fetchjava.lang.IndexOutOfBoundsException - if offset or length are invalidpublic java.lang.String getString(int offset,
int length)
throws java.lang.IndexOutOfBoundsException
getString in interface ReadTextBufferoffset - the offset in the buffer to start fromlength - number of characters to fetchjava.lang.IndexOutOfBoundsException - if offset or length are invalidpublic void getText(int offset,
int length,
javax.swing.text.Segment segment)
throws java.lang.IndexOutOfBoundsException
TextBuffer The Segment object is
provided by the caller.getText in interface ReadTextBufferoffset - the offset into the buffer representing the desired
start of the data >= 0length - the length of the desired data >= 0segment - the caller's Segment object to return the data injava.lang.IndexOutOfBoundsExceptionDocument.getText(int, int)public void readLock()
Note that for TextBuffer objects, a call to
readLock() must be matched by a call to readUnlock() even if
nested within a writeLock()/writeUnlock(). This is to help
guarantee correctness.
readLock in interface ReadTextBufferTextBuffer.getLineMap(),
TextBuffer.writeLock()public void readLockInterruptibly()
throws java.lang.InterruptedException
Note that for TextBuffer objects, a call to
readLock() must be matched by a call to readUnlock() even if
nested within a writeLock()/writeUnlock(). This is to help
guarantee correctness.
readLockInterruptibly in interface ReadTextBufferjava.lang.InterruptedException - if the current thread is in or gets put in
the interrupted state. The interrupted state
is cleared when this exception is thrown.TextBuffer.getLineMap(),
TextBuffer.writeLock()public boolean tryReadLock()
tryReadLock() (i.e.,
where it returns true) must be matched by a call to
readUnlock().tryReadLock in interface ReadTextBufferreadLock()public void readUnlock()
readUnlock in interface ReadTextBufferpublic int getLockStatus()
getLockStatus in interface ReadTextBuffer