Class AggregateCharSequence
- All Implemented Interfaces:
Serializable
,CharSequence
,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
- Since:
- 3.0.0
- Author:
- Daniel Fernández
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAggregateCharSequence
(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) -
Method Summary
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.CharSequence
chars, codePoints
-
Field Details
-
serialVersionUID
protected static final long serialVersionUID- See Also:
-
-
Constructor Details
-
AggregateCharSequence
-
AggregateCharSequence
-
AggregateCharSequence
public AggregateCharSequence(CharSequence component0, CharSequence component1, CharSequence component2) -
AggregateCharSequence
public AggregateCharSequence(CharSequence component0, CharSequence component1, CharSequence component2, CharSequence component3) -
AggregateCharSequence
public AggregateCharSequence(CharSequence component0, CharSequence component1, CharSequence component2, CharSequence component3, CharSequence component4) -
AggregateCharSequence
-
AggregateCharSequence
-
-
Method Details
-
length
public int length()- Specified by:
length
in interfaceCharSequence
-
charAt
public char charAt(int index) - Specified by:
charAt
in interfaceCharSequence
-
subSequence
- Specified by:
subSequence
in interfaceCharSequence
-
write
Description copied from interface: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 aWriter
.- Specified by:
write
in interfaceIWritableCharSequence
- Parameters:
writer
- the writer to write the character sequence to.- Throws:
IOException
- if an input/output exception happens during writing
-
equals
-
hashCode
public int hashCode() -
contentEquals
-
contentEquals
-
toString
- Specified by:
toString
in interfaceCharSequence
- Overrides:
toString
in classObject
-