public class MFString
extends java.lang.Object
implements java.lang.Comparable, java.lang.CharSequence, java.io.Serializable
| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_SIZE |
| Constructor and Description |
|---|
MFString()
Default constructor.
|
MFString(java.lang.CharSequence str)
Initializes using the characters from a CharSequence.
|
MFString(int maxSize)
Creates an MFString with the specified maximum size.
|
MFString(MFString str)
Copy constructor.
|
| Modifier and Type | Method and Description |
|---|---|
MFString |
append(char c)
Append a char at the end of the string.
|
MFString |
append(char[] c)
Append a char array at the end of the string.
|
MFString |
append(java.lang.CharSequence s)
Append the contents of a CharSequence to this string
|
MFString |
append(java.lang.CharSequence s,
int start,
int end)
Append the CharSequence to this string within the given range.
|
MFString |
append(int i)
Append an int representation of a string at the
end of the string.
|
MFString |
append(long l)
Append an int representation of a string at the
end of the string.
|
MFString |
append(MFString s)
Append the contents of a MFString to this string
|
char |
charAt(int index)
Get the length of the string.
|
int |
compareTo(java.lang.Object o)
Implements Comparable method compareTo.
|
void |
deepCopy(MFString src)
Copies the state of the source MFString to this string.
|
boolean |
equals(java.lang.Object o) |
void |
freeze()
Freeze the state.
|
int |
hashCode()
This is for the use case where the object needs to be
in a pool (in order to avoid creating garbage) but also
in a java collection, such as HashMap, which needs to
have this in order to operate properly.
|
boolean |
isEmpty()
Convenience method which exists in String.
|
int |
length()
Get the length of the string.
|
void |
reset()
Resets the string so a new string can be
created.
|
void |
setCharAt(int index,
char ch)
Change the char at a specific index.
|
java.lang.CharSequence |
subSequence(int start,
int end)
Returns a new CharSequence that is a subsequence of this sequence.
|
java.lang.String |
toString()
WARNING: Creates garbage.
|
void |
unfreeze() |
public static final int MAX_SIZE
public MFString()
public MFString(int maxSize)
MAX_SIZE.maxSize - max size of this MFStringpublic MFString(MFString str)
str - - the intial value of this string object.public MFString(java.lang.CharSequence str)
str - - the intial value of this string object.java.lang.IllegalArgumentException - - if any character is not printable ASCII.java.lang.IndexOutOfBoundsException - - The length of str is greater than 1024.public void deepCopy(MFString src)
src - -- the rhs stringjava.lang.IllegalStateException - - If called when the string has been frozen.public MFString append(char c)
c - the character to be appendedjava.lang.IllegalArgumentException - - if any character is not printable ASCII.java.lang.IndexOutOfBoundsException - - The length of str is greater than 1024.java.lang.IllegalStateException - - If called when the string has been frozen.public MFString append(char[] c)
c - the string to be appendedjava.lang.IllegalArgumentException - - if any character is not printable ASCII.java.lang.IndexOutOfBoundsException - - The length of str is greater than 1024.java.lang.IllegalStateException - - If called when the string has been frozen.public MFString append(MFString s)
s - the string to be appendedjava.lang.IllegalArgumentException - - if any character is not printable ASCII.java.lang.IndexOutOfBoundsException - - The length of sr is greater than 1024.java.lang.IllegalStateException - - If called when the string has been frozen.public MFString append(java.lang.CharSequence s)
s - the string to be appendedjava.lang.IllegalArgumentException - - if any character is not printable ASCII.java.lang.IndexOutOfBoundsException - - The length of str is greater than 1024.java.lang.IllegalStateException - - If called when the string has been frozen.public MFString append(java.lang.CharSequence s, int start, int end)
s - the string to be appendedstart - the start indexend - the end indexjava.lang.IllegalArgumentException - - if any character is not printable ASCII.java.lang.IndexOutOfBoundsException - - if either index is not greater than zero and less than 1024
or start is greater than end or if end is greater than s.length();java.lang.IllegalStateException - - If called when the string has been frozen.public MFString append(int i)
i - the integerjava.lang.IndexOutOfBoundsException - - The length of str is greater than 1024.java.lang.IllegalStateException - - If called when the string has been frozen.public MFString append(long l)
l - the long integerjava.lang.IndexOutOfBoundsException - - The length of str is greater than 1024.java.lang.IllegalStateException - - If called when the string has been frozen.public char charAt(int index)
charAt in interface java.lang.CharSequencejava.lang.IndexOutOfBoundsException - - The length of str is greater than 1024.public void setCharAt(int index,
char ch)
index - the idxch - the characterjava.lang.IllegalArgumentException - - if any character is not printable ASCII.java.lang.IndexOutOfBoundsException - - The length of str is greater than 1024.java.lang.IllegalStateException - - If called when the string has been frozen.public int length()
length in interface java.lang.CharSequencepublic boolean isEmpty()
public java.lang.CharSequence subSequence(int start,
int end)
subSequence in interface java.lang.CharSequencejava.lang.IndexOutOfBoundsException - - if start or end are negative, if end is greater than length(), or if start is greater than endpublic void reset()
java.lang.IllegalStateException - - If called when the string has been frozen.public void freeze()
public void unfreeze()
public java.lang.String toString()
toString in interface java.lang.CharSequencetoString in class java.lang.Objectpublic int compareTo(java.lang.Object o)
throws java.lang.ClassCastException
compareTo in interface java.lang.Comparablejava.lang.ClassCastExceptionpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object