Search in sources :

Example 1 with DecoderException

use of com.github.mangstadt.vinnie.codec.DecoderException in project vinnie by mangstadt.

the class VObjectReader method decodeQuotedPrintable.

/**
 * Decodes the given property's value from quoted-printable encoding.
 * @param property the property
 * @param listener the data listener
 */
private void decodeQuotedPrintable(VObjectProperty property, VObjectDataListener listener) {
    Charset charset = getCharset(property, listener);
    if (charset == null) {
        charset = defaultQuotedPrintableCharset;
    }
    String value = property.getValue();
    QuotedPrintableCodec codec = new QuotedPrintableCodec(charset.name());
    try {
        value = codec.decode(value);
    } catch (DecoderException e) {
        listener.onWarning(Warning.QUOTED_PRINTABLE_ERROR, property, e, context);
        return;
    }
    property.setValue(value);
}
Also used : DecoderException(com.github.mangstadt.vinnie.codec.DecoderException) QuotedPrintableCodec(com.github.mangstadt.vinnie.codec.QuotedPrintableCodec) Charset(java.nio.charset.Charset)

Aggregations

DecoderException (com.github.mangstadt.vinnie.codec.DecoderException)1 QuotedPrintableCodec (com.github.mangstadt.vinnie.codec.QuotedPrintableCodec)1 Charset (java.nio.charset.Charset)1