Package org.mozilla.javascript
Class ConsString
- java.lang.Object
-
- org.mozilla.javascript.ConsString
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.CharSequence
public class ConsString extends java.lang.Object implements java.lang.CharSequence, java.io.SerializableThis class represents a string composed of two components, each of which may be ajava.lang.Stringor another ConsString.This string representation is optimized for concatenation using the "+" operator. Instead of immediately copying both components to a new character array, ConsString keeps references to the original components and only converts them to a String if either toString() is called or a certain depth level is reached.
Note that instances of this class are only immutable if both parts are immutable, i.e. either Strings or ConsStrings that are ultimately composed of Strings.
Both the name and the concept are borrowed from V8.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ConsString(java.lang.CharSequence str1, java.lang.CharSequence str2)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description charcharAt(int index)intlength()java.lang.CharSequencesubSequence(int start, int end)java.lang.StringtoString()
-
-
-
Method Detail
-
toString
public java.lang.String toString()
- Specified by:
toStringin interfacejava.lang.CharSequence- Overrides:
toStringin classjava.lang.Object
-
length
public int length()
- Specified by:
lengthin interfacejava.lang.CharSequence
-
charAt
public char charAt(int index)
- Specified by:
charAtin interfacejava.lang.CharSequence
-
subSequence
public java.lang.CharSequence subSequence(int start, int end)- Specified by:
subSequencein interfacejava.lang.CharSequence
-
-