Package gnu.lists
Class FString
- java.lang.Object
-
- gnu.lists.AbstractSequence<E>
-
- gnu.lists.SimpleVector<E>
-
- gnu.lists.AbstractCharVector<Char>
-
- gnu.lists.FString
-
- All Implemented Interfaces:
BoundedHashable,Array<Char>,AVector<Char>,CharSeq,Consumable,Sequence<Char>,Externalizable,Serializable,Appendable,CharSequence,Comparable,Iterable<Char>,Collection<Char>,List<Char>,RandomAccess
- Direct Known Subclasses:
CharBuffer
public class FString extends AbstractCharVector<Char> implements Appendable, CharSeq, Consumable
Simple adjustable-length vector whose elements are 32-bit code points Used for the Scheme string type. This isn't a regular SimpleVector because character indexing isn't a simple lookup. "Sub-range mode" is not used (at least not for Kawa Scheme): if you need an immutable sub-string, use an IString (or java.lang.String).- 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 Constructor Description FString()FString(char[] values)Create an FString from a char[].FString(char[] buffer, int offset, int length)This constructor makes a copy.FString(int num)FString(int num, int value)FString(CharSequence seq)FString(CharSequence seq, int offset, int length)Copy a substring of a CharSequence.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddAll(CharSequence s)voidaddAllStrings(Object[] args, int startIndex)Append arguments to this FString.static FStringalloc(int sz)Create a empty string, but with a given initial buffer size.FStringappend(char c)FStringappend(CharSequence csq)FStringappend(CharSequence csq, int start, int end)FStringappend(Object obj)FStringappendCharacter(int c)Append a Unicode code point.intcharacterAt(int index)voidconsumePosRange(int iposStart, int iposEnd, Consumer out)FStringcopy(int start, int end)intcreatePos(int index, boolean isAfter)Generate a position at a given index.intcreateRelativePos(int pos, int delta, boolean isAfter)inteffectiveIndex(int index)booleanequals(Object obj)Must override, since we override hashCode.Charget(int index)See java.util.List.intgetElementKind()ChargetRaw(int index)Given an "effective index", return element as object.StringgetTag()This is convenience hack for printing "uniform vectors" (srfi 4).intindexOf(int ch, int fromChar)voidinsert(int where, int ch, boolean beforeMarkers)voidinsert(int where, String str, boolean beforeMarkers)voidinsertRepeated(int where, int value, int count)intlastIndexOf(int ch, int fromChar)protected FStringnewInstance(int newLength)protected intnextIndex(int ipos)Get the offset from the beginning corresponding to a position cookie.FStringprepend(CharSequence str, int start, int end)FStringprepend(Object obj)FStringprependCharacter(int c)voidreplace(int where, char[] chars, int start, int count)voidreplace(int where, String string)voidreplace(CharSequence src, int srcStart, int srcEnd, int dstStart, int dstEnd)Replace a substring of this string with another.Charset(int index, Char value)See java.util.List.voidsetCharacterAt(int index, int ch)voidsetCharAt(int index, char ch)voidsetCharAtBuffer(int index, char ch)voidsetRaw(int index, Char value)Given an "effective index", set selected element.voidshift(int srcStart, int dstStart, int count)intsize()See java.util.List.CharSeqsubSequence(int start, int end)Stringsubstring(int start, int end)char[]toCharArray()Return a char[] contain the characters of this string.StringtoString()voidwriteTo(int start, int count, Appendable dest)Append a specified subsequence to anAppendable.voidwriteTo(Appendable dest)-
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, gapReserve, gapReserveGeneric, getGapEnd, getGapSize, getGapStart, getOffsetBits, getRowMajor, getSegment, getSegment, getSegmentReadOnly, getSizeBits, isAfterPos, 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, copyPos, effectiveIndex, effectiveIndex, effectiveIndex, effectiveIndex, elements, endPos, 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, hasNext, hasPrevious, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, nextIndex, nextMatching, nextPos, parentPos, previousPos, rank, releasePos, remove, remove, removeAll, removePos, removePosRange, retainAll, set, setAt, setPosNext, setPosPrevious, stableCompare, startPos, 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
-
FString
public FString()
-
FString
public FString(int num)
-
FString
public FString(int num, int value)
-
FString
public FString(char[] values)
Create an FString from a char[]. Note that this contructor does *not* copy the argument.
-
FString
public FString(char[] buffer, int offset, int length)This constructor makes a copy.
-
FString
public FString(CharSequence seq)
-
FString
public FString(CharSequence seq, int offset, int length)
Copy a substring of a CharSequence.- Parameters:
offset- - start offset in 16-bit char unitslength- - length in 16-bit char units
-
-
Method Detail
-
size
public int size()
Description copied from interface:SequenceSee java.util.List.
-
effectiveIndex
public int effectiveIndex(int index)
- Specified by:
effectiveIndexin interfaceArray<Char>- Overrides:
effectiveIndexin classSimpleVector<Char>- Parameters:
index- measured in Unicode code points (characters)
-
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.- Overrides:
createPosin classAbstractSequence<Char>- Parameters:
index- offset from beginning of desired positionisAfter- should the position have the isAfter property
-
nextIndex
protected int nextIndex(int ipos)
Description copied from class:AbstractSequenceGet the offset from the beginning corresponding to a position cookie.- Overrides:
nextIndexin classAbstractSequence<Char>
-
createRelativePos
public int createRelativePos(int pos, int delta, boolean isAfter)- Overrides:
createRelativePosin classAbstractSequence<Char>
-
alloc
public static FString alloc(int sz)
Create a empty string, but with a given initial buffer size.
-
getRaw
public final Char getRaw(int index)
Description copied from interface:ArrayGiven an "effective index", return element as object.
-
get
public final Char get(int index)
Description copied from interface:SequenceSee java.util.List.
-
indexOf
public int indexOf(int ch, int fromChar)- Parameters:
fromChar- offset in 16-bit code units
-
lastIndexOf
public int lastIndexOf(int ch, int fromChar)- Parameters:
fromChar- offset in 16-bit code units
-
set
public Char set(int index, Char value)
Description copied from interface:SequenceSee java.util.List.
-
setRaw
public final void setRaw(int index, Char value)Description copied from class:AbstractSequenceGiven an "effective index", set selected element.
-
characterAt
public final int characterAt(int index)
- Parameters:
index- offset in 16-bit code units
-
toCharArray
public char[] toCharArray()
Return a char[] contain the characters of this string. It is unspecified if the result is a copy or shares with this FString.
-
shift
public void shift(int srcStart, int dstStart, int count)- Overrides:
shiftin classSimpleVector<Char>
-
copy
public FString copy(int start, int end)
-
addAll
public boolean addAll(CharSequence s)
-
insert
public void insert(int where, int ch, boolean beforeMarkers)
-
insert
public void insert(int where, String str, boolean beforeMarkers)
-
addAllStrings
public void addAllStrings(Object[] args, int startIndex)
Append arguments to this FString. Used to implement Scheme's string-append.- Parameters:
args- an array of FString valuestartIndex- index of first string inargsto use
-
toString
public String toString()
- Specified by:
toStringin interfaceCharSeq- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classAbstractSequence<Char>
-
substring
public String substring(int start, int end)
-
subSequence
public CharSeq subSequence(int start, int end)
- Specified by:
subSequencein interfaceCharSequence
-
setCharacterAt
public void setCharacterAt(int index, int ch)- Specified by:
setCharacterAtin interfaceCharSeq
-
replace
public void replace(CharSequence src, int srcStart, int srcEnd, int dstStart, int dstEnd)
Replace a substring of this string with another. The two strings may have different lengths, so this generalizes insertion and deletion. All indexes are code-unit (16-bit char) offsets.
-
setCharAtBuffer
public void setCharAtBuffer(int index, char ch)
-
insertRepeated
public void insertRepeated(int where, int value, int count)
-
replace
public void replace(int where, char[] chars, int start, int count)
-
replace
public void replace(int where, String string)
-
equals
public boolean equals(Object obj)
Description copied from class:AbstractCharVectorMust override, since we override hashCode.- Specified by:
equalsin interfaceCollection<Char>- Specified by:
equalsin interfaceList<Char>- Specified by:
equalsin classAbstractCharVector<Char>
-
newInstance
protected FString newInstance(int newLength)
- Specified by:
newInstancein classSimpleVector<Char>
-
getElementKind
public int getElementKind()
- Specified by:
getElementKindin interfaceArray<Char>- Overrides:
getElementKindin classAbstractSequence<Char>
-
getTag
public String getTag()
Description copied from class:SimpleVectorThis is convenience hack for printing "uniform vectors" (srfi 4). It may go away without notice!- Overrides:
getTagin classSimpleVector<Char>
-
consumePosRange
public void consumePosRange(int iposStart, int iposEnd, Consumer out)- Overrides:
consumePosRangein classAbstractSequence<Char>
-
append
public FString append(char c)
- Specified by:
appendin interfaceAppendable
-
appendCharacter
public FString appendCharacter(int c)
Append a Unicode code point.
-
append
public FString append(CharSequence csq)
- Specified by:
appendin interfaceAppendable
-
append
public FString append(CharSequence csq, int start, int end)
- Specified by:
appendin interfaceAppendable
-
prependCharacter
public FString prependCharacter(int c)
-
prepend
public FString prepend(CharSequence str, int start, int end)
-
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- Throws:
IOException
-
writeTo
public void writeTo(Appendable dest) throws IOException
- Specified by:
writeToin interfaceCharSeq- Throws:
IOException
-
-