Interface MediaType

All Superinterfaces:
Parametrized

public interface MediaType extends Parametrized
Interface of media types as defined in RFC 2045, Section 5 and RFC 7231, Section 3.1.1.1

By contract MediaTypes are equal if their main and subtype are equal (using case-insensitive comparison). So parameters like charset are not taken into account for comparison. Also Object.hashCode() must return a values that's computed as

 
 return type().toLower(Locale.ENGLISH).hashCode()*31 + subType.toLower(Locale.ENGLISH).hashCode();
 
 
  • Method Details

    • type

      String type()
      Returns the content type in the form <maintype>/<subtype>.
      Returns:
      The content type.
    • mainType

      String mainType()
      Returns the main type.
      Returns:
      The main type.
    • subType

      String subType()
      Returns the sub-type of this content type.
      Returns:
      The sub-type.
    • charset

      String charset(String defaultCharset)
      Returns the value of the charset parameter of this content type.
      Parameters:
      defaultCharset - The charset to return if no charset parameter is present.
      Returns:
      The charset of defaultCharset