Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.eclipse.jface.text
Class SequentialRewriteTextStore  view SequentialRewriteTextStore download SequentialRewriteTextStore.java

java.lang.Object
  extended byorg.eclipse.jface.text.SequentialRewriteTextStore
All Implemented Interfaces:
ITextStore

public class SequentialRewriteTextStore
extends java.lang.Object
implements ITextStore

A text store that optimizes a given source text store for sequential rewriting. While rewritten it keeps a list of replace command that serve as patches for the source store. Only on request, the source store is indeed manipulated by applying the patch commands to the source text store.

Since:
2.0

Nested Class Summary
private static class SequentialRewriteTextStore.Replace
          A buffered replace command.
 
Field Summary
private static boolean ASSERT_SEQUENTIALITY
          A flag to enforce sequential access.
private  java.util.List fReplaceList
          The list of buffered replacements.
private  ITextStore fSource
          The source text store
 
Constructor Summary
SequentialRewriteTextStore(ITextStore source)
          Creates a new sequential rewrite store for the given source store.
 
Method Summary
private  void commit()
          Commits all buffered replace commands.
 void dispose()
          Disposes this rewrite store.
 char get(int offset)
          Returns the character at the specified offset.
 java.lang.String get(int offset, int length)
          Returns the text of the specified character range.
private static int getDelta(SequentialRewriteTextStore.Replace replace)
          Returns the difference between the offset in the source store and the "same" offset in the rewrite store after the replace operation.
 int getLength()
          Returns number of characters stored in this text store.
 ITextStore getSourceStore()
          Returns the source store of this rewrite store.
 void replace(int offset, int length, java.lang.String text)
          Replaces the specified character range with the given text.
 void set(java.lang.String text)
          Replace the content of the text store with the given text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fReplaceList

private java.util.List fReplaceList
The list of buffered replacements.


fSource

private ITextStore fSource
The source text store


ASSERT_SEQUENTIALITY

private static final boolean ASSERT_SEQUENTIALITY
A flag to enforce sequential access.

See Also:
Constant Field Values
Constructor Detail

SequentialRewriteTextStore

public SequentialRewriteTextStore(ITextStore source)
Creates a new sequential rewrite store for the given source store.

Method Detail

getSourceStore

public ITextStore getSourceStore()
Returns the source store of this rewrite store.


replace

public void replace(int offset,
                    int length,
                    java.lang.String text)
Description copied from interface: ITextStore
Replaces the specified character range with the given text. replace(getLength(), 0, "some text") is a valid call and appends text to the end of the text store.

Specified by:
replace in interface ITextStore

set

public void set(java.lang.String text)
Description copied from interface: ITextStore
Replace the content of the text store with the given text. Convenience method for replace(0, getLength(), text.

Specified by:
set in interface ITextStore

get

public java.lang.String get(int offset,
                            int length)
Description copied from interface: ITextStore
Returns the text of the specified character range.

Specified by:
get in interface ITextStore

getDelta

private static final int getDelta(SequentialRewriteTextStore.Replace replace)
Returns the difference between the offset in the source store and the "same" offset in the rewrite store after the replace operation.


get

public char get(int offset)
Description copied from interface: ITextStore
Returns the character at the specified offset.

Specified by:
get in interface ITextStore

getLength

public int getLength()
Description copied from interface: ITextStore
Returns number of characters stored in this text store.

Specified by:
getLength in interface ITextStore

dispose

public void dispose()
Disposes this rewrite store.


commit

private void commit()
Commits all buffered replace commands.