Package com.helger.commons.codec
Class AbstractRFC1522Codec
- java.lang.Object
-
- com.helger.commons.codec.AbstractRFC1522Codec
-
- Direct Known Subclasses:
RFC1522BCodec,RFC1522QCodec
public abstract class AbstractRFC1522Codec extends Object implements ICodec<String>
Implements methods common to all codecs defined in RFC 1522.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.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractRFC1522Codec(Charset aCharset)Constructor which allows for the selection of a default charset
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description CharsetgetCharset()protected abstract byte[]getDecoded(byte[] aEncodedBuffer, int nOfs, int nLen)StringgetDecoded(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)StringgetEncoded(String sText)Applies an RFC 1522 compliant encoding scheme to the given string of text with the given charset.protected abstract StringgetRFC1522Encoding()Returns the codec name (referred to as encoding in the RFC 1522).
-
-
-
Field Detail
-
SEP
protected static final char SEP
Separator.- See Also:
- Constant Field Values
-
PREFIX
protected static final String PREFIX
Prefix.- See Also:
- Constant Field Values
-
POSTFIX
protected static final String POSTFIX
Postfix.- See Also:
- Constant Field Values
-
-
Method Detail
-
getRFC1522Encoding
@Nonnull @Nonempty protected abstract String getRFC1522Encoding()
Returns the codec name (referred to as encoding in the RFC 1522).- Returns:
- name of the codec
-
getEncoded
@Nullable @ReturnsMutableCopy protected abstract byte[] getEncoded(@Nullable byte[] aDecodedBuffer, @Nonnegative int nOfs, @Nonnegative int nLen)
-
getDecoded
@Nullable @ReturnsMutableCopy protected abstract byte[] getDecoded(@Nullable byte[] aEncodedBuffer, @Nonnegative int nOfs, @Nonnegative int nLen)
-
getEncoded
@Nullable public String getEncoded(@Nullable String sText)
Applies an RFC 1522 compliant encoding scheme to the given string of text with the given charset.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.
- Specified by:
getEncodedin interfaceIEncoder<String,String>- Parameters:
sText- a string to encode- Returns:
- RFC 1522 compliant "encoded-word"
- Throws:
EncodeException- thrown if there is an error condition during the Encoding process.- See Also:
- Standard charsets
-
getDecoded
@Nullable public String getDecoded(@Nullable String sEncodedText)
Applies an RFC 1522 compliant decoding scheme to the given string of text.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.
- Specified by:
getDecodedin interfaceIDecoder<String,String>- Parameters:
sEncodedText- a string to decode- Returns:
- A new decoded String or
nullif the input isnull. - Throws:
DecodeException- thrown if there is an error condition during the decoding process.
-
-