Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-04

oracle.javatools.buffer
Class ReadTextBufferDecorator

java.lang.Object
  extended by oracle.javatools.buffer.ReadTextBufferDecorator
All Implemented Interfaces:
ReadTextBuffer
Direct Known Subclasses:
TextBufferDecorator

public abstract class ReadTextBufferDecorator
extends java.lang.Object
implements ReadTextBuffer

The ReadTextBufferDecorator is a base decorator for a ReadTextBuffer. This allows additional behavior to be added to a ReadTextBuffer.


Field Summary
protected  ReadTextBuffer _rbuffer
          The delegate ReadTextBuffer.
 
Fields inherited from interface oracle.javatools.buffer.ReadTextBuffer
LOCK_STATUS_NONE, LOCK_STATUS_READ, LOCK_STATUS_UNSUPPORTED, LOCK_STATUS_WRITE
 
Constructor Summary
ReadTextBufferDecorator(ReadTextBuffer buffer)
          Constructs the decorator for the delegate buffer.
 
Method Summary
 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 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_rbuffer

protected final ReadTextBuffer _rbuffer
The delegate ReadTextBuffer.

Constructor Detail

ReadTextBufferDecorator

public ReadTextBufferDecorator(ReadTextBuffer buffer)
Constructs the decorator for the delegate buffer.

Parameters:
buffer - the buffer that the decorator delegates to
Method Detail

getLength

public int getLength()
Fetches the number of characters in this buffer.

Specified by:
getLength in interface ReadTextBuffer
Returns:
length of buffer

getChar

public char getChar(int offset)
             throws java.lang.IndexOutOfBoundsException
Fetches the character from the given offset.

Specified by:
getChar in interface ReadTextBuffer
Parameters:
offset - the offset in the buffer to get the character from
Returns:
the character at the given offset
Throws:
java.lang.IndexOutOfBoundsException - if offset is invalid

getChars

public char[] getChars(int offset,
                       int length)
                throws java.lang.IndexOutOfBoundsException
Fetches a number of characters from the indicated offset in the buffer. If length is zero, a zero-length array will be returned.

Specified by:
getChars in interface ReadTextBuffer
Parameters:
offset - the offset in the buffer to start from
length - number of characters to fetch
Returns:
an array containing the requested characters
Throws:
java.lang.IndexOutOfBoundsException - if offset or length are invalid

getString

public java.lang.String getString(int offset,
                                  int length)
                           throws java.lang.IndexOutOfBoundsException
Fetches a number of characters from the indicated offset in the buffer and returns it as a String. If the length is zero, a zero-length String will be returned.

Specified by:
getString in interface ReadTextBuffer
Parameters:
offset - the offset in the buffer to start from
length - number of characters to fetch
Returns:
a String containing the requested characters
Throws:
java.lang.IndexOutOfBoundsException - if offset or length are invalid

getText

public void getText(int offset,
                    int length,
                    javax.swing.text.Segment segment)
             throws java.lang.IndexOutOfBoundsException
Fetches the text contained within the given section of the TextBuffer The Segment object is provided by the caller.

Specified by:
getText in interface ReadTextBuffer
Parameters:
offset - the offset into the buffer representing the desired start of the data >= 0
length - the length of the desired data >= 0
segment - the caller's Segment object to return the data in
Throws:
java.lang.IndexOutOfBoundsException
See Also:
Document.getText(int, int)

readLock

public void readLock()
Attempts to acquire a read lock on this text buffer for the purposes of reading the buffer - this is a blocking call. Note that this is equivalent to a shared lock - multiple concurrent readers are allowed to acquire the read lock.

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.

Specified by:
readLock in interface ReadTextBuffer
See Also:
TextBuffer.getLineMap(), TextBuffer.writeLock()

tryReadLock

public boolean tryReadLock()
Attempts to acquire a read lock on this buffer in a non-blocking manner. Returns true if a read lock was acquired, or false if a read lock could not be acquired. This call returns immediately. Note that successful calls to tryReadLock() (i.e., where it returns true) must be matched by a call to readUnlock().

Specified by:
tryReadLock in interface ReadTextBuffer
Returns:
true if the lock was acquired, false if the lock was not acquired
See Also:
readLock()

readUnlock

public void readUnlock()
Releases a held read lock on this text buffer.

Specified by:
readUnlock in interface ReadTextBuffer

getLockStatus

public int getLockStatus()
Fetch the lock status for the current thread only. Returns LOCK_STATUS_WRITE if the current thread holds a write lock on this buffer (TextBuffer instances only), LOCK_STATUS_READ if the current thread holds a read lock on this buffer, LOCK_STATUS_NONE if the current thread does not hold any locks on this buffer, or LOCK_STATUS_UNSUPPORTED if this ReadTextBuffer implementation does not support locking.

Specified by:
getLockStatus in interface ReadTextBuffer
Returns:
one of the lock status constants indicating the state of the current thread's locks on this buffer

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-04

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