Package org.apache.axiom.mime
Class MediaType
- java.lang.Object
-
- org.apache.axiom.mime.MediaType
-
public final class MediaType extends Object
Represents a media type as defined by RFC 2045 and RFC 2046. It specifies a primary type (e.g.text) and a subtype (e.g.xml). Note that in RFC 2045, "media type" refers to what is called "primary type" here, while this class uses "media type" to refer to the combination of primary and subtype.This class is immutable. It overrides
Object.equals(Object)andObject.hashCode()to allow comparing media types as described by RFC 2045, i.e. in a case insensitive way.
-
-
Field Summary
Fields Modifier and Type Field Description static MediaTypeAPPLICATION_OCTET_STREAMThe media type forapplication/octet-stream.static MediaTypeAPPLICATION_SOAP_XMLThe media type forapplication/soap+xml.static MediaTypeAPPLICATION_XMLThe media type forapplication/xml.static MediaTypeAPPLICATION_XOP_XMLThe media type forapplication/xop+xml.static MediaTypeMULTIPART_RELATEDThe media type formultipart/related.static MediaTypeTEXT_PLAINThe media type fortext/plain.static MediaTypeTEXT_XMLThe media type fortext/xml.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)StringgetPrimaryType()Get the primary type.StringgetSubType()Get the subtype.inthashCode()booleanhasPrimaryType(String type)Check if this media type has the given primary type.booleanhasSubType(String type)Check if this media type has the given sub type.booleanisXML()Check if this media type describes XML content as defined in RFC 7303.StringtoString()
-
-
-
Field Detail
-
TEXT_XML
public static final MediaType TEXT_XML
The media type fortext/xml.
-
APPLICATION_XML
public static final MediaType APPLICATION_XML
The media type forapplication/xml.
-
APPLICATION_SOAP_XML
public static final MediaType APPLICATION_SOAP_XML
The media type forapplication/soap+xml.
-
APPLICATION_XOP_XML
public static final MediaType APPLICATION_XOP_XML
The media type forapplication/xop+xml.
-
MULTIPART_RELATED
public static final MediaType MULTIPART_RELATED
The media type formultipart/related.
-
APPLICATION_OCTET_STREAM
public static final MediaType APPLICATION_OCTET_STREAM
The media type forapplication/octet-stream.
-
TEXT_PLAIN
public static final MediaType TEXT_PLAIN
The media type fortext/plain.
-
-
Constructor Detail
-
MediaType
public MediaType(String primaryType, String subType)
Constructor.- Parameters:
primaryType- the primary typesubType- the subtype
-
MediaType
public MediaType(String type) throws ParseException
Constructor that parses a media type.- Parameters:
type- the media type to parse- Throws:
ParseException- if the value is invalid and could not be parsed
-
-
Method Detail
-
getPrimaryType
public String getPrimaryType()
Get the primary type.- Returns:
- the primary type
-
getSubType
public String getSubType()
Get the subtype.- Returns:
- the subtype
-
hasPrimaryType
public boolean hasPrimaryType(String type)
Check if this media type has the given primary type.- Parameters:
type- the primary type to check against- Returns:
- whether the primary type matches
-
hasSubType
public boolean hasSubType(String type)
Check if this media type has the given sub type.- Parameters:
type- the sub type to check against- Returns:
- whether the sub type matches
-
isXML
public boolean isXML()
Check if this media type describes XML content as defined in RFC 7303.- Returns:
- whether the content expected for this media type is XML
-
-