Package org.faceless.publisher.type
Class MediaType
java.lang.Object
org.faceless.publisher.type.MediaType
- All Implemented Interfaces:
Serializable
A simple class representing a Media-Type (aka Content-Type or MIME-Type).
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
getBase()
Return type/subtypegetParameter
(String key) Return the named parameter, or null if it doesn't existReturn a read-only map of the parametersReturn the subtype, or null for wildcardgetType()
Return the type, or null for wildcardint
hashCode()
boolean
Return true if either the type or subtype are undefinedboolean
Return true if neither the type nor subtype are definedboolean
Return true if the subtype is "xml", or ends in "+xml"boolean
Return true if this MediaType matches the specified type.boolean
Return true if this MediaType matches the specified type/subtype.boolean
Return true if this MediaType matches the specified type.newParameter
(String key, String value) Set the named parameter in a new copy of this object and return it.Return a new MediaType that is a clone of the current one with a new type/subtypestatic MediaType
Returns a Media-Type for this String, or null if it is not well-formed.static MediaType
Returns a Media-Type for this String, or null if it is not well-formed.toString()
-
Field Details
-
WILDCARD
The wildcard MediaType */*
-
-
Constructor Details
-
MediaType
Create a MediaType from the specified parameters- Parameters:
type
- the type, eg "image", or null for wildcardsubtype
- the subtype, eg "png", or null for wildcard
-
-
Method Details
-
parse
Returns a Media-Type for this String, or null if it is not well-formed. -
parse
Returns a Media-Type for this String, or null if it is not well-formed.- Parameters:
strict
- if false, do your best to return something even if its not strictly valid.
-
getType
Return the type, or null for wildcard -
getSubType
Return the subtype, or null for wildcard -
isWildcard
public boolean isWildcard()Return true if neither the type nor subtype are defined -
hasWildcard
public boolean hasWildcard()Return true if either the type or subtype are undefined -
isXMLBased
public boolean isXMLBased()Return true if the subtype is "xml", or ends in "+xml" -
matches
Return true if this MediaType matches the specified type. This type must not have wildcards to match; the specified type may have wildcards. -
matches
Return true if this MediaType matches the specified type/subtype. This type must not have wildcards to match; the specified type/subtype may have wildcards. -
matches
Return true if this MediaType matches the specified type. This type must not have wildcards to match; the specified type may have wildcards. -
getBase
Return type/subtype -
getParameter
Return the named parameter, or null if it doesn't exist -
newType
Return a new MediaType that is a clone of the current one with a new type/subtype -
newParameter
Set the named parameter in a new copy of this object and return it. If value is a string, use it. If value is an empty String, set it with no value (eg "base64"). If value is null, remove it -
getParameters
Return a read-only map of the parameters -
toString
-
hashCode
public int hashCode() -
equals
-