org.apache.axiom.mime

## Class ContentTypeBuilder

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

-     public final class ContentTypeBuilder
      extends Object

  Builder for `ContentType` objects. This class can be used to construct `ContentType` objects or as a mutable alternative to `ContentType` (which is designed to be immutable).

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ContentTypeBuilder(ContentType type)` Constructor that initializes the builder with the media type and parameters from an existing `ContentType` object.
    `ContentTypeBuilder(MediaType mediaType)` Constructor that initializes the builder with a media type and no parameters.
    `ContentTypeBuilder(String type)` Constructor that parses a `Content-Type` header value.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `ContentType` | `build()` Build the `ContentType` object.
    `void` | `clearParameters()` Remove all parameters.
    `MediaType` | `getMediaType()` Get the media type.
    `String` | `getParameter(String name)` Get the specified parameter value.
    `void` | `setMediaType(MediaType mediaType)` Set the media type.
    `void` | `setParameter(String name, String value)` Set the specified parameter value.
    `String` | `toString()` Create a string representation of the content type.

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

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

- - ### Constructor Detail

    - #### ContentTypeBuilder

          public ContentTypeBuilder(MediaType mediaType)

      Constructor that initializes the builder with a media type and no parameters.
      Parameters:
        `mediaType` - the media type

    - #### ContentTypeBuilder

          public ContentTypeBuilder(ContentType type)

      Constructor that initializes the builder with the media type and parameters from an existing `ContentType` object.
      Parameters:
        `type` - the content type

    - #### ContentTypeBuilder

          public ContentTypeBuilder(String type)
                             throws ParseException

      Constructor that parses a `Content-Type` header value.
      Parameters:
        `type` - the value of the `Content-Type` header conforming to RFC 2045
      Throws:
        `ParseException` - if the value is invalid and could not be parsed

  - ### Method Detail

    - #### getMediaType

          public MediaType getMediaType()

      Get the media type.
      Returns:
        the media type

    - #### setMediaType

          public void setMediaType(MediaType mediaType)

      Set the media type.
      Parameters:
        `mediaType` - the media type

    - #### getParameter

          public String getParameter(String name)

      Get the specified parameter value.
      Parameters:
        `name` - the parameter name
      Returns:
        the parameter value, or `null` if no parameter with the given name was found

    - #### setParameter

          public void setParameter(String name,
                                   String value)

      Set the specified parameter value. If a parameter with the given name already exists, it will be replaced. Note that parameter names are case insensitive.
      Parameters:
        `name` - the parameter name
        `value` - the parameter value

    - #### clearParameters

          public void clearParameters()

      Remove all parameters.

    - #### build

          public ContentType build()

      Build the `ContentType` object.
      Returns:
        the `ContentType` object

    - #### toString

          public String toString()

      Create a string representation of the content type. This method uses the same conventions as `ContentType.toString()`.
      Overrides:
        `toString` in class `Object`
      Returns:
        the string representation of this content type

Copyright © The Apache Software Foundation. All Rights Reserved.