public class QCodec extends java.lang.Object implements StringEncoder, StringDecoder
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 conditionally thread-safe.
The instance field for encoding blanks is mutable setEncodeBlanks(boolean)
but is not volatile, and accesses are not synchronised.
If an instance of the class is shared between threads, the caller needs to ensure that suitable synchronisation
is used to ensure safe publication of the value between threads, and must not invoke
setEncodeBlanks(boolean)
after initial setup.
Constructor and Description |
---|
QCodec()
Default constructor.
|
QCodec(java.nio.charset.Charset charset)
Constructor which allows for the selection of a default Charset.
|
QCodec(java.lang.String charsetName)
Constructor which allows for the selection of a default Charset.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
decode(java.lang.Object obj)
Decodes a quoted-printable object into its original form.
|
java.lang.String |
decode(java.lang.String str)
Decodes a quoted-printable string into its original form.
|
java.lang.Object |
encode(java.lang.Object obj)
Encodes an object into its quoted-printable form using the default Charset.
|
java.lang.String |
encode(java.lang.String sourceStr)
Encodes a string into its quoted-printable form using the default Charset.
|
java.lang.String |
encode(java.lang.String sourceStr,
java.nio.charset.Charset sourceCharset)
Encodes a string into its quoted-printable form using the specified Charset.
|
java.lang.String |
encode(java.lang.String sourceStr,
java.lang.String sourceCharset)
Encodes a string into its quoted-printable form using the specified Charset.
|
java.nio.charset.Charset |
getCharset()
Gets the default Charset name used for string decoding and encoding.
|
java.lang.String |
getDefaultCharset()
Gets the default Charset name used for string decoding and encoding.
|
boolean |
isEncodeBlanks()
Tests if optional transformation of SPACE characters is to be used
|
void |
setEncodeBlanks(boolean b)
Defines whether optional transformation of SPACE characters is to be used
|
public QCodec()
public QCodec(java.nio.charset.Charset charset)
charset
- the default string Charset to use.public QCodec(java.lang.String charsetName)
charsetName
- the Charset to use.java.nio.charset.UnsupportedCharsetException
- If the named Charset is unavailablepublic java.lang.String encode(java.lang.String sourceStr, java.nio.charset.Charset sourceCharset) throws EncoderException
sourceStr
- string to convert to quoted-printable formsourceCharset
- the Charset for sourceStrEncoderException
- thrown if a failure condition is encountered during the encoding process.public java.lang.String encode(java.lang.String sourceStr, java.lang.String sourceCharset) throws EncoderException
sourceStr
- string to convert to quoted-printable formsourceCharset
- the Charset for sourceStrEncoderException
- thrown if a failure condition is encountered during the encoding process.public java.lang.String encode(java.lang.String sourceStr) throws EncoderException
encode
in interface StringEncoder
sourceStr
- string to convert to quoted-printable formEncoderException
- thrown if a failure condition is encountered during the encoding process.public java.lang.String decode(java.lang.String str) throws DecoderException
decode
in interface StringDecoder
str
- quoted-printable string to convert into its original formDecoderException
- A decoder exception is thrown if a failure condition is encountered during the decode process.public java.lang.Object encode(java.lang.Object obj) throws EncoderException
encode
in interface Encoder
obj
- object to convert to quoted-printable formEncoderException
- thrown if a failure condition is encountered during the encoding process.public java.lang.Object decode(java.lang.Object obj) throws DecoderException
decode
in interface Decoder
obj
- quoted-printable object to convert into its original formDecoderException
- Thrown if the argument is not a String
. Thrown if a failure condition is encountered
during the decode process.public java.nio.charset.Charset getCharset()
public java.lang.String getDefaultCharset()
public boolean isEncodeBlanks()
true
if SPACE characters are to be transformed, false
otherwisepublic void setEncodeBlanks(boolean b)
b
- true
if SPACE characters are to be transformed, false
otherwiseCopyright © 2010 - 2020 Adobe. All Rights Reserved