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, waitMethods 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:
lengthin interfaceCharSequence
-
charAt
public char charAt(int index) - Specified by:
charAtin interfaceCharSequence
-
subSequence
- Specified by:
subSequencein interfaceCharSequence
-
write
Description copied from interface:IWritableCharSequenceWrite the contents of this char sequence directly to an output
Writer.This method can avoid the need to create a
Stringobject containing all the contents in this character sequence just when we want to write it to aWriter.- Specified by:
writein 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:
toStringin interfaceCharSequence- Overrides:
toStringin classObject
-