Class AbstractLazyCharSequence

  • All Implemented Interfaces:
    java.lang.CharSequence, IWritableCharSequence
    Direct Known Subclasses:
    LazyEscapingCharSequence, LazyProcessingCharSequence

    public abstract class AbstractLazyCharSequence
    extends java.lang.Object
    implements IWritableCharSequence

    Abstract class for character sequences that perform lazy evaluation of their textual contents.

    Implementations of this class allow the possibility that their textual contents are actually computed during output writing (if possible), and therefore directly written to output buffers and never requiring being completely resolved in memory.

    This is mostly an internal class, and its use is not recommended from user's code.

    Children of this class are not thread-safe.

    Since:
    3.0.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String resolvedText  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      char charAt​(int index)  
      boolean equals​(java.lang.Object o)  
      private java.lang.String getText()  
      int hashCode()  
      int length()  
      protected abstract java.lang.String resolveText()  
      java.lang.CharSequence subSequence​(int beginIndex, int endIndex)  
      java.lang.String toString()  
      void write​(java.io.Writer writer)
      Write the contents of this char sequence directly to an output Writer.
      protected abstract void writeUnresolved​(java.io.Writer writer)  
      • 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 Detail

      • resolvedText

        private java.lang.String resolvedText
    • Constructor Detail

      • AbstractLazyCharSequence

        protected AbstractLazyCharSequence()
    • Method Detail

      • resolveText

        protected abstract java.lang.String resolveText()
      • getText

        private java.lang.String getText()
      • length

        public final int length()
        Specified by:
        length in interface java.lang.CharSequence
      • charAt

        public final char charAt​(int index)
        Specified by:
        charAt in interface java.lang.CharSequence
      • subSequence

        public final java.lang.CharSequence subSequence​(int beginIndex,
                                                        int endIndex)
        Specified by:
        subSequence in interface java.lang.CharSequence
      • write

        public final void write​(java.io.Writer writer)
                         throws java.io.IOException
        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 a Writer.

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

        protected abstract void writeUnresolved​(java.io.Writer writer)
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • equals

        public final boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public final int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public final java.lang.String toString()
        Specified by:
        toString in interface java.lang.CharSequence
        Overrides:
        toString in class java.lang.Object