org.apache.hc.client5.http.entity.mime

## Class AbstractContentBody

- java.lang.Object
- - org.apache.hc.client5.http.entity.mime.AbstractContentBody

- All Implemented Interfaces:
    ContentBody, ContentDescriptor
  Direct Known Subclasses:
    ByteArrayBody, FileBody, InputStreamBody, StringBody

      public abstract class AbstractContentBody
      extends Object
      implements ContentBody

  Since:
    4.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractContentBody(ContentType contentType)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getCharset()` The body descriptors character set, defaulted appropriately for the MIME type.
    `ContentType` | `getContentType()`
    `String` | `getMediaType()` Gets the defaulted MIME media type for this content.
    `String` | `getMimeType()` Returns the body descriptors MIME type.
    `String` | `getSubType()` Gets the defaulted MIME sub type for this content.

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

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

    - ### Methods inherited from interface org.apache.hc.client5.http.entity.mime.ContentBody

      `getFilename, writeTo`

    - ### Methods inherited from interface org.apache.hc.client5.http.entity.mime.ContentDescriptor

      `getContentLength`

- - ### Constructor Detail

    - #### AbstractContentBody

          public AbstractContentBody(ContentType contentType)

      Since:
        4.3

  - ### Method Detail

    - #### getContentType

          public ContentType getContentType()

      Since:
        4.3

    - #### getMimeType

          public String getMimeType()

      Description copied from interface: `ContentDescriptor`
      Returns the body descriptors MIME type.
      Specified by:
        `getMimeType` in interface `ContentDescriptor`
      Returns:
        The MIME type, which has been parsed from the content-type definition. Must not be null, but "text/plain", if no content-type was specified.
      See Also:
        `ContentDescriptor.getMediaType()`, `ContentDescriptor.getSubType()`

    - #### getMediaType

          public String getMediaType()

      Description copied from interface: `ContentDescriptor`
      Gets the defaulted MIME media type for this content. For example `TEXT`, `IMAGE`, `MULTIPART`
      Specified by:
        `getMediaType` in interface `ContentDescriptor`
      Returns:
        the MIME media type when content-type specified, otherwise the correct default (`TEXT`)
      See Also:
        `ContentDescriptor.getMimeType()`

    - #### getSubType

          public String getSubType()

      Description copied from interface: `ContentDescriptor`
      Gets the defaulted MIME sub type for this content.
      Specified by:
        `getSubType` in interface `ContentDescriptor`
      Returns:
        the MIME media type when content-type is specified, otherwise the correct default (`PLAIN`)
      See Also:
        `ContentDescriptor.getMimeType()`

    - #### getCharset

          public String getCharset()

      Description copied from interface: `ContentDescriptor`

      The body descriptors character set, defaulted appropriately for the MIME type.

      For `TEXT` types, this will be defaulted to `us-ascii`. For other types, when the charset parameter is missing this property will be null.

      Specified by:
        `getCharset` in interface `ContentDescriptor`
      Returns:
        Character set, which has been parsed from the content-type definition. Not null for `TEXT` types, when unset will be set to default `us-ascii`. For other types, when unset, null will be returned.

Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.