Package org.grails.encoder
Class AbstractEncodedAppender
- java.lang.Object
-
- org.grails.encoder.AbstractEncodedAppender
-
- All Implemented Interfaces:
EncodedAppender
- Direct Known Subclasses:
StreamingEncoderEncodedAppender,WriterEncodedAppender
public abstract class AbstractEncodedAppender extends java.lang.Object implements EncodedAppender
Abstract base class for implementations ofEncodedAppenderinterface- Since:
- 2.3
-
-
Constructor Summary
Constructors Constructor Description AbstractEncodedAppender()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidappend(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, java.lang.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, java.lang.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, java.lang.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, java.lang.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.booleanisIgnoreEncodingState()voidsetIgnoreEncodingState(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, 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
-
Methods inherited from interface org.grails.encoder.EncodedAppender
close
-
-
-
-
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 arrayb- a char arrayoff- Offset from which to start encoding characterslen- 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 stringstr- A Stringoff- Offset from which to start encoding characterslen- 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 portionstr- a CharSequencestart- the start index, inclusiveend- 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: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:
java.io.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, java.lang.CharSequence str, int off, int len) throws java.io.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:
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: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:
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: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:
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:
shouldEncodein interfaceEncodedAppender- Parameters:
encoderToApply- the encoder to applyencodingState- 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 usenewEncodingState- the new encoding state after encoder has been appliedinput- 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:EncodedAppenderEncodes aStreamEncodeableinstance and appends it to the buffer.- Specified by:
appendin interfaceEncodedAppender- Parameters:
encoder- the encoder to usestreamEncodeable- the instance to encode- Throws:
java.io.IOException- Signals that an I/O exception has occurred.
-
flush
public void flush() throws java.io.IOExceptionDescription copied from interface:EncodedAppenderFlush the internal buffer and write the buffered input to a possible destination.- Specified by:
flushin interfaceEncodedAppender- Throws:
java.io.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
-
-