Class AbstractEncodedAppender

    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void append​(Encoder encoder, EncodingState encodingState, char[] b, int off, int len)
      Encodes a portion of a char array and appends it to the buffer.
      void append​(Encoder encoder, EncodingState encodingState, java.lang.CharSequence str, int off, int len)
      Encodes a portion of a string and appends it to the buffer.
      void append​(Encoder encoder, StreamEncodeable streamEncodeable)
      Encodes a StreamEncodeable instance and appends it to the buffer.
      protected abstract void appendCharSequence​(EncodingState encodingState, java.lang.CharSequence str, int start, int end)
      Append a portion of a CharSequence to the buffer and attach the encodingState information to it
      void appendEncoded​(Encoder encoder, EncodingState encodingState, char[] b, int off, int len)
      Appends an encoded portion of a char array to the buffer.
      void appendEncoded​(Encoder encoder, EncodingState encodingState, java.lang.CharSequence str, int off, int len)
      Appends an encoded portion of a string to the buffer
      protected EncodingState createNewEncodingState​(Encoder encoder, EncodingState encodingState)  
      protected void encodeAndWrite​(Encoder encoder, EncodingState newEncodingState, java.lang.CharSequence input)
      Encode and write input to buffer using a non-streaming encoder
      void flush()
      Flush the internal buffer and write the buffered input to a possible destination.
      boolean isIgnoreEncodingState()  
      void setIgnoreEncodingState​(boolean ignoreEncodingState)
      When enabled, will encode all input regardless of it's current state disables double-encoding prevention.
      boolean shouldEncode​(Encoder encoderToApply, EncodingState encodingState)
      Check if the encoder should be used to a input with certain encodingState
      protected boolean shouldEncodeWith​(Encoder encoderToApply, EncodingState encodingState)  
      protected abstract void write​(EncodingState encodingState, char[] b, int off, int len)
      Append a portion of a char array to the buffer and attach the encodingState information to it
      protected abstract void write​(EncodingState encodingState, java.lang.String str, int off, int len)
      Append a portion of a string to the buffer and attach the encodingState information to it
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractEncodedAppender

        public AbstractEncodedAppender()
    • Method Detail

      • write

        protected abstract void write​(EncodingState encodingState,
                                      char[] b,
                                      int off,
                                      int len)
                               throws java.io.IOException
        Append a portion of a char array to the buffer and attach the encodingState information to it
        Parameters:
        encodingState - the new encoding state of the char array
        b - a char array
        off - Offset from which to start encoding characters
        len - Number of characters to encode
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
      • write

        protected abstract void write​(EncodingState encodingState,
                                      java.lang.String str,
                                      int off,
                                      int len)
                               throws java.io.IOException
        Append a portion of a string to the buffer and attach the encodingState information to it
        Parameters:
        encodingState - the new encoding state of the string
        str - A String
        off - Offset from which to start encoding characters
        len - Number of characters to encode
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
      • appendCharSequence

        protected abstract void appendCharSequence​(EncodingState encodingState,
                                                   java.lang.CharSequence str,
                                                   int start,
                                                   int end)
                                            throws java.io.IOException
        Append a portion of a CharSequence to the buffer and attach the encodingState information to it
        Parameters:
        encodingState - the new encoding state of the CharSequence portion
        str - a CharSequence
        start - the start index, inclusive
        end - the end index, exclusive
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
      • append

        public void append​(Encoder encoder,
                           EncodingState encodingState,
                           char[] b,
                           int off,
                           int len)
                    throws java.io.IOException
        Description copied from interface: EncodedAppender
        Encodes a portion of a char array and appends it to the buffer.
        Specified by:
        append in interface EncodedAppender
        Parameters:
        encoder - the encoder to use
        encodingState - the current encoding state of the string
        b - a char array
        off - Offset from which to start encoding characters
        len - Number of characters to encode
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
      • append

        public void append​(Encoder encoder,
                           EncodingState encodingState,
                           java.lang.CharSequence str,
                           int off,
                           int len)
                    throws java.io.IOException
        Description copied from interface: EncodedAppender
        Encodes a portion of a string and appends it to the buffer.
        Specified by:
        append in interface EncodedAppender
        Parameters:
        encoder - the encoder to use
        encodingState - the current encoding state of the string
        str - A String
        off - Offset from which to start encoding characters
        len - Number of characters to encode
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
      • appendEncoded

        public void appendEncoded​(Encoder encoder,
                                  EncodingState encodingState,
                                  char[] b,
                                  int off,
                                  int len)
                           throws java.io.IOException
        Description copied from interface: EncodedAppender
        Appends an encoded portion of a char array to the buffer.
        Specified by:
        appendEncoded in interface EncodedAppender
        Parameters:
        encoder - the encoder that has been applied
        encodingState - the previous encoding state of the char array
        b - a char array
        off - Offset from which to start encoding characters
        len - Number of characters to encode
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
      • appendEncoded

        public void appendEncoded​(Encoder encoder,
                                  EncodingState encodingState,
                                  java.lang.CharSequence str,
                                  int off,
                                  int len)
                           throws java.io.IOException
        Description copied from interface: EncodedAppender
        Appends an encoded portion of a string to the buffer
        Specified by:
        appendEncoded in interface EncodedAppender
        Parameters:
        encoder - the encoder that has been applied
        encodingState - the previous encoding state of the string
        str - A String
        off - Offset from which to start encoding characters
        len - Number of characters to encode
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
      • shouldEncode

        public boolean shouldEncode​(Encoder encoderToApply,
                                    EncodingState encodingState)
        Check if the encoder should be used to a input with certain encodingState
        Specified by:
        shouldEncode in interface EncodedAppender
        Parameters:
        encoderToApply - the encoder to apply
        encodingState - the current encoding state
        Returns:
        true, if should encode
      • shouldEncodeWith

        protected boolean shouldEncodeWith​(Encoder encoderToApply,
                                           EncodingState encodingState)
      • encodeAndWrite

        protected void encodeAndWrite​(Encoder encoder,
                                      EncodingState newEncodingState,
                                      java.lang.CharSequence input)
                               throws java.io.IOException
        Encode and write input to buffer using a non-streaming encoder
        Parameters:
        encoder - the encoder to use
        newEncodingState - the new encoding state after encoder has been applied
        input - the input CharSequence
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
      • append

        public void append​(Encoder encoder,
                           StreamEncodeable streamEncodeable)
                    throws java.io.IOException
        Description copied from interface: EncodedAppender
        Encodes a StreamEncodeable instance and appends it to the buffer.
        Specified by:
        append in interface EncodedAppender
        Parameters:
        encoder - the encoder to use
        streamEncodeable - the instance to encode
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
      • flush

        public void flush()
                   throws java.io.IOException
        Description copied from interface: EncodedAppender
        Flush the internal buffer and write the buffered input to a possible destination.
        Specified by:
        flush in interface EncodedAppender
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
      • isIgnoreEncodingState

        public boolean isIgnoreEncodingState()
        Specified by:
        isIgnoreEncodingState in interface EncodedAppender
        Returns:
        current state of ignoreEncodingState setting
      • setIgnoreEncodingState

        public void setIgnoreEncodingState​(boolean ignoreEncodingState)
        Description copied from interface: EncodedAppender
        When enabled, will encode all input regardless of it's current state disables double-encoding prevention.
        Specified by:
        setIgnoreEncodingState in interface EncodedAppender