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

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `NAME`

    - ### Fields inherited from class i2p.susi.webmail.encoding.Encoding

      `_log`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HeaderLine()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `decode(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\n
    `String` | `encode(byte[] in)` This will split multibyte chars across lines, see 4th ref above
    `String` | `encode(String str)` Encode a single header line ONLY.
    `String` | `getName()` Returns the name of this encoding.

    - ### Methods inherited from class i2p.susi.webmail.encoding.Encoding

      `decode, decode, decode, decode, decode, encode`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### NAME

          public static final String NAME

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### HeaderLine

          public HeaderLine()

  - ### Method Detail

    - #### 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:
        `decode` in class `Encoding`
      Parameters:
        `in` - the input stream to read data from
        `bout` - the buffer to write decoded data to
      Throws:
        `DecodingException` - if decoding fails
        `IOException` - if reading from input stream fails
      See Also:
        `Encoding.decode(byte[], int, int)`

    - #### encode

          public String encode(byte[] in)
                        throws EncodingException

      This will split multibyte chars across lines, see 4th ref above
      Specified by:
        `encode` in class `Encoding`
      Parameters:
        `in` - the byte array to encode
      Returns:
        the encoded string, SMTP-safe
      Throws:
        `UnsupportedOperationException` - always
        `EncodingException` - if encoding fails

    - #### 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:
        `encode` in class `Encoding`
      Parameters:
        `str` - must start with "field-name: ", must have non-whitespace after that
      Throws:
        `EncodingException` - if encoding fails
      See Also:
        `Encoding.encode(byte[])`

    - #### getName

          public String getName()

      Description copied from class: `Encoding`
      Returns the name of this encoding.
      Specified by:
        `getName` in class `Encoding`
      Returns:
        the encoding name