Class AbstractEncodedAppender

java.lang.Object
org.grails.encoder.AbstractEncodedAppender
All Implemented Interfaces:
EncodedAppender
Direct Known Subclasses:
StreamingEncoderEncodedAppender, WriterEncodedAppender

public abstract class AbstractEncodedAppender extends Object implements EncodedAppender
Abstract base class for implementations of EncodedAppender interface
Since:
2.3
  • Constructor Details

    • AbstractEncodedAppender

      public AbstractEncodedAppender()
  • Method Details

    • write

      protected abstract void write(EncodingState encodingState, char[] b, int off, int len) throws 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:
      IOException - Signals that an I/O exception has occurred.
    • write

      protected abstract void write(EncodingState encodingState, String str, int off, int len) throws 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:
      IOException - Signals that an I/O exception has occurred.
    • appendCharSequence

      protected abstract void appendCharSequence(EncodingState encodingState, CharSequence str, int start, int end) throws 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:
      IOException - Signals that an I/O exception has occurred.
    • append

      public void append(Encoder encoder, EncodingState encodingState, char[] b, int off, int len) throws 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:
      IOException - Signals that an I/O exception has occurred.
    • createNewEncodingState

      protected EncodingState createNewEncodingState(Encoder encoder, EncodingState encodingState)
    • append

      public void append(Encoder encoder, EncodingState encodingState, CharSequence str, int off, int len) throws 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:
      IOException - Signals that an I/O exception has occurred.
    • appendEncoded

      public void appendEncoded(Encoder encoder, EncodingState encodingState, char[] b, int off, int len) throws 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:
      IOException - Signals that an I/O exception has occurred.
    • appendEncoded

      public void appendEncoded(Encoder encoder, EncodingState encodingState, CharSequence str, int off, int len) throws 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:
      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, CharSequence input) throws 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:
      IOException - Signals that an I/O exception has occurred.
    • append

      public void append(Encoder encoder, StreamEncodeable streamEncodeable) throws 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:
      IOException - Signals that an I/O exception has occurred.
    • flush

      public void flush() throws 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:
      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