org.apache.axiom.mime

## Class MediaType

- java.lang.Object
- - org.apache.axiom.mime.MediaType

-     public final class MediaType
      extends Object

  Represents a media type as defined by RFC 2045 and RFC 2046. It specifies a primary type (e.g. `text`) and a subtype (e.g. `xml`). Note that in RFC 2045, "media type" refers to what is called "primary type" here, while this class uses "media type" to refer to the combination of primary and subtype.

  This class is immutable. It overrides `Object.equals(Object)` and `Object.hashCode()` to allow comparing media types as described by RFC 2045, i.e. in a case insensitive way.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static MediaType` | `APPLICATION_SOAP_XML` The media type for `application/soap+xml`.
    `static MediaType` | `APPLICATION_XML` The media type for `application/xml`.
    `static MediaType` | `APPLICATION_XOP_XML` The media type for `application/xop+xml`.
    `static MediaType` | `MULTIPART_RELATED` The media type for `multipart/related`.
    `static MediaType` | `TEXT_XML` The media type for `text/xml`.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MediaType(String type)` Constructor that parses a media type.
    `MediaType(String primaryType, String subType)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object obj)`
    `String` | `getPrimaryType()` Get the primary type.
    `String` | `getSubType()` Get the subtype.
    `int` | `hashCode()`
    `String` | `toString()`

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### TEXT_XML

          public static final MediaType TEXT_XML

      The media type for `text/xml`.

    - #### APPLICATION_XML

          public static final MediaType APPLICATION_XML

      The media type for `application/xml`.

    - #### APPLICATION_SOAP_XML

          public static final MediaType APPLICATION_SOAP_XML

      The media type for `application/soap+xml`.

    - #### APPLICATION_XOP_XML

          public static final MediaType APPLICATION_XOP_XML

      The media type for `application/xop+xml`.

    - #### MULTIPART_RELATED

          public static final MediaType MULTIPART_RELATED

      The media type for `multipart/related`.

  - ### Constructor Detail

    - #### MediaType

          public MediaType(String primaryType,
                           String subType)

      Constructor.
      Parameters:
        `primaryType` - the primary type
        `subType` - the subtype

    - #### MediaType

          public MediaType(String type)
                    throws ParseException

      Constructor that parses a media type.
      Parameters:
        `type` - the media type to parse
      Throws:
        `ParseException` - if the value is invalid and could not be parsed

  - ### Method Detail

    - #### getPrimaryType

          public String getPrimaryType()

      Get the primary type.
      Returns:
        the primary type

    - #### getSubType

          public String getSubType()

      Get the subtype.
      Returns:
        the subtype

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © The Apache Software Foundation. All Rights Reserved.