Class ContentType

java.lang.Object
uk.ac.starlink.auth.ContentType

public class ContentType extends Object
Simple abstraction of MIME type. This class represents the basic MIME type/subtype, but does not attempt to represent content-type parameters.

This class is a stripped-down version of uk.ac.starlink.util.ContentType.

Since:
20 May 2021
Author:
Mark Taylor
See Also:
  • Constructor Details

    • ContentType

      public ContentType(String type, String subtype)
      Constructs a ContentType from type and subtype strings. Case is normalised (to lower case).
      Parameters:
      type - type part
      subtype - subtype part
  • Method Details

    • getType

      public String getType()
      Returns the Type part of this content type.
      Returns:
      type
    • getSubtype

      public String getSubtype()
      Returns the Subtype part of this content type.
      Returns:
      subtype
    • matches

      public boolean matches(String type, String subtype)
      Indicates whether the type and subtype match a given pair.
      Parameters:
      type - required type part (case-insensitive)
      subtype - required subtype part (case-insensitive)
      Returns:
      true iff type and subtype match those of this content-type
    • hashCode

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

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • toString

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

      public static ContentType parse(String txt)
      Parses a Content-Type (MIME type) string.
      Parameters:
      txt - text representation of MIME type
      Returns:
      ContentType instance if syntax matches, else null