gnu.lists
Class CharBuffer

java.lang.Object
  extended by gnu.lists.AbstractSequence
      extended by gnu.lists.GapVector
          extended by gnu.lists.StableVector
              extended by gnu.lists.CharBuffer
All Implemented Interfaces:
CharSeq, Consumable, Sequence, java.io.Serializable, java.lang.CharSequence, java.lang.Iterable, java.util.Collection, java.util.List

public class CharBuffer
extends StableVector
implements CharSeq, java.io.Serializable

Editable character sequence using a a buffer-gap implementstion and self-adjusting position. Can implement (the text part of) an Emacs buffer, or a javax.swing.text.AbstractDocument.Content

See Also:
Serialized Form

Field Summary
 
Fields inherited from class gnu.lists.StableVector
free, FREE_POSITION, positions
 
Fields inherited from class gnu.lists.GapVector
base, gapEnd, gapStart
 
Fields inherited from interface gnu.lists.Sequence
ATTRIBUTE_VALUE, BOOLEAN_VALUE, CDATA_VALUE, CHAR_VALUE, COMMENT_VALUE, DOCUMENT_VALUE, DOUBLE_VALUE, ELEMENT_VALUE, EOF_VALUE, eofValue, FLOAT_VALUE, INT_S16_VALUE, INT_S32_VALUE, INT_S64_VALUE, INT_S8_VALUE, INT_U16_VALUE, INT_U32_VALUE, INT_U64_VALUE, INT_U8_VALUE, OBJECT_VALUE, PRIM_VALUE, PROCESSING_INSTRUCTION_VALUE, TEXT_BYTE_VALUE
 
Constructor Summary
protected CharBuffer()
           
  CharBuffer(FString str)
           
  CharBuffer(int initialSize)
           
 
Method Summary
 char charAt(int index)
           
 void consume(int start, int count, Consumer dest)
           
 void delete(int where, int count)
           
 void dump()
           
 void fill(char value)
          Set all the elements to a given character.
 void fill(int fromIndex, int toIndex, char value)
           
 char[] getArray()
           
 void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
          Copy characters into a destination buffer.
 void insert(int where, java.lang.String str, boolean beforeMarkers)
           
 int length()
          Get length of string, in characters.
 void setCharAt(int index, char value)
           
 java.lang.CharSequence subSequence(int start, int end)
           
 java.lang.String toString()
           
 void writeTo(int start, int count, java.io.Writer dest)
          Write out (part of) this string.
 void writeTo(java.io.Writer dest)
           
 
Methods inherited from class gnu.lists.StableVector
addPos, adjustPositions, allocPositionIndex, chainFreelist, consumePosRange, copyPos, createPos, endPos, fillPosRange, gapReserve, hasNext, isAfterPos, nextIndex, nextPos, releasePos, removePosRange, shiftGap, startPos, unchainFreelist
 
Methods inherited from class gnu.lists.GapVector
add, fill, gapReserve, get, getNextKind, getSegment, set, size
 
Methods inherited from class gnu.lists.AbstractSequence
add, addAll, addAll, clear, compare, compare, compare, consume, consumeNext, contains, containsAll, createRelativePos, elements, equals, equals, fill, firstAttributePos, firstChildPos, firstChildPos, fromEndIndex, get, getAttribute, getAttributeLength, getContainingSequenceSize, getEffectiveIndex, getIndexDifference, getIterator, getIterator, getIteratorAtPos, getLowBound, getNextTypeName, getNextTypeObject, getPosNext, getPosPrevious, getSize, gotoAttributesStart, gotoChildrenStart, gotoParent, hashCode, hasPrevious, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, nextIndex, nextMatching, parentPos, previousPos, rank, remove, remove, removeAll, removePos, retainAll, set, setPosNext, setPosPrevious, stableCompare, subList, subSequence, subSequencePos, toArray, toArray, toString, unsupported, unsupportedException
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gnu.lists.Sequence
elements, fill, get, isEmpty, set, size
 
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, subList, toArray, toArray
 
Methods inherited from interface gnu.lists.Consumable
consume
 

Constructor Detail

CharBuffer

public CharBuffer(FString str)

CharBuffer

public CharBuffer(int initialSize)

CharBuffer

protected CharBuffer()
Method Detail

length

public int length()
Description copied from interface: CharSeq
Get length of string, in characters. Synonym for size(), for compatibility with String and StringBuffer.

Specified by:
length in interface CharSeq
Specified by:
length in interface java.lang.CharSequence

charAt

public char charAt(int index)
Specified by:
charAt in interface CharSeq
Specified by:
charAt in interface java.lang.CharSequence

getChars

public void getChars(int srcBegin,
                     int srcEnd,
                     char[] dst,
                     int dstBegin)
Copy characters into a destination buffer. Same interface as java.lang.String's getChars.

Specified by:
getChars in interface CharSeq

setCharAt

public void setCharAt(int index,
                      char value)
Specified by:
setCharAt in interface CharSeq

subSequence

public java.lang.CharSequence subSequence(int start,
                                          int end)
Specified by:
subSequence in interface CharSeq
Specified by:
subSequence in interface java.lang.CharSequence

fill

public void fill(int fromIndex,
                 int toIndex,
                 char value)
Specified by:
fill in interface CharSeq

fill

public final void fill(char value)
Set all the elements to a given character.

Specified by:
fill in interface CharSeq

getArray

public char[] getArray()

delete

public void delete(int where,
                   int count)

insert

public void insert(int where,
                   java.lang.String str,
                   boolean beforeMarkers)

consume

public void consume(int start,
                    int count,
                    Consumer dest)
Specified by:
consume in interface CharSeq

toString

public java.lang.String toString()
Specified by:
toString in interface CharSeq
Specified by:
toString in interface java.lang.CharSequence
Overrides:
toString in class AbstractSequence

writeTo

public void writeTo(int start,
                    int count,
                    java.io.Writer dest)
             throws java.io.IOException
Description copied from interface: CharSeq
Write out (part of) this string.

Specified by:
writeTo in interface CharSeq
Parameters:
start - index of initial character to write
count - number of characters to write
dest - where to write the characters
Throws:
java.io.IOException

writeTo

public void writeTo(java.io.Writer dest)
             throws java.io.IOException
Specified by:
writeTo in interface CharSeq
Throws:
java.io.IOException

dump

public void dump()