gnu.lists

Class FString

Implemented Interfaces:
CharSequence, Comparable, CharSeq, Externalizable, java.util.List, Array, Consumable, Sequence

public class FString
extends SimpleVector
implements Comparable, CharSeq, Externalizable, Consumable

Simple adjustable-length vector whose elements are 32-bit floats. Used for the Scheme string type.

Field Summary

char[]
data
protected static char[]
empty

Fields inherited from class gnu.lists.SimpleVector

size

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, 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, eofValue

Constructor Summary

FString()
FString(String str)
FString(StringBuffer buffer)
FString(StringBuffer buffer, int offset, int length)
FString(char[] values)
Create an FString from a char[].
FString(char[] buffer, int offset, int length)
FString(CharSeq seq)
FString(CharSeq seq, int offset, int length)
FString(Sequence seq)
FString(int num)
FString(int num, char value)

Method Summary

boolean
addAll(FString s)
Append all the characters of another FString.
void
addAllStrings(Object[] args, int startIndex)
Append arguments to this FString.
FString
append(CharSequence csq)
FString
append(CharSequence csq, int start, int end)
FString
append(char c)
char
charAt(int index)
char
charAtBuffer(int index)
protected void
clearBuffer(int start, int count)
int
compareTo(Object obj)
void
consume(Consumer out)
boolean
consumeNext(int ipos, Consumer out)
Copy an element specified by a position pair to a Consumer.
void
consumePosRange(int iposStart, int iposEnd, Consumer out)
FString
copy(int start, int end)
void
ensureBufferLength(int sz)
boolean
equals(Object obj)
void
fill(char ch)
Set all the elements to a given character.
void
fill(int fromIndex, int toIndex, char value)
Object
get(int index)
See java.util.List.
protected Object
getBuffer()
Object
getBuffer(int index)
int
getBufferLength()
Get the allocated length of the data buffer.
void
getChars(StringBuffer dst)
void
getChars(int srcBegin, int srcEnd, StringBuffer dst)
void
getChars(int srcBegin, int srcEnd, dst[] , int dstBegin)
int
getElementKind()
int
hashCode()
int
length()
Get length of string, in characters.
void
readExternal(ObjectInput in)
void
replace(int where, String string)
void
replace(int where, char[] chars, int start, int count)
Object
setBuffer(int index, Object value)
void
setBufferLength(int length)
void
setCharAt(int index, char ch)
void
setCharAtBuffer(int index, char ch)
void
shift(int srcStart, int dstStart, int count)
CharSequence
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
writeExternal(ObjectOutput out)
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.SimpleVector

add, add, addAll, addPos, clear, clearBuffer, compareToInt, compareToLong, consume, consumeNext, consumePosRange, createPos, fill, fill, fillPosRange, get, getBuffer, getBuffer, getBufferLength, getElementKind, getNextKind, getPosNext, getRowMajor, getTag, intAt, intAtBuffer, isAfterPos, longAt, longAtBuffer, nextIndex, nextPos, remove, remove, removeAll, removePos, removePosRange, retainAll, set, setBuffer, setBufferLength, setSize, shift, size, transpose

Methods inherited from class gnu.lists.AbstractSequence

add, add, addAll, addAll, addPos, clear, compare, compare, compare, consume, consumeNext, consumePosRange, contains, containsAll, copyPos, createPos, createRelativePos, elements, endPos, equals, equals, fill, fill, fillPosRange, firstAttributePos, firstChildPos, firstChildPos, fromEndIndex, get, get, getAttribute, getAttributeLength, getContainingSequenceSize, getEffectiveIndex, getIndexDifference, getIterator, getIterator, getIteratorAtPos, getLowBound, getNextKind, getNextTypeName, getNextTypeObject, getPosNext, getPosPrevious, getSize, gotoAttributesStart, gotoChildrenStart, gotoParent, hasNext, hasPrevious, hashCode, indexOf, isAfterPos, isEmpty, iterator, lastIndexOf, listIterator, listIterator, nextIndex, nextIndex, nextMatching, nextPos, parentPos, previousPos, rank, releasePos, remove, remove, removeAll, removePos, removePosRange, retainAll, set, set, setPosNext, setPosPrevious, size, stableCompare, startPos, subList, subSequence, subSequencePos, toArray, toArray, toString, toString, unsupported, unsupportedException

