Package gnu.lists

Class CharBuffer

All Implemented Interfaces:
BoundedHashable, Array<Char>, AVector<Char>, CharSeq, Consumable, Sequence<Char>, Externalizable, Serializable, Appendable, CharSequence, Comparable, Iterable<Char>, Collection<Char>, List<Char>, RandomAccess, SequencedCollection<Char>

public class CharBuffer extends FString
Editable character sequence using a buffer-gap implementation and self-adjusting position. Can implement (the text part of) an Emacs buffer, or a javax.swing.text.AbstractDocument.Content
See Also:
  • Constructor Details

    • CharBuffer

      public CharBuffer(FString str)
    • CharBuffer

      public CharBuffer(int initialSize)
    • CharBuffer

      protected CharBuffer()
  • Method Details

    • getArray

      public char[] getArray()
    • startPos

      public int startPos()
      Overrides:
      startPos in class AbstractSequence<Char>
    • endPos

      public int endPos()
      Overrides:
      endPos in class AbstractSequence<Char>
    • isAfterPos

      public boolean isAfterPos(int ipos)
      Description copied from class: AbstractSequence
      Tests whether the position has the "isAfter" property. I.e. if something is inserted at the position, will the iterator end up being after the new data?
      Overrides:
      isAfterPos in class SimpleVector<Char>
    • hasNext

      public boolean hasNext(int ipos)
      Overrides:
      hasNext in class AbstractSequence<Char>
    • nextPos

      public int nextPos(int ipos)
      Description copied from class: AbstractSequence
      Return the next position following the argument. The new position has the isAfter property. The argument is implicitly released (as in releasePos). Returns 0 if we are already at end of file.
      Overrides:
      nextPos in class AbstractSequence<Char>
    • copyPos

      public int copyPos(int ipos)
      Description copied from class: AbstractSequence
      Make a copy of a position int. For simple positions returns the argument. However, if the positions are magic cookies that are actively managed by the sequence (as opposed to for example a simple index), then making a copy may need to increment a reference count, or maybe allocate a new position cookie. In any case, the new position is initialized to the same offset (and isAfter property) as the original.
      Overrides:
      copyPos in class AbstractSequence<Char>
      Parameters:
      ipos - the position being copied.
      Returns:
      the new position
    • nextIndex

      public int nextIndex(int ipos)
      Description copied from class: AbstractSequence
      Get the offset from the beginning corresponding to a position cookie.
      Overrides:
      nextIndex in class FString
    • releasePos

      public void releasePos(int ipos)
      Description copied from class: AbstractSequence
      Reclaim any resources used by the given position int.
      Overrides:
      releasePos in class AbstractSequence<Char>
      Parameters:
      ipos - the Pos being free'd.
    • createPos

      public int createPos(int index, boolean isAfter)
      Description copied from class: AbstractSequence
      Generate a position at a given index. The result is a position cookie that must be free'd with releasePos.
      Overrides:
      createPos in class FString
      Parameters:
      index - offset from beginning of desired position
      isAfter - should the position have the isAfter property
    • insert

      public void insert(int where, int ch, boolean beforeMarkers)
      Overrides:
      insert in class FString
    • insert

      public void insert(int where, String str, boolean beforeMarkers)
      Overrides:
      insert in class FString
    • gapReserve

      protected void gapReserve(int where, int needed)
      Overrides:
      gapReserve in class SimpleVector<Char>
    • toString

      public String toString()
      Specified by:
      toString in interface CharSeq
      Specified by:
      toString in interface CharSequence
      Overrides:
      toString in class FString
    • writeTo

      public void writeTo(int start, int count, Appendable dest) throws IOException
      Description copied from interface: CharSeq
      Append a specified subsequence to an Appendable. An allowable implementation is: dest.append(this, start, start+count). Hence implementors of Appendable should avoid calling writeTo - though they can call getChars.
      Specified by:
      writeTo in interface CharSeq
      Overrides:
      writeTo in class FString
      Throws:
      IOException
    • writeTo

      public void writeTo(Appendable dest) throws IOException
      Specified by:
      writeTo in interface CharSeq
      Overrides:
      writeTo in class FString
      Throws:
      IOException
    • dump

      public void dump()