Package i2p.susi.webmail.encoding
Class HeaderLine
- java.lang.Object
-
- i2p.susi.webmail.encoding.Encoding
-
- i2p.susi.webmail.encoding.HeaderLine
-
public class HeaderLine extends Encoding
Ref: http://en.wikipedia.org/wiki/MIME#Encoded-Word http://tools.ietf.org/html/rfc2047 https://jeffreystedfast.blogspot.com/2013/09/time-for-rant-on-mime-parsers.html https://jeffreystedfast.blogspot.com/2013/08/why-decoding-rfc2047-encoded-headers-is.html- Author:
- susi
-
-
Constructor Summary
Constructors Constructor Description HeaderLine()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddecode(InputStream in, Buffer bout)Decode all the header lines, up through \r\n\r\n, and puts them in the ReadBuffer, including the \r\n\r\nStringencode(byte[] in)This will split multibyte chars across lines, see 4th ref aboveStringencode(String str)Encode a single header line ONLY.StringgetName()
-
-
-
Field Detail
-
NAME
public static final String NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
encode
public String encode(byte[] in) throws EncodingException
This will split multibyte chars across lines, see 4th ref above- Specified by:
encodein classEncoding- Returns:
- Encoded string.
- Throws:
UnsupportedOperationException- alwaysEncodingException
-
encode
public String encode(String str) throws EncodingException
Encode a single header line ONLY. Do NOT include the \r\n. Returns a string of one or more lines including the trailing \r\n. Field-name will not be encoded, must be less than 62 chars. The fieldBody is treated as "unstructured text", which is suitable only for the field names "Subject" and "Comments". We do NOT tokenize into structured fields. To make things easy, we either encode the whole field body as RFC 2047, or don't encode at all. If it's too long for a single line, we encode it, even if we didn't otherwise have to. We don't do quoted-string. This will not split multibyte chars, including supplementary chars, across lines. TODO this will not work for quoting structured text such as recipient names on the "To" and "Cc" lines.- Overrides:
encodein classEncoding- Parameters:
str- must start with "field-name: ", must have non-whitespace after that- Throws:
EncodingException- See Also:
Encoding.encode(byte[])
-
decode
public void decode(InputStream in, Buffer bout) throws IOException
Decode all the header lines, up through \r\n\r\n, and puts them in the ReadBuffer, including the \r\n\r\n- Specified by:
decodein classEncoding- Throws:
DecodingExceptionIOException- See Also:
Encoding.decode(byte[], int, int)
-
-