Package com.helger.base.codec.impl
Class QuotedPrintableCodec
java.lang.Object
com.helger.base.codec.impl.QuotedPrintableCodec
- All Implemented Interfaces:
IByteArrayCodec,IByteArrayDecoder,IByteArrayEncoder,IByteArrayStreamDecoder,IByteArrayStreamEncoder,ICodec<byte[]>,IDecoder<byte[],,byte[]> IEncoder<byte[],byte[]>
Encoder and decoder for quoted printable stuff. Uses "=" as the escape char.
- Author:
- Philip Helger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final bytestatic final bytestatic final byte -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor with the UTF-8 charset.QuotedPrintableCodec(@NonNull BitSet aPrintableChars) Constructor using a custom set of printable characters. -
Method Summary
Modifier and TypeMethodDescriptionvoiddecode(byte @Nullable [] aEncodedBuffer, int nOfs, int nLen, @NonNull OutputStream aOS) Decode the passed quoted-printable encoded buffer and write the decoded bytes to the output stream.voidencode(byte @Nullable [] aDecodedBuffer, int nOfs, int nLen, @NonNull OutputStream aOS) Encode the passed decoded buffer using quoted-printable encoding and write it to the output stream.static @NonNull BitSet@NonNull BitSetstatic final voidwriteEncodeQuotedPrintableByte(int b, @NonNull OutputStream aOS) Encodes byte into its quoted-printable representation.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.helger.base.codec.IByteArrayDecoder
getDecoded, getDecoded, getMaximumDecodedLengthMethods inherited from interface com.helger.base.codec.IByteArrayStreamDecoder
decode, getDecoded, getDecodedAsString, getDecodedAsString, getDecodedAsString, getDecodedAsStringMethods inherited from interface com.helger.base.codec.IByteArrayStreamEncoder
encode, getEncoded, getEncoded, getEncoded, getEncodedAsString, getEncodedAsString, getEncodedAsString, getMaximumEncodedLength
-
Field Details
-
ESCAPE_CHAR
public static final byte ESCAPE_CHAR- See Also:
-
TAB
public static final byte TAB- See Also:
-
SPACE
public static final byte SPACE- See Also:
-
-
Constructor Details
-
QuotedPrintableCodec
public QuotedPrintableCodec()Default constructor with the UTF-8 charset. -
QuotedPrintableCodec
Constructor using a custom set of printable characters.- Parameters:
aPrintableChars- The set of printable characters. May not benull.
-
-
Method Details
-
getDefaultPrintableChars
- Returns:
- A copy of the default bit set to be used.
-
getPrintableChars
- Returns:
- A copy of the default bit set to be used. Never
null.
-
writeEncodeQuotedPrintableByte
public static final void writeEncodeQuotedPrintableByte(int b, @NonNull OutputStream aOS) throws IOException Encodes byte into its quoted-printable representation. It will always be 3 characters.- Parameters:
b- byte to encodeaOS- the output stream to write to- Throws:
IOException- In case writing to the OutputStream failed
-
encode
public void encode(byte @Nullable [] aDecodedBuffer, @Nonnegative int nOfs, @Nonnegative int nLen, @WillNotClose @NonNull OutputStream aOS) Encode the passed decoded buffer using quoted-printable encoding and write it to the output stream.- Specified by:
encodein interfaceIByteArrayStreamEncoder- Parameters:
aDecodedBuffer- The buffer to be encoded. May benull.nOfs- The offset in the buffer to start encoding from.nLen- The number of bytes to encode.aOS- The output stream to write the encoded data to. May not benull.
-
decode
public void decode(byte @Nullable [] aEncodedBuffer, @Nonnegative int nOfs, @Nonnegative int nLen, @WillNotClose @NonNull OutputStream aOS) Decode the passed quoted-printable encoded buffer and write the decoded bytes to the output stream.- Specified by:
decodein interfaceIByteArrayStreamDecoder- Parameters:
aEncodedBuffer- The quoted-printable encoded buffer to be decoded. May benull.nOfs- The offset in the buffer to start decoding from.nLen- The number of bytes to decode.aOS- The output stream to write the decoded data to. May not benull.
-