java.lang.Object
i2p.susi.webmail.encoding.Encoding
- Direct Known Subclasses:
Base64, EightBit, HeaderLine, HTML, QuotedPrintable, SevenBit
Interface to encode/decode content transfer encodings like quoted-printable, base64 etc.
Field Summary
Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptiondecode(byte[] in) Decode a byte array using default offset and length.decode(byte[] in, int offset, int length) Decode a portion of a byte array.Decode a buffer into another buffer.voidDecode a buffer into another buffer using the input stream.abstract voiddecode(InputStream in, Buffer out) Decode an input stream into a buffer.Decode a string.abstract Stringencode(byte[] in) Encode a byte array to a ASCII or ISO-8859-1 String.voidencode(InputStream in, Writer out) Encode an input stream of bytes to a ASCII or ISO-8859-1 String.Encode a (UTF-8) String to a ASCII or ISO-8859-1 String.abstract StringgetName()Returns the name of this encoding.
Field Details
_log
Logger for the encoding subclass.
Constructor Details
Encoding
protected Encoding()Creates an Encoding with a logger.
Method Details
getName
encode
Encode a byte array to a ASCII or ISO-8859-1 String. Output must be SMTP-safe: Line length of 998 or less, using SMTP-safe characters, followed by \r\n, and must not start with a '.' unless escaped by a 2nd dot. For some encodings, max line length is 76.- Parameters:
in- the byte array to encode- Returns:
- the encoded string, SMTP-safe
- Throws:
EncodingException- if encoding fails
encode
Encode a (UTF-8) String to a ASCII or ISO-8859-1 String. Output must be SMTP-safe: Line length of 998 or less, using SMTP-safe characters, followed by \r\n, and must not start with a '.' unless escaped by a 2nd dot. For some encodings, max line length is 76. This implementation just converts the string to a byte array and then calls encode(byte[]). Most classes will not need to override.- Parameters:
str- the string to encode- Returns:
- the encoded string, SMTP-safe
- Throws:
EncodingException- if encoding fails- See Also:
encode
Encode an input stream of bytes to a ASCII or ISO-8859-1 String. Output must be SMTP-safe: Line length of 998 or less, using SMTP-safe characters, followed by \r\n, and must not start with a '.' unless escaped by a 2nd dot. For some encodings, max line length is 76. This implementation just reads the whole stream into memory and then calls encode(byte[]). Subclasses should implement a more memory-efficient method if large inputs are expected.- Parameters:
in- the input stream to encodeout- the writer to write encoded output to- Throws:
IOException- if reading from stream or writing fails
decode
Decode a byte array using default offset and length. This implementation just calls decode(in, 0, in.length). Most classes will not need to override.- Parameters:
in- the byte array to decode- Returns:
- a buffer containing the decoded data
- Throws:
DecodingException- if decoding fails- See Also:
decode
Decode a portion of a byte array.- Parameters:
in- the byte array to decodeoffset- the starting position in the arraylength- the number of bytes to decode- Returns:
- a buffer containing the decoded data as a String
- Throws:
DecodingException- if decoding fails
decode
Decode a string. This implementation just converts the string to a byte array and then calls decode(byte[]). Most classes will not need to override.- Parameters:
str- the string to decode- Returns:
- a buffer containing the decoded data, or null if str is null
- Throws:
DecodingException- if decoding fails- See Also:
decode
Decode a buffer into another buffer. This implementation just calls decode(in.content, in.offset, in.length). Most classes will not need to override.- Parameters:
in- the buffer containing data to decode- Returns:
- a buffer containing the decoded data
- Throws:
DecodingException- if decoding failsIOException- See Also:
decode
Decode a buffer into another buffer using the input stream.- Parameters:
in- the buffer containing data to decodeout- the buffer to write decoded data to- Throws:
DecodingException- if decoding failsIOException- if reading from input stream fails- See Also:
decode
Decode an input stream into a buffer.- Parameters:
in- the input stream to read data fromout- the buffer to write decoded data to- Throws:
DecodingException- if decoding failsIOException- if reading from input stream fails- See Also: