Class MediaType

    • Constructor Detail

      • MediaType

        public MediaType()
        Constructs a */* media type.
      • MediaType

        public MediaType​(String type)
        Constructs a type/* media type.
        Parameters:
        type - the type (may be null for a wild card)
      • MediaType

        public MediaType​(String type,
                         String subtype)
        Constructs a type/subtype media type.
        Parameters:
        type - the type (may be null for a wild card)
        subtype - the subtype (may be null for a wild card)
      • MediaType

        public MediaType​(String type,
                         String subtype,
                         String parameter,
                         String parameterValue)
        Constructs a type/subtype;parameter="name" media type.
        Parameters:
        type - the type (may be null for a wild card)
        subtype - the subtype (may be null for a wild card)
        parameter - the parameter
        parameterValue - the parameter value
      • MediaType

        public MediaType​(String type,
                         String subtype,
                         Map<String,​? extends Collection<String>> parameters)
        Constructs a media type using the supplied parameters.
        Parameters:
        type - the type (may be null for a wild card)
        subtype - the subtype (may be null for a wild card)
        parameters - the parameter map
    • Method Detail

      • getType

        public String getType()
      • getSubtype

        public String getSubtype()
      • isWildcard

        public boolean isWildcard()
      • isWildcardType

        public boolean isWildcardType()
      • isWildcardSubtype

        public boolean isWildcardSubtype()
      • isCompatible

        public boolean isCompatible​(MediaType other)
      • hasParameter

        public boolean hasParameter​(String parameter)
      • getQuality

        public float getQuality()
      • hasParameters

        public boolean hasParameters()
      • withoutParameter

        public MediaType withoutParameter​(String parameter)
      • withoutQuality

        public MediaType withoutQuality()
      • withoutParameters

        public MediaType withoutParameters()
      • hashCode

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

        public int getSimilarity​(MediaType other)
        Description copied from interface: Similar
         x = 0         ⇔ equal
         x < 0         ⇔ not similar
         x > 0         ⇔ similar
         y > 0 & x > y ⇔ x more similar than y
         
        Specified by:
        getSimilarity in interface Similar<MediaType>
        Parameters:
        other - the other object
        Returns:
        the similarity value
      • normalizeString

        public static String normalizeString​(String string)
        Normalize mime type string by processing it through the MediaType parser. Handles differing spaces between type and subtype, etc.
        Parameters:
        string - Mime type string to normalize
        Returns:
        Normalized mime type string
      • anyApplication

        public static MediaType anyApplication()
      • anyText

        public static MediaType anyText()
      • anyImage

        public static MediaType anyImage()
      • anyAudio

        public static MediaType anyAudio()
      • anyVideo

        public static MediaType anyVideo()
      • anyMessage

        public static MediaType anyMessage()
      • anyModel

        public static MediaType anyModel()
      • anyMultipart

        public static MediaType anyMultipart()