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 boolean
addAll(CharSequence s)
void
addAllStrings(Object[] args, int startIndex)
Append arguments to this FString.static FString
alloc(int sz)
Create a empty string, but with a given initial buffer size.FString
append(char c)
FString
append(CharSequence csq)
FString
append(CharSequence csq, int start, int end)
FString
append(Object obj)
FString
appendCharacter(int c)
Append a Unicode code point.int
characterAt(int index)
void
consumePosRange(int iposStart, int iposEnd, Consumer out)
FString
copy(int start, int end)
int
createPos(int index, boolean isAfter)
Generate a position at a given index.int
createRelativePos(int pos, int delta, boolean isAfter)
int
effectiveIndex(int index)
boolean
equals(Object obj)
Must override, since we override hashCode.Char
get(int index)
See java.util.List.int
getElementKind()
Char
getRaw(int index)
Given an "effective index", return element as object.String
getTag()
This is convenience hack for printing "uniform vectors" (srfi 4).int
indexOf(int ch, int fromChar)
void
insert(int where, int ch, boolean beforeMarkers)
void
insert(int where, String str, boolean beforeMarkers)
void
insertRepeated(int where, int value, int count)
int
lastIndexOf(int ch, int fromChar)
protected FString
newInstance(int newLength)
protected int
nextIndex(int ipos)
Get the offset from the beginning corresponding to a position cookie.FString
prepend(CharSequence str, int start, int end)
FString
prepend(Object obj)
FString
prependCharacter(int c)
void
replace(int where, char[] chars, int start, int count)
void
replace(int where, String string)
void
replace(CharSequence src, int srcStart, int srcEnd, int dstStart, int dstEnd)
Replace a substring of this string with another.Char
set(int index, Char value)
See java.util.List.void
setCharacterAt(int index, int ch)
void
setCharAt(int index, char ch)
void
setCharAtBuffer(int index, char ch)
void
setRaw(int index, Char value)
Given an "effective index", set selected element.void
shift(int srcStart, int dstStart, int count)
int
size()
See java.util.List.CharSeq
subSequence(int start, int end)
String
substring(int start, int end)
char[]
toCharArray()
Return a char[] contain the characters of this string.String
toString()
void
writeTo(int start, int count, Appendable dest)
Append a specified subsequence to anAppendable
.void
writeTo(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:Sequence
See java.util.List.
-
effectiveIndex
public int effectiveIndex(int index)
- Specified by:
effectiveIndex
in interfaceArray<Char>
- Overrides:
effectiveIndex
in classSimpleVector<Char>
- Parameters:
index
- measured in Unicode code points (characters)
-
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 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:AbstractSequence
Get the offset from the beginning corresponding to a position cookie.- Overrides:
nextIndex
in classAbstractSequence<Char>
-
createRelativePos
public int createRelativePos(int pos, int delta, boolean isAfter)
- Overrides:
createRelativePos
in 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:Array
Given an "effective index", return element as object.
-
get
public final Char get(int index)
Description copied from interface:Sequence
See 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:Sequence
See java.util.List.
-
setRaw
public final void setRaw(int index, Char value)
Description copied from class:AbstractSequence
Given 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:
shift
in 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 inargs
to use
-
toString
public String toString()
- Specified by:
toString
in interfaceCharSeq
- Specified by:
toString
in interfaceCharSequence
- Overrides:
toString
in classAbstractSequence<Char>
-
substring
public String substring(int start, int end)
-
subSequence
public CharSeq subSequence(int start, int end)
- Specified by:
subSequence
in interfaceCharSequence
-
setCharacterAt
public void setCharacterAt(int index, int ch)
- Specified by:
setCharacterAt
in 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:AbstractCharVector
Must override, since we override hashCode.- Specified by:
equals
in interfaceCollection<Char>
- Specified by:
equals
in interfaceList<Char>
- Specified by:
equals
in classAbstractCharVector<Char>
-
newInstance
protected FString newInstance(int newLength)
- Specified by:
newInstance
in classSimpleVector<Char>
-
getElementKind
public int getElementKind()
- Specified by:
getElementKind
in interfaceArray<Char>
- Overrides:
getElementKind
in classAbstractSequence<Char>
-
getTag
public String getTag()
Description copied from class:SimpleVector
This is convenience hack for printing "uniform vectors" (srfi 4). It may go away without notice!- Overrides:
getTag
in classSimpleVector<Char>
-
consumePosRange
public void consumePosRange(int iposStart, int iposEnd, Consumer out)
- Overrides:
consumePosRange
in classAbstractSequence<Char>
-
append
public FString append(char c)
- Specified by:
append
in interfaceAppendable
-
appendCharacter
public FString appendCharacter(int c)
Append a Unicode code point.
-
append
public FString append(CharSequence csq)
- Specified by:
append
in interfaceAppendable
-
append
public FString append(CharSequence csq, int start, int end)
- Specified by:
append
in 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 IOException
Description copied from interface:CharSeq
Append a specified subsequence to anAppendable
. An allowable implementation is:dest.append(this, start, start+count)
. Hence implementors ofAppendable
should avoid callingwriteTo
- though they can callgetChars
.- Specified by:
writeTo
in interfaceCharSeq
- Throws:
IOException
-
writeTo
public void writeTo(Appendable dest) throws IOException
- Specified by:
writeTo
in interfaceCharSeq
- Throws:
IOException
-
-