Package org.mozilla.javascript
Class ConsString
java.lang.Object
org.mozilla.javascript.ConsString
- All Implemented Interfaces:
Serializable,CharSequence
This class represents a string composed of two components, each of which may be a
java.lang.String or 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:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncharcharAt(int index) intlength()subSequence(int start, int end) toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
-
Constructor Details
-
ConsString
-
-
Method Details
-
toString
- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classObject
-
length
public int length()- Specified by:
lengthin interfaceCharSequence
-
charAt
public char charAt(int index) - Specified by:
charAtin interfaceCharSequence
-
subSequence
- Specified by:
subSequencein interfaceCharSequence
-