Package org.grails.encoder
Class AbstractEncodedAppender
java.lang.Object
org.grails.encoder.AbstractEncodedAppender
- All Implemented Interfaces:
EncodedAppender
- Direct Known Subclasses:
StreamingEncoderEncodedAppender,WriterEncodedAppender
Abstract base class for implementations of
EncodedAppender interface- Since:
- 2.3
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappend(Encoder encoder, EncodingState encodingState, char[] b, int off, int len) Encodes a portion of a char array and appends it to the buffer.voidappend(Encoder encoder, EncodingState encodingState, CharSequence str, int off, int len) Encodes a portion of a string and appends it to the buffer.voidappend(Encoder encoder, StreamEncodeable streamEncodeable) Encodes aStreamEncodeableinstance and appends it to the buffer.protected abstract voidappendCharSequence(EncodingState encodingState, CharSequence str, int start, int end) Append a portion of a CharSequence to the buffer and attach the encodingState information to itvoidappendEncoded(Encoder encoder, EncodingState encodingState, char[] b, int off, int len) Appends an encoded portion of a char array to the buffer.voidappendEncoded(Encoder encoder, EncodingState encodingState, CharSequence str, int off, int len) Appends an encoded portion of a string to the bufferprotected EncodingStatecreateNewEncodingState(Encoder encoder, EncodingState encodingState) protected voidencodeAndWrite(Encoder encoder, EncodingState newEncodingState, CharSequence input) Encode and write input to buffer using a non-streaming encodervoidflush()Flush the internal buffer and write the buffered input to a possible destination.booleanvoidsetIgnoreEncodingState(boolean ignoreEncodingState) When enabled, will encode all input regardless of it's current state disables double-encoding prevention.booleanshouldEncode(Encoder encoderToApply, EncodingState encodingState) Check if the encoder should be used to a input with certain encodingStateprotected booleanshouldEncodeWith(Encoder encoderToApply, EncodingState encodingState) protected abstract voidwrite(EncodingState encodingState, char[] b, int off, int len) Append a portion of a char array to the buffer and attach the encodingState information to itprotected abstract voidwrite(EncodingState encodingState, String str, int off, int len) Append a portion of a string to the buffer and attach the encodingState information to itMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.grails.encoder.EncodedAppender
close
-
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 arrayb- a char arrayoff- Offset from which to start encoding characterslen- 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 stringstr- A Stringoff- Offset from which to start encoding characterslen- 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 portionstr- a CharSequencestart- the start index, inclusiveend- 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:EncodedAppenderEncodes a portion of a char array and appends it to the buffer.- Specified by:
appendin interfaceEncodedAppender- Parameters:
encoder- the encoder to useencodingState- the current encoding state of the stringb- a char arrayoff- Offset from which to start encoding characterslen- Number of characters to encode- Throws:
IOException- Signals that an I/O exception has occurred.
-
createNewEncodingState
-
append
public void append(Encoder encoder, EncodingState encodingState, CharSequence str, int off, int len) throws IOException Description copied from interface:EncodedAppenderEncodes a portion of a string and appends it to the buffer.- Specified by:
appendin interfaceEncodedAppender- Parameters:
encoder- the encoder to useencodingState- the current encoding state of the stringstr- A Stringoff- Offset from which to start encoding characterslen- 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:EncodedAppenderAppends an encoded portion of a char array to the buffer.- Specified by:
appendEncodedin interfaceEncodedAppender- Parameters:
encoder- the encoder that has been appliedencodingState- the previous encoding state of the char arrayb- a char arrayoff- Offset from which to start encoding characterslen- 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:EncodedAppenderAppends an encoded portion of a string to the buffer- Specified by:
appendEncodedin interfaceEncodedAppender- Parameters:
encoder- the encoder that has been appliedencodingState- the previous encoding state of the stringstr- A Stringoff- Offset from which to start encoding characterslen- Number of characters to encode- Throws:
IOException- Signals that an I/O exception has occurred.
-
shouldEncode
Check if the encoder should be used to a input with certain encodingState- Specified by:
shouldEncodein interfaceEncodedAppender- Parameters:
encoderToApply- the encoder to applyencodingState- the current encoding state- Returns:
- true, if should encode
-
shouldEncodeWith
-
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 usenewEncodingState- the new encoding state after encoder has been appliedinput- the input CharSequence- Throws:
IOException- Signals that an I/O exception has occurred.
-
append
Description copied from interface:EncodedAppenderEncodes aStreamEncodeableinstance and appends it to the buffer.- Specified by:
appendin interfaceEncodedAppender- Parameters:
encoder- the encoder to usestreamEncodeable- the instance to encode- Throws:
IOException- Signals that an I/O exception has occurred.
-
flush
Description copied from interface:EncodedAppenderFlush the internal buffer and write the buffered input to a possible destination.- Specified by:
flushin interfaceEncodedAppender- Throws:
IOException- Signals that an I/O exception has occurred.
-
isIgnoreEncodingState
public boolean isIgnoreEncodingState()- Specified by:
isIgnoreEncodingStatein interfaceEncodedAppender- Returns:
- current state of ignoreEncodingState setting
-
setIgnoreEncodingState
public void setIgnoreEncodingState(boolean ignoreEncodingState) Description copied from interface:EncodedAppenderWhen enabled, will encode all input regardless of it's current state disables double-encoding prevention.- Specified by:
setIgnoreEncodingStatein interfaceEncodedAppender
-