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
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Encoding()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods 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 Detail
-
_log
protected final Log _log
-
-
Method Detail
-
getName
public abstract String getName()
-
encode
public abstract String encode(byte[] in) throws EncodingException
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
public String encode(String str) throws EncodingException
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
public void encode(InputStream in, Writer out) throws IOException
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
public Buffer decode(byte[] in) throws DecodingException
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
public Buffer decode(byte[] in, int offset, int length) throws DecodingException
- Parameters:
in
-offset
-length
-- Returns:
- Output buffer containing decoded String.
- Throws:
DecodingException
-
decode
public Buffer decode(String str) throws DecodingException
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
public Buffer decode(Buffer in) throws IOException
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
public void decode(Buffer in, Buffer out) throws IOException
- Parameters:
in
-- Throws:
DecodingException
IOException
- Since:
- 0.9.34
- See Also:
decode(byte[], int, int)
-
decode
public abstract void decode(InputStream in, Buffer out) throws IOException
- Parameters:
in
-- Throws:
DecodingException
IOException
- Since:
- 0.9.34
- See Also:
decode(byte[], int, int)
-
-