public abstract class AbstractCharReplacementEncoder extends java.lang.Object implements Encoder, StreamingEncoder, EncodesToWriter
StreamingEncoder interface that enables efficient
streaming encoding| Modifier and Type | Field and Description |
|---|---|
protected CodecIdentifier |
codecIdentifier |
| Constructor and Description |
|---|
AbstractCharReplacementEncoder(CodecIdentifier codecIdentifier) |
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.String |
convertToString(java.lang.Object o) |
EncodesToWriter |
createChainingEncodesToWriter(java.util.List<StreamingEncoder> encoders,
boolean applyAdditionalFirst) |
protected java.lang.Object |
doCharReplacementEncoding(java.lang.Object o) |
java.lang.Object |
encode(java.lang.Object o)
Encode given input object
|
void |
encodeToStream(Encoder thisInstance,
java.lang.CharSequence str,
int off,
int len,
EncodedAppender appender,
EncodingState encodingState)
Encode and append portion of source CharSequence to the appender.
|
void |
encodeToWriter(char[] buf,
int off,
int len,
java.io.Writer writer,
EncodingState encodingState) |
void |
encodeToWriter(java.lang.CharSequence str,
int off,
int len,
java.io.Writer writer,
EncodingState encodingState) |
protected abstract java.lang.String |
escapeCharacter(char ch,
char previousChar)
Escape the character, return null if no replacement has to be made
|
protected java.lang.Object |
escapeCharSequence(java.lang.CharSequence str) |
CodecIdentifier |
getCodecIdentifier()
Gets the codec identifier information.
|
boolean |
isApplyToSafelyEncoded() |
boolean |
isSafe()
Checks if this encoder is XSS "safe".
|
void |
markEncoded(java.lang.CharSequence string)
Mark this instance as encoded with this encoder in the current
EncodingStateRegistry |
protected CodecIdentifier codecIdentifier
public AbstractCharReplacementEncoder(CodecIdentifier codecIdentifier)
protected abstract java.lang.String escapeCharacter(char ch,
char previousChar)
ch - the character to escapepreviousChar - the previous charpublic java.lang.Object encode(java.lang.Object o)
Encoderprotected final java.lang.Object doCharReplacementEncoding(java.lang.Object o)
protected java.lang.String convertToString(java.lang.Object o)
protected java.lang.Object escapeCharSequence(java.lang.CharSequence str)
public void encodeToWriter(java.lang.CharSequence str,
int off,
int len,
java.io.Writer writer,
EncodingState encodingState)
throws java.io.IOException
encodeToWriter in interface EncodesToWriterjava.io.IOExceptionpublic void encodeToWriter(char[] buf,
int off,
int len,
java.io.Writer writer,
EncodingState encodingState)
throws java.io.IOException
encodeToWriter in interface EncodesToWriterjava.io.IOExceptionpublic EncodesToWriter createChainingEncodesToWriter(java.util.List<StreamingEncoder> encoders, boolean applyAdditionalFirst)
createChainingEncodesToWriter in interface EncodesToWriterpublic void encodeToStream(Encoder thisInstance, java.lang.CharSequence str, int off, int len, EncodedAppender appender, EncodingState encodingState) throws java.io.IOException
StreamingEncoderencodeToStream in interface StreamingEncoderstr - The source CharSequenceoff - Offset from which to start encoding characterslen - Number of characters to encodeappender - the appender to write toencodingState - the current encoding statejava.io.IOException - Signals that an I/O exception has occurred.public void markEncoded(java.lang.CharSequence string)
EncoderEncodingStateRegistrymarkEncoded in interface Encoderstring - a CharSequence to mark as encodedpublic boolean isSafe()
Encoderpublic boolean isApplyToSafelyEncoded()
isApplyToSafelyEncoded in interface Encodertrue if this this codec should be applied to a buffer part that is
already encoded with a safe encoderpublic CodecIdentifier getCodecIdentifier()
CodecIdentifierProvidergetCodecIdentifier in interface CodecIdentifierProvider