Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.2.0)

E17493-03


oracle.javatools.buffer
Class TextBufferFactory

java.lang.Object
  extended by oracle.javatools.buffer.TextBufferFactory


public final class TextBufferFactory
extends java.lang.Object

The TextBufferFactory is a static factory class for creating TextBuffer instances for use. This is done in order to separate our published API from our implementation details from TextBuffer clients.


Method Summary
static TextBuffer createArrayTextBuffer()
          Creates a new empty instance of the TextBuffer using a flat array implementation.
static java.text.CharacterIterator createCharacterIterator(ReadTextBuffer textBuffer)
          Constructs a new CharacterIterator wrapper for the given text buffer instance so that the buffer can be used with a BreakIterator in the java.text package.
static TextBuffer createExpirableTextBufferSnapshot(TextBuffer textBuffer)
          Constructs an expirable snapshot of the specified TextBuffer.
static TextBuffer createGapTextBuffer()
          Creates a new empty instance of the TextBuffer using a gap buffer implementation.
static java.io.Reader createReader(ReadTextBuffer textBuffer)
          Constructs a new Reader wrapper for the given text buffer instance so that the buffer can be read using the Reader API.
static java.io.Reader createReader(ReadTextBuffer textBuffer, int startOffset)
          Constructs a new Reader wrapper for the given text buffer instance so that the buffer can be read using the Reader API.
static TextBuffer createReadOnlyTextBufferWrapper(TextBuffer textBuffer)
          Creates a read-only wrapper that implements the TextBuffer interface around the specified interface.
static ReadTextBuffer createReadTextBuffer(char[] dataSource)
          Creates a ReadTextBuffer wrapper implementation for the given String data source so that it can be used with other classes that accept a ReadTextBuffer such as the parser package.
static ReadTextBuffer createReadTextBuffer(java.lang.String dataSource)
          Creates a ReadTextBuffer wrapper implementation for the given String data source so that it can be used with other classes that accept a ReadTextBuffer such as the parser package.
static TextBuffer createTextBuffer()
          Creates a new empty instance of the TextBuffer using a default implementation.
static TextBuffer createTextBuffer(ReadWriteLock lockToUse)
          Creates a new empty instance of the TextBuffer using a default implementation.

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Method Detail

createTextBuffer

public static TextBuffer createTextBuffer()
Creates a new empty instance of the TextBuffer using a default implementation. The current default is to use a gap implementation.
Returns:
an empty, newly created TextBuffer instance
See Also:
createGapTextBuffer()

createTextBuffer

public static TextBuffer createTextBuffer(ReadWriteLock lockToUse)
Creates a new empty instance of the TextBuffer using a default implementation. The current default is to use a gap implementation.

The specified lock will be used for locking for the buffer. This allows clients to coordinate locking with that used by the TextBuffer.

Parameters:
lockToUse - the ReadWriteLock instance to use for this buffer instance
Returns:
an empty, newly created TextBuffer instance
See Also:
ReadWriteLock

createArrayTextBuffer

public static TextBuffer createArrayTextBuffer()
Creates a new empty instance of the TextBuffer using a flat array implementation. This implementation uses a flat array with extra space at the end to store the data. This performs well when the buffer contains nearly static data as it requires less overhead when accessing (reading) the buffer as compared to the gap implementation.
Returns:
an empty, newly created TextBuffer instance

createGapTextBuffer

public static TextBuffer createGapTextBuffer()
Creates a new empty instance of the TextBuffer using a gap buffer implementation. This implementation uses an array containing a gap to store the data. This performs well for typical edits which are frequently clustered together.
Returns:
an empty, newly created TextBuffer instance

createReadOnlyTextBufferWrapper

public static TextBuffer createReadOnlyTextBufferWrapper(TextBuffer textBuffer)
Creates a read-only wrapper that implements the TextBuffer interface around the specified interface. This wrapper can be provided to other clients (like an editor) to allow it to read the contents of the text buffer, but not modify it.
Parameters:
textBuffer - the source text buffer to wrap
Returns:
a read-only TextBuffer wrapper

createReadTextBuffer

public static ReadTextBuffer createReadTextBuffer(java.lang.String dataSource)
Creates a ReadTextBuffer wrapper implementation for the given String data source so that it can be used with other classes that accept a ReadTextBuffer such as the parser package.
Parameters:
dataSource - the String dataSource
Returns:
the ReadTextBuffer wrapper instance

createReadTextBuffer

public static ReadTextBuffer createReadTextBuffer(char[] dataSource)
Creates a ReadTextBuffer wrapper implementation for the given String data source so that it can be used with other classes that accept a ReadTextBuffer such as the parser package.
Parameters:
dataSource - the String dataSource
Returns:
the ReadTextBuffer wrapper instance

createCharacterIterator

public static java.text.CharacterIterator createCharacterIterator(ReadTextBuffer textBuffer)
Constructs a new CharacterIterator wrapper for the given text buffer instance so that the buffer can be used with a BreakIterator in the java.text package. It is the responsibility of the caller to guarantee that the contents of the text buffer do not change for the duration that this CharacterIterator is used.
Parameters:
textBuffer - the text buffer to provide a CharacterIterator wrapper on top of
Returns:
a CharacterIterator that can be used to iterate over the contents of the text buffer

createReader

public static java.io.Reader createReader(ReadTextBuffer textBuffer)
Constructs a new Reader wrapper for the given text buffer instance so that the buffer can be read using the Reader API. Note that as long as the Reader wrapper is open, the text buffer will be held with a read lock. Clients should make sure to close() the Reader when it is no longer needed.
Parameters:
textBuffer - the text buffer to provide a Reader wrapper on top of
Returns:
a Reader that can be used to read the contents of the text buffer

createReader

public static java.io.Reader createReader(ReadTextBuffer textBuffer,
                                          int startOffset)
Constructs a new Reader wrapper for the given text buffer instance so that the buffer can be read using the Reader API. Note that as long as the Reader wrapper is open, the text buffer will be held with a read lock. Clients should make sure to close() the Reader when it is no longer needed.
Parameters:
textBuffer - the text buffer to provide a Reader wrapper on top of
Returns:
a Reader that can be used to read the contents of the text buffer

createExpirableTextBufferSnapshot

public static TextBuffer createExpirableTextBufferSnapshot(TextBuffer textBuffer)
Constructs an expirable snapshot of the specified TextBuffer. This snapshot provides access to the contents of the buffer as long as the buffer has not been modified since the snapshot was created. Once the buffer is modified, any access through the snapshot will generate an ExpiredTextBufferException. Note the only supported operations on this snapshot are for fetching the buffer contents or buffer attributes. All other operations will generate an UnsupportedOperationException.
Parameters:
textBuffer - the textbuffer to create a snapshot on top of
Returns:
an expirable snapshot of the specified text buffer

Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.2.0)

E17493-03


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