Package gnu.lists
Class CharBuffer
- java.lang.Object
-
- gnu.lists.AbstractSequence<E>
-
- gnu.lists.SimpleVector<E>
-
- gnu.lists.AbstractCharVector<Char>
-
- gnu.lists.FString
-
- gnu.lists.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
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:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class gnu.lists.AbstractCharVector
data, empty
-
Fields inherited from class gnu.lists.SimpleVector
COPY_ON_WRITE, GAP_FLAG, info, MAX_GAP_SIZE, READ_ONLY_FLAG, SHARED_FLAG, SUBRANGE_FLAG, VERY_SIMPLE_FLAG
-
Fields inherited from class gnu.lists.AbstractSequence
noInts
-
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
Constructors Modifier Constructor Description protectedCharBuffer()CharBuffer(int initialSize)CharBuffer(FString str)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcopyPos(int ipos)Make a copy of a position int.intcreatePos(int index, boolean isAfter)Generate a position at a given index.voiddump()intendPos()protected voidgapReserve(int where, int needed)char[]getArray()booleanhasNext(int ipos)voidinsert(int where, int ch, boolean beforeMarkers)voidinsert(int where, String str, boolean beforeMarkers)booleanisAfterPos(int ipos)Tests whether the position has the "isAfter" property.intnextIndex(int ipos)Get the offset from the beginning corresponding to a position cookie.intnextPos(int ipos)Return the next position following the argument.voidreleasePos(int ipos)Reclaim any resources used by the given position int.intstartPos()StringtoString()voidwriteTo(int start, int count, Appendable dest)Append a specified subsequence to anAppendable.voidwriteTo(Appendable dest)-
Methods inherited from class gnu.lists.FString
addAll, addAllStrings, alloc, append, append, append, append, appendCharacter, characterAt, consumePosRange, copy, createRelativePos, effectiveIndex, equals, get, getElementKind, getRaw, getTag, indexOf, insertRepeated, lastIndexOf, newInstance, prepend, prepend, prependCharacter, replace, replace, replace, set, setCharacterAt, setCharAt, setCharAtBuffer, setRaw, shift, size, subSequence, substring, toCharArray
-
Methods inherited from class gnu.lists.AbstractCharVector
charAt, clearBuffer, compareTo, compareTo, compareTo, copyBuffer, ensureBufferLength, equals, getBuffer, getBufferLength, getCharRaw, getChars, hashCode, length, openReader, openReader, setBuffer
-
Methods inherited from class gnu.lists.SimpleVector
add, add, addPos, addSpace, asImmutable, checkCanWrite, delete, doCopyOnWrite, fill, forEach, gapReserveGeneric, getGapEnd, getGapSize, getGapStart, getOffsetBits, getRowMajor, getSegment, getSegment, getSegmentReadOnly, getSizeBits, isGapBuffer, isReadOnly, isSubRange, isVerySimple, readExternal, setGapBounds, setGapBounds, setInfoField, setReadOnly, toDataArray, vsize, writeExternal
-
Methods inherited from class gnu.lists.AbstractSequence
addAll, addAll, badRank, boundedHash, checkRank, clear, compare, compare, compare, consume, consume, consumeNext, contains, containsAll, effectiveIndex, effectiveIndex, effectiveIndex, effectiveIndex, elements, equals, fill, fillPosRange, firstAttributePos, firstChildPos, firstChildPos, fromEndIndex, get, get, get, get, getAttribute, getAttributeLength, getBooleanRaw, getByteRaw, getContainingSequenceSize, getDoubleRaw, getFloatRaw, getIndexDifference, getInt, getInt, getInt, getInt, getInt, getIntRaw, getIterator, getIterator, getIteratorAtPos, getLongRaw, getLowBound, getNextKind, getNextTypeName, getNextTypeObject, getPosNext, getPosPrevious, getShortRaw, getSize, getSize, gotoAttributesStart, gotoChildrenStart, gotoParent, hasPrevious, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, nextIndex, nextMatching, parentPos, previousPos, rank, remove, remove, removeAll, removePos, removePosRange, retainAll, set, setAt, setPosNext, setPosPrevious, stableCompare, subList, subSequence, subSequencePos, toArray, toArray, toString, unsupported, unsupportedException
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface gnu.lists.Array
effectiveIndex, effectiveIndex, effectiveIndex, effectiveIndex, get, get, get, get, getBooleanRaw, getByteRaw, getDoubleRaw, getFloatRaw, getInt, getInt, getInt, getInt, getInt, getIntRaw, getLongRaw, getLowBound, getShortRaw, getSize, getSize, isEmpty, rank, set
-
Methods inherited from interface gnu.kawa.util.BoundedHashable
boundedHash
-
Methods inherited from interface java.lang.CharSequence
chars, codePoints
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface gnu.lists.Consumable
consume
-
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, sort, spliterator, subList, toArray, toArray
-
-
-
-
Constructor Detail
-
CharBuffer
public CharBuffer(FString str)
-
CharBuffer
public CharBuffer(int initialSize)
-
CharBuffer
protected CharBuffer()
-
-
Method Detail
-
getArray
public char[] getArray()
-
startPos
public int startPos()
- Overrides:
startPosin classAbstractSequence<Char>
-
endPos
public int endPos()
- Overrides:
endPosin classAbstractSequence<Char>
-
isAfterPos
public boolean isAfterPos(int ipos)
Description copied from class:AbstractSequenceTests 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:
isAfterPosin classSimpleVector<Char>
-
hasNext
public boolean hasNext(int ipos)
- Overrides:
hasNextin classAbstractSequence<Char>
-
nextPos
public int nextPos(int ipos)
Description copied from class:AbstractSequenceReturn 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:
nextPosin classAbstractSequence<Char>
-
copyPos
public int copyPos(int ipos)
Description copied from class:AbstractSequenceMake 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:
copyPosin classAbstractSequence<Char>- Parameters:
ipos- the position being copied.- Returns:
- the new position
-
nextIndex
public int nextIndex(int ipos)
Description copied from class:AbstractSequenceGet the offset from the beginning corresponding to a position cookie.
-
releasePos
public void releasePos(int ipos)
Description copied from class:AbstractSequenceReclaim any resources used by the given position int.- Overrides:
releasePosin classAbstractSequence<Char>- Parameters:
ipos- the Pos being free'd.
-
createPos
public int createPos(int index, boolean isAfter)Description copied from class:AbstractSequenceGenerate a position at a given index. The result is a position cookie that must be free'd with releasePos.
-
insert
public void insert(int where, int ch, boolean beforeMarkers)
-
insert
public void insert(int where, String str, boolean beforeMarkers)
-
gapReserve
protected void gapReserve(int where, int needed)- Overrides:
gapReservein classSimpleVector<Char>
-
toString
public String toString()
-
writeTo
public void writeTo(int start, int count, Appendable dest) throws IOExceptionDescription copied from interface:CharSeqAppend a specified subsequence to anAppendable. An allowable implementation is:dest.append(this, start, start+count). Hence implementors ofAppendableshould avoid callingwriteTo- though they can callgetChars.- Specified by:
writeToin interfaceCharSeq- Overrides:
writeToin classFString- Throws:
IOException
-
writeTo
public void writeTo(Appendable dest) throws IOException
- Specified by:
writeToin interfaceCharSeq- Overrides:
writeToin classFString- Throws:
IOException
-
dump
public void dump()
-
-