Class AggregateCharSequence

  • All Implemented Interfaces:
    , , IWritableCharSequence

    public final class AggregateCharSequence
    extends 
    implements , IWritableCharSequence

    Character sequence that aggregates one or several objects, without the need to clone them or convert them to String.

    Special implementation of the interface that can replace objects wherever a specific text literal is composed of several parts and we want to avoid creating new objects for them, using instead objects of this class that simply keep an array of references to the original CharSequences.

    Note that any mutable 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:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static long serialVersionUID  
    • Constructor Summary

      Constructors 
      Constructor Description
       component)  
      [] components)  
       component0,  component1)  
       component0,  component1,  component2)  
       component0,  component1,  component2,  component3)  
       component0,  component1,  component2,  component3,  component4)  
      <? extends > components)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      char charAt​(int index)  
      boolean  cs)  
      boolean  sb)  
      boolean  o)  
      int hashCode()  
      int length()  
      subSequence​(int beginIndex, int endIndex)  
      toString()  
      void  writer)
      Write the contents of this char sequence directly to an output .
      • Methods inherited from class java.lang.

        , , , , , , ,
    • Constructor Detail

      • AggregateCharSequence

        public AggregateCharSequence​( component)
      • AggregateCharSequence

        public AggregateCharSequence​( component0,
                                      component1)
      • AggregateCharSequence

        public AggregateCharSequence​( component0,
                                      component1,
                                      component2)
      • AggregateCharSequence

        public AggregateCharSequence​( component0,
                                      component1,
                                      component2,
                                      component3)
      • AggregateCharSequence

        public AggregateCharSequence​( component0,
                                      component1,
                                      component2,
                                      component3,
                                      component4)
      • AggregateCharSequence

        public AggregateCharSequence​([] components)
      • AggregateCharSequence

        public AggregateCharSequence​(<? extends > components)
    • Method Detail

      • length

        public int length()
        Specified by:
         in interface 
      • charAt

        public char charAt​(int index)
        Specified by:
         in interface 
      • subSequence

        public  subSequence​(int beginIndex,
                                        int endIndex)
        Specified by:
         in interface 
      • write

        public void write​( writer)
                   throws 
        Description copied from interface: IWritableCharSequence

        Write the contents of this char sequence directly to an output .

        This method can avoid the need to create a object containing all the contents in this character sequence just when we want to write it to a .

        Specified by:
        write in interface IWritableCharSequence
        Parameters:
        writer - the writer to write the character sequence to.
        Throws:
        - if an input/output exception happens during writing
      • equals

        public boolean equals​( o)
        Overrides:
         in class 
      • hashCode

        public int hashCode()
        Overrides:
         in class 
      • contentEquals

        public boolean contentEquals​( sb)
      • contentEquals

        public boolean contentEquals​( cs)
      • toString

        public  toString()
        Specified by:
         in interface 
        Overrides:
         in class