public abstract class AbstractRFC1522Codec extends Object implements ICodec<String>
RFC 1522 describes techniques to allow the encoding of non-ASCII text in various portions of a RFC 822 [2] message header, in a manner which is unlikely to confuse existing message handling software.
This class is immutable and thread-safe.
| Modifier and Type | Field and Description |
|---|---|
protected static String |
POSTFIX
Postfix.
|
protected static String |
PREFIX
Prefix.
|
protected static char |
SEP
Separator.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractRFC1522Codec(Charset aCharset)
Constructor which allows for the selection of a default charset
|
| Modifier and Type | Method and Description |
|---|---|
Charset |
getCharset() |
protected abstract byte[] |
getDecoded(byte[] aEncodedBuffer,
int nOfs,
int nLen) |
String |
getDecoded(String sEncodedText)
Applies an RFC 1522 compliant decoding scheme to the given string of text.
|
protected abstract byte[] |
getEncoded(byte[] aDecodedBuffer,
int nOfs,
int nLen) |
String |
getEncoded(String sText)
Applies an RFC 1522 compliant encoding scheme to the given string of text
with the given charset.
|
protected abstract String |
getRFC1522Encoding()
Returns the codec name (referred to as encoding in the RFC 1522).
|
protected static final char SEP
protected static final String PREFIX
protected static final String POSTFIX
@Nonnull @Nonempty protected abstract String getRFC1522Encoding()
@Nullable @ReturnsMutableCopy protected abstract byte[] getEncoded(@Nullable byte[] aDecodedBuffer, @Nonnegative int nOfs, @Nonnegative int nLen)
@Nullable @ReturnsMutableCopy protected abstract byte[] getDecoded(@Nullable byte[] aEncodedBuffer, @Nonnegative int nOfs, @Nonnegative int nLen)
@Nullable public String getEncoded(@Nullable String sText) throws EncodeException
This method constructs the "encoded-word" header common to all the RFC 1522 codecs and then invokes #getEncoded(byte []) method of a concrete class to perform the specific encoding.
getEncoded in interface IEncoder<String,String>sText - a string to encodeEncodeException - thrown if there is an error condition during the Encoding process.@Nullable public String getDecoded(@Nullable String sEncodedText) throws DecodeException
This method processes the "encoded-word" header common to all the RFC 1522 codecs and then invokes #getDecoded(byte []) method of a concrete class to perform the specific decoding.
getDecoded in interface IDecoder<String,String>sEncodedText - a string to decodenull if the input is null.DecodeException - thrown if there is an error condition during the decoding process.Copyright © 2014–2016 Philip Helger. All rights reserved.