public final class AggregateCharSequence extends Object implements Serializable, IWritableCharSequence
Character sequence that aggregates one or several CharSequence
objects, without the need to clone them
or convert them to String.
Special implementation of the CharSequence
interface that can replace String
objects
wherever a specific text literal is composed of several parts and we want to avoid creating new
String
objects for them, using instead objects of this class that simply keep an array
of references to the original CharSequences.
Note that any mutable CharSequence
implementations used to build objects of this class should
never be modified after the creation of the aggregated object.
This class is thread-safe
Modifier and Type | Field and Description |
---|---|
protected static long |
serialVersionUID |
Constructor and Description |
---|
AggregateCharSequence(CharSequence component) |
AggregateCharSequence(CharSequence[] components) |
AggregateCharSequence(CharSequence component0,
CharSequence component1) |
AggregateCharSequence(CharSequence component0,
CharSequence component1,
CharSequence component2) |
AggregateCharSequence(CharSequence component0,
CharSequence component1,
CharSequence component2,
CharSequence component3) |
AggregateCharSequence(CharSequence component0,
CharSequence component1,
CharSequence component2,
CharSequence component3,
CharSequence component4) |
AggregateCharSequence(List<? extends CharSequence> components) |
Modifier and Type | Method and Description |
---|---|
char |
charAt(int index) |
boolean |
contentEquals(CharSequence cs) |
boolean |
contentEquals(StringBuffer sb) |
boolean |
equals(Object o) |
int |
hashCode() |
int |
length() |
CharSequence |
subSequence(int beginIndex,
int endIndex) |
String |
toString() |
void |
write(Writer writer)
Write the contents of this char sequence directly to an output
Writer . |
chars, codePoints
protected static final long serialVersionUID
public AggregateCharSequence(CharSequence component)
public AggregateCharSequence(CharSequence component0, CharSequence component1)
public AggregateCharSequence(CharSequence component0, CharSequence component1, CharSequence component2)
public AggregateCharSequence(CharSequence component0, CharSequence component1, CharSequence component2, CharSequence component3)
public AggregateCharSequence(CharSequence component0, CharSequence component1, CharSequence component2, CharSequence component3, CharSequence component4)
public AggregateCharSequence(CharSequence[] components)
public AggregateCharSequence(List<? extends CharSequence> components)
public int length()
length
in interface CharSequence
public char charAt(int index)
charAt
in interface CharSequence
public CharSequence subSequence(int beginIndex, int endIndex)
subSequence
in interface CharSequence
public void write(Writer writer) throws IOException
IWritableCharSequence
Write the contents of this char sequence directly to an output Writer
.
This method can avoid the need to create a String
object containing all the contents in
this character sequence just when we want to write it to a Writer
.
write
in interface IWritableCharSequence
writer
- the writer to write the character sequence to.IOException
- if an input/output exception happens during writingpublic boolean contentEquals(StringBuffer sb)
public boolean contentEquals(CharSequence cs)
public String toString()
toString
in interface CharSequence
toString
in class Object
Copyright © 2017 The THYMELEAF team. All rights reserved.