public interface IEncoder
Important: Each class implementing this interface must have a Nullary Constructor, so the object can be instantiated using the Class.fromName() methods by the EncoderManager.
GenericFilterWriter/GenericSkeleton, only an IEncoder
implementation is needed. Encoding is handled automatically in this case
based on MimeTypeMapper.
EncoderContext. Normally the encoder shouldn't be run on SKELETON or
INLINE content - or only run with a small subset of cases as compared to TEXT
(the goal is to keep SKELETON/INLINE as close to the original as possible).
IParameters can be passed to the IEncoder if more
configuration is needed.
QuoteMode is also provided to help guide logic around double and
single quotes. Some encoders take more parameters in their constructor
(XMLEncoder)
IFilterWriter should be
implemented. This will give the full context of the TextUnit and
surrounding Events. Encoding can be applied with more nuance. However
an IEncoder can still be implemented for default cases.
IFilterWriter and/or
IEncoder implementations. Not handled in ad hoc ways.
| Modifier and Type | Method and Description |
|---|---|
String |
encode(char value,
EncoderContext context)
Encodes a given character with this encoding.
|
String |
encode(int codePoint,
EncoderContext context)
Encodes a given code-point with this encoding.
|
String |
encode(String text,
EncoderContext context)
Encodes a given text with this encoder.
|
default CharsetEncoder |
getCharsetEncoder()
Gets the character set encoder used for this encoder.
|
default String |
getEncoding()
Gets the name of the charset encoding to use.
|
default String |
getLineBreak()
Gets the line-break to use for this encoder.
|
IParameters |
getParameters()
Gets the parameters object with all the configuration information specific to
this encoder.
|
void |
reset()
Reset state in this encoder in preparation for processing new content.
|
void |
setOptions(IParameters params,
String encoding,
String lineBreak)
Sets the options for this encoder.
|
default String |
toNative(String propertyName,
String value)
Converts any property values from its standard representation to the native
representation for this encoder.
|
void reset()
void setOptions(IParameters params, String encoding, String lineBreak)
params - the parameters object with all the configuration information
specific to this encoder.encoding - the name of the charset encoding to use.lineBreak - the type of line break to use.String encode(String text, EncoderContext context)
text - the text to encode.context - the context of the text: 0=text, 1=skeleton, 2=inline.String encode(int codePoint, EncoderContext context)
codePoint - the code-point to encode.context - the context of the character: 0=text, 1=skeleton, 2=inline.String encode(char value, EncoderContext context)
value - the character to encode.context - the context of the character: 0=text, 1=skeleton, 2=inline.default String toNative(String propertyName, String value)
propertyName - the name of the property.value - the standard value to convert.default String getLineBreak()
default String getEncoding()
default CharsetEncoder getCharsetEncoder()
IParameters getParameters()
Copyright © 2022. All rights reserved.