Field Details

data

public char[] data

empty

protected static char[] empty

Constructor Details

FString

public FString()

FString

public FString(String str)

FString

public FString(StringBuffer buffer)

FString

public FString(StringBuffer buffer,
               int offset,
               int length)

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)

FString

public FString(CharSeq seq)

FString

public FString(CharSeq seq,
               int offset,
               int length)

FString

public FString(Sequence seq)

FString

public FString(int num)

FString

public FString(int num,
               char value)

Method Details

addAll

public boolean addAll(FString s)
Append all the characters of another FString.

addAllStrings

public void addAllStrings(Object[] args,
                          int startIndex)
Append arguments to this FString. Used to implement Scheme's string-append and string-append/shared.
Parameters:
args - an array of FString value
startIndex - index of first string in args to use

append

public FString append(CharSequence csq)

append

public FString append(CharSequence csq,
                      int start,
                      int end)

append

public FString append(char c)

charAt

public final char charAt(int index)
Specified by:
charAt in interface CharSeq

charAtBuffer

public final char charAtBuffer(int index)

clearBuffer

protected void clearBuffer(int start,
                           int count)
Overrides:
clearBuffer in interface SimpleVector

compareTo

public int compareTo(Object obj)

consume

public void consume(Consumer out)
Specified by:
consume in interface Consumable
Overrides:
consume in interface AbstractSequence

consumeNext

public boolean consumeNext(int ipos,
                           Consumer out)
Copy an element specified by a position pair to a Consumer.
Overrides:
consumeNext in interface SimpleVector
Returns:
if hasNext(ipos).

consumePosRange

public void consumePosRange(int iposStart,
                            int iposEnd,
                            Consumer out)
Overrides:
consumePosRange in interface SimpleVector

copy

public FString copy(int start,
                    int end)

ensureBufferLength

public void ensureBufferLength(int sz)

equals

public boolean equals(Object obj)
Overrides:
equals in interface AbstractSequence

fill

public final void fill(char ch)
Set all the elements to a given character.
Specified by:
fill in interface CharSeq

fill

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

get

public final Object get(int index)
See java.util.List.
Specified by:
get in interface Sequence
Overrides:
get in interface SimpleVector

getBuffer

protected Object getBuffer()
Overrides:
getBuffer in interface SimpleVector

getBuffer

public final Object getBuffer(int index)
Overrides:
getBuffer in interface SimpleVector

getBufferLength

public int getBufferLength()
Get the allocated length of the data buffer.
Overrides:
getBufferLength in interface SimpleVector

getChars

public void getChars(StringBuffer dst)

getChars

public void getChars(int srcBegin,
                     int srcEnd,
                     StringBuffer dst)

getChars

public void getChars(int srcBegin,
                     int srcEnd,
                     dst[] ,
                     int dstBegin)

getElementKind

public int getElementKind()
Overrides:
getElementKind in interface SimpleVector

hashCode

public int hashCode()
Overrides:
hashCode in interface AbstractSequence

length

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

readExternal

public void readExternal(ObjectInput in)
            throws IOException,
                   ClassNotFoundException

replace

public void replace(int where,
                    String string)

replace

public void replace(int where,
                    char[] chars,
                    int start,
                    int count)

setBuffer

public final Object setBuffer(int index,
                              Object value)
Overrides:
setBuffer in interface SimpleVector

setBufferLength

public void setBufferLength(int length)
Overrides:
setBufferLength in interface SimpleVector

setCharAt

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

setCharAtBuffer

public void setCharAtBuffer(int index,
                            char ch)

shift

public void shift(int srcStart,
                  int dstStart,
                  int count)
Overrides:
shift in interface SimpleVector

subSequence

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

substring

public String substring(int start,
                        int end)

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.

toString

public String toString()
Specified by:
toString in interface CharSeq
Overrides:
toString in interface AbstractSequence

writeExternal

public void writeExternal(ObjectOutput out)
            throws IOException

writeTo

public void writeTo(int start,
                    int count,
                    java.io.Writer dest)
            throws java.io.IOException
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

writeTo

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