com.jscape.inet.mime

## Class MimeHeader

- java.lang.Object
- - com.jscape.inet.mime.MimeHeader

- All Implemented Interfaces:
    java.io.Serializable
  Direct Known Subclasses:
    HttpCookie

      public class MimeHeader
      extends java.lang.Object
      implements java.io.Serializable

  Implements methods for managing mime headers for use in a `MimeMessage`.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MimeHeader()` Constructs a new `MimeHeader` instance.
    `MimeHeader(byte[] data)` Constructs a new `MimeHeader` instance.
    `MimeHeader(java.lang.String name, java.lang.String value)` Constructs a new `MimeHeader` instance.
    `MimeHeader(java.lang.String name, java.lang.String value, java.lang.String characterEncoding)` Constructs a new `MimeHeader` instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addAttribute(MimeHeaderAttr attr)` Adds attribute to this `MimeHeader`.
    `void` | `addAttribute(java.lang.String name, java.lang.String value)` Adds attribute to this `MimeHeader`.
    `MimeHeaderAttr` | `getAttribute(java.lang.String name)` Gets attribute by name.
    `java.util.Enumeration` | `getAttributes()` Gets all attributes for this `MimeHeader`.
    `java.lang.String` | `getName()` Gets name for this `MimeHeader`.
    `java.lang.String` | `getValue()` Gets value for this `MimeHeader`.
    `java.lang.String` | `getValueString()` Gets value for this `MimeHeader`.
    `boolean` | `isFolding()` Checks if folding should be enabled for this `MimeHeader`.
    `boolean` | `isValid()` Checks if this header is valid.
    `void` | `removeAttribute(int index)` Removes specified index from attributes.
    `void` | `setFolding(boolean folding)` Enables or disables folding for this `MimeHeader`.
    `void` | `setName(java.lang.String name)` Sets name of this `MimeHeader`.
    `void` | `setValue(java.lang.String value)` Sets the value of this `MimeHeader`.
    `java.lang.String` | `toString()` Gets String representation of this `MimeHeader`.

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

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### MimeHeader

          public MimeHeader()
                     throws MimeException

      Constructs a new `MimeHeader` instance.
      Throws:
        `MimeException` - if a MIME related parsing error occurs

    - #### MimeHeader

          public MimeHeader(java.lang.String name,
                            java.lang.String value)
                     throws MimeException

      Constructs a new `MimeHeader` instance.
      Parameters:
        `name` - the name of header
        `value` - the value of header
      Throws:
        `MimeException` - if a MIME related parsing error occurs

    - #### MimeHeader

          public MimeHeader(java.lang.String name,
                            java.lang.String value,
                            java.lang.String characterEncoding)
                     throws MimeException

      Constructs a new `MimeHeader` instance.
      Parameters:
        `name` - the name of header
        `value` - the value of header
        `characterEncoding` - the character encoding to encode value as
      Throws:
        `MimeException` - thrown if character encoding can not be completed or header does not allow character encoding

    - #### MimeHeader

          public MimeHeader(byte[] data)
                     throws MimeException

      Constructs a new `MimeHeader` instance. The MIME header data is parsed.
      Parameters:
        `data` - the MIME header data
      Throws:
        `MimeException` - if a MIME related parsing error occurs

  - ### Method Detail

    - #### getName

          public java.lang.String getName()

      Gets name for this `MimeHeader`.
      Returns:
        name

    - #### getValue

          public java.lang.String getValue()

      Gets value for this `MimeHeader`. Any encoded values in header will be decoded according to RFC 2047. Strips quotes from value.
      Returns:
        value

    - #### getValueString

          public java.lang.String getValueString()

      Gets value for this `MimeHeader`. Leaves quotes in value. Any encoded values in header will be decoded according to RFC 2047.
      Returns:
        value

    - #### setName

          public void setName(java.lang.String name)

      Sets name of this `MimeHeader`.
      Parameters:
        `name` - the header name

    - #### setValue

          public void setValue(java.lang.String value)

      Sets the value of this `MimeHeader`.
      Parameters:
        `value` - the header value

    - #### addAttribute

          public void addAttribute(MimeHeaderAttr attr)

      Adds attribute to this `MimeHeader`.
      Parameters:
        `attr` - a MimeHeaderAttr
      See Also:
        `MimeHeaderAttr`

    - #### addAttribute

          public void addAttribute(java.lang.String name,
                                   java.lang.String value)
                            throws MimeException

      Adds attribute to this `MimeHeader`.
      Parameters:
        `name` - the name of the MIME header attribute
        `value` - the value of the MIME header attribute
      Throws:
        `MimeException` - if a MIME related error occurs

    - #### removeAttribute

          public void removeAttribute(int index)

      Removes specified index from attributes.
      Parameters:
        `index` - the index of attribute to remove

    - #### getAttribute

          public MimeHeaderAttr getAttribute(java.lang.String name)

      Gets attribute by name.
      Parameters:
        `name` - the name of attribute to retrieve
      Returns:
        a `MimeHeaderAttr`
      See Also:
        `MimeHeaderAttr`

    - #### getAttributes

          public java.util.Enumeration getAttributes()

      Gets all attributes for this `MimeHeader`. Returns an Enumeration of `MimeHeaderAttr`
      Returns:
        Enumeration
      See Also:
        `MimeHeaderAttr`

    - #### toString

          public java.lang.String toString()

      Gets String representation of this `MimeHeader`.
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        String

    - #### isFolding

          public boolean isFolding()

      Checks if folding should be enabled for this `MimeHeader`. Folding is enabled by default. If folding is enabled then the maximum length of a header is 76 characters. Headers which exceed 76 characters will be folded according to RFC 822.
      Returns:
        `true` if folding is enabled, `false` otherwise

    - #### setFolding

          public void setFolding(boolean folding)

      Enables or disables folding for this `MimeHeader`. Folding is enabled by default. If folding is enabled then the maximum length of a header is 76 characters. Headers which exceed 76 characters will be folded according to RFC 822.
      Parameters:
        `folding` - `true` to enable folding, `false` to disable

    - #### isValid

          public boolean isValid()

      Checks if this header is valid.
      Returns:
        true if header is valid, false otherwise

Copyright © JSCAPE LLC. 1999-2021. All Rights Reserved