Package i2p.susi.webmail.encoding
Class Encoding
java.lang.Object
i2p.susi.webmail.encoding.Encoding
- Direct Known Subclasses:
Base64
,EightBit
,HeaderLine
,HTML
,QuotedPrintable
,SevenBit
public abstract class Encoding extends Object
Interface to encode/decode content transfer encodings like quoted-printable, base64 etc.
- Since:
- 0.9.33 changed from interface to abstract class
- Author:
- susi
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description protected
Encoding()
-
Method Summary
Modifier and Type Method Description Buffer
decode(byte[] in)
This implementation just calls decode(in, 0, in.length).Buffer
decode(byte[] in, int offset, int length)
Buffer
decode(Buffer in)
This implementation just calls decode(in.content, in.offset, in.length).void
decode(Buffer in, Buffer out)
abstract void
decode(InputStream in, Buffer out)
Buffer
decode(String str)
This implementation just converts the string to a byte array and then calls decode(byte[]).abstract String
encode(byte[] in)
Encode a byte array to a ASCII or ISO-8859-1 String.void
encode(InputStream in, Writer out)
Encode an input stream of bytes to a ASCII or ISO-8859-1 String.String
encode(String str)
Encode a (UTF-8) String to a ASCII or ISO-8859-1 String.abstract String
getName()
-
Field Details
-
Constructor Details
-
Encoding
protected Encoding()
-
-
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
-- Returns:
- Encoded string.
- Throws:
EncodingException
-
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
-- Throws:
EncodingException
- Since:
- 0.9.33 implementation moved from subclasses
- See Also:
encode(byte[])
-
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.- Throws:
IOException
- Since:
- 0.9.33
-
decode
This implementation just calls decode(in, 0, in.length). Most classes will not need to override.- Parameters:
in
-- Throws:
DecodingException
- Since:
- 0.9.33 implementation moved from subclasses
- See Also:
decode(byte[], int, int)
-
decode
- Parameters:
in
-offset
-length
-- Returns:
- Output buffer containing decoded String.
- Throws:
DecodingException
-
decode
This implementation just converts the string to a byte array and then calls decode(byte[]). Most classes will not need to override.- Parameters:
str
-- Returns:
- null if str is null
- Throws:
DecodingException
- Since:
- 0.9.33 implementation moved from subclasses
- See Also:
decode(byte[], int, int)
-
decode
This implementation just calls decode(in.content, in.offset, in.length). Most classes will not need to override.- Parameters:
in
-- Throws:
DecodingException
IOException
- Since:
- 0.9.33 implementation moved from subclasses
- See Also:
decode(byte[], int, int)
-
decode
- Parameters:
in
-- Throws:
DecodingException
IOException
- Since:
- 0.9.34
- See Also:
decode(byte[], int, int)
-
decode
- Parameters:
in
-- Throws:
DecodingException
IOException
- Since:
- 0.9.34
- See Also:
decode(byte[], int, int)
-