public class ConsString
extends java.lang.Object
implements java.lang.CharSequence, java.io.Serializable
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.
Constructor and Description |
---|
ConsString(java.lang.CharSequence str1,
java.lang.CharSequence str2) |
Modifier and Type | Method and Description |
---|---|
char |
charAt(int index) |
int |
length() |
java.lang.CharSequence |
subSequence(int start,
int end) |
java.lang.String |
toString() |
public ConsString(java.lang.CharSequence str1, java.lang.CharSequence str2)
public java.lang.String toString()
toString
in interface java.lang.CharSequence
toString
in class java.lang.Object
public int length()
length
in interface java.lang.CharSequence
public char charAt(int index)
charAt
in interface java.lang.CharSequence
public java.lang.CharSequence subSequence(int start, int end)
subSequence
in interface java.lang.CharSequence
Copyright © 2010 - 2020 Adobe. All Rights Reserved