Extension SDK 10.1.2

oracle.javatools.buffer
Class TextBufferFactory

java.lang.Object
  extended byoracle.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 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 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.
 
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()

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

Extension SDK

 

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