Package org.apache.axiom.mime
Class MediaType
java.lang.Object
org.apache.axiom.mime.MediaType
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)
and Object.hashCode()
to allow comparing media types as described by RFC 2045, i.e. in a case insensitive way.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final MediaType
The media type forapplication/octet-stream
.static final MediaType
The media type forapplication/soap+xml
.static final MediaType
The media type forapplication/xml
.static final MediaType
The media type forapplication/xop+xml
.static final MediaType
The media type formultipart/related
.static final MediaType
The media type fortext/plain
.static final MediaType
The media type fortext/xml
. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Get the primary type.Get the subtype.int
hashCode()
boolean
hasPrimaryType
(String type) Check if this media type has the given primary type.boolean
hasSubType
(String type) Check if this media type has the given sub type.boolean
isXML()
Check if this media type describes XML content as defined in RFC 7303.toString()
-
Field Details
-
TEXT_XML
The media type fortext/xml
. -
APPLICATION_XML
The media type forapplication/xml
. -
APPLICATION_SOAP_XML
The media type forapplication/soap+xml
. -
APPLICATION_XOP_XML
The media type forapplication/xop+xml
. -
MULTIPART_RELATED
The media type formultipart/related
. -
APPLICATION_OCTET_STREAM
The media type forapplication/octet-stream
. -
TEXT_PLAIN
The media type fortext/plain
.
-
-
Constructor Details
-
MediaType
Constructor.- Parameters:
primaryType
- the primary typesubType
- the subtype
-
MediaType
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 Details
-
getPrimaryType
Get the primary type.- Returns:
- the primary type
-
getSubType
Get the subtype.- Returns:
- the subtype
-
hasPrimaryType
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
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
-
hashCode
public int hashCode() -
equals
-
toString
-