Class MediaType

java.lang.Object
org.netpreserve.jwarc.MessageParser
org.netpreserve.jwarc.MediaType

public class MediaType extends MessageParser
  • Field Details

    • GEMINI

      public static final MediaType GEMINI
    • GEMTEXT

      public static final MediaType GEMTEXT
    • JSON

      public static final MediaType JSON
    • HTML

      public static MediaType HTML
    • HTML_UTF8

      public static MediaType HTML_UTF8
    • HTTP

      public static MediaType HTTP
    • HTTP_REQUEST

      public static MediaType HTTP_REQUEST
    • HTTP_RESPONSE

      public static MediaType HTTP_RESPONSE
    • OCTET_STREAM

      public static MediaType OCTET_STREAM
    • PLAIN_TEXT

      public static MediaType PLAIN_TEXT
    • WARC_FIELDS

      public static MediaType WARC_FIELDS
    • WWW_FORM_URLENCODED

      public static final MediaType WWW_FORM_URLENCODED
  • Method Details

    • parse

      public static MediaType parse(String string) throws IllegalArgumentException
      Parses a media type string strictly.
      Throws:
      IllegalArgumentException - if the string is not a valid media type
    • parseLeniently

      public static MediaType parseLeniently(String string)
      Parses a media type string leniently.

      This method is more permissive than parse(String) and will not throw an exception if the string is invalid. Instead, the returned media type will have isValid() return false. Invalid parameters will be ignored and will omitted from toString(). The method raw() can be used to return the original string.

    • raw

      public String raw()
      The original unparsed media type string.
    • type

      public String type()
    • subtype

      public String subtype()
    • parameters

      public Map<String,String> parameters()
    • isValid

      public boolean isValid()
    • equals

      public boolean equals(Object o)
      Two media types are considered equal if their type, subtype and parameter names are equal case-insensitively and if the parameter values are equal case-sensitively.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • base

      public MediaType base()
      The base type and subtype without any parameters.