org.ws4d.java.types
Class InternetMediaType

java.lang.Object
  extended by org.ws4d.java.types.InternetMediaType

public class InternetMediaType
extends java.lang.Object

Kind of MIME-Type like described at RFC 1590.


Constructor Summary
InternetMediaType(java.lang.String mediaType)
          Create a new media type object from the information given.
InternetMediaType(java.lang.String type, java.lang.String subtype)
          Creates a new media type object from given types.
InternetMediaType(java.lang.String type, java.lang.String subtype, java.lang.String[] parameterKeys, java.lang.String[] parameterValues)
          Creates a new media type object from given types.
InternetMediaType(java.lang.String type, java.lang.String subtype, java.lang.String parameterKey, java.lang.String parameterValue)
          Creates a new media type object from given types.
 
Method Summary
static InternetMediaType cloneAndAddParameter(InternetMediaType original, java.lang.String parameterKey, java.lang.String parameterValue)
          Clones an InternetMediaType instance and adds the passed parameter to the original ones.
static InternetMediaType cloneAndAddParameters(InternetMediaType original, java.lang.String[] parameterKeys, java.lang.String[] parameterValues)
          Clones an InternetMediaType instance and adds the passed parameters to the original ones.
static InternetMediaType cloneAndSetParameter(InternetMediaType original, java.lang.String parameterKey, java.lang.String parameterValue)
          Clones an InternetMediaType instance and replaces the original parameters with the passed one.
static InternetMediaType cloneAndSetParameters(InternetMediaType original, java.lang.String[] parameterKeys, java.lang.String[] parameterValues)
          Clones an InternetMediaType instance and replaces the original parameters with the passed ones.
 boolean equals(java.lang.Object obj)
           
static InternetMediaType getApplicationOctetStream()
          Returns the application/octet-stream type.
static InternetMediaType getApplicationXOPXML()
          Returns the application/xop+xml type.
static InternetMediaType getApplicationXWWWFormUrlEncoded()
          Returns the application/x-www-form-urlencoded type.
static InternetMediaType getImageJPEG()
          Returns the image/jpeg type.
 java.lang.String getMediaType()
          Returns the complete media type.
static InternetMediaType getMultipartFormdata()
          Returns the multipart/form-data type.
static InternetMediaType getMultipartRelated()
          Returns the multipart/related type.
 java.lang.String getParameter(java.lang.String attributeName)
          Returns the value of a given attribute.
static InternetMediaType getSOAPXML()
          Returns the application/soap+xml type.
 java.lang.String getSubtype()
          Returns the subtype.
static InternetMediaType getTextHTML()
          Returns the text/html type.
static InternetMediaType getTextPlain()
          Returns the text/plain type.
 java.lang.String getType()
          Returns the main type.
static InternetMediaType getXML()
          Returns the application/xml type.
 int hashCode()
           
 boolean hasMainType(java.lang.String type)
          Checks whether this media type has the given main type.
 boolean hasParameter(java.lang.String attributeName)
          Checks whether this parameter exists.
 boolean hasSubType(java.lang.String subtype)
          Checks whether this media type has the given sub type.
 boolean hasType(java.lang.String type, java.lang.String subtype)
          Checks whether this media type has the given type.
 java.lang.String toString()
          Returns a string representation of this media type.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InternetMediaType

public InternetMediaType(java.lang.String type,
                         java.lang.String subtype)
Creates a new media type object from given types.

Parameters:
type - media type.
subtype - media sub type.

InternetMediaType

public InternetMediaType(java.lang.String type,
                         java.lang.String subtype,
                         java.lang.String[] parameterKeys,
                         java.lang.String[] parameterValues)
Creates a new media type object from given types. If parameterKeys is not null parameterValues has also not to be null and has to have the same size.

Parameters:
type - media type.
subtype - media sub type.
parameterKeys - key array for parameters.
parameterValues - value array for parameters.

InternetMediaType

public InternetMediaType(java.lang.String type,
                         java.lang.String subtype,
                         java.lang.String parameterKey,
                         java.lang.String parameterValue)
Creates a new media type object from given types. If parameterKeys is not null parameterValues has also not to be null and has to have the same size.

Parameters:
type - media type.
subtype - media sub type.
parameterKey - key of the parameter.
parameterValue - value of the parameter.

InternetMediaType

public InternetMediaType(java.lang.String mediaType)
Create a new media type object from the information given.

Parameters:
mediaType - the string describing the media type.
Method Detail

getSOAPXML

public static final InternetMediaType getSOAPXML()
Returns the application/soap+xml type.

Returns:
the application/soap+xml type.

getXML

public static final InternetMediaType getXML()
Returns the application/xml type.

Returns:
the application/xml type.

getApplicationOctetStream

public static final InternetMediaType getApplicationOctetStream()
Returns the application/octet-stream type.

Returns:
the application/octet-stream type.

getApplicationXOPXML

public static final InternetMediaType getApplicationXOPXML()
Returns the application/xop+xml type.

Returns:
the application/xop+xml type.

getMultipartRelated

public static final InternetMediaType getMultipartRelated()
Returns the multipart/related type.

Returns:
the multipart/related type.

getMultipartFormdata

public static final InternetMediaType getMultipartFormdata()
Returns the multipart/form-data type.

Returns:
the multipart/form-data type.

getApplicationXWWWFormUrlEncoded

public static final InternetMediaType getApplicationXWWWFormUrlEncoded()
Returns the application/x-www-form-urlencoded type.

Returns:
the application/x-www-form-urlencoded type.

getImageJPEG

public static final InternetMediaType getImageJPEG()
Returns the image/jpeg type.

Returns:
the image/jpeg type.

getTextHTML

public static final InternetMediaType getTextHTML()
Returns the text/html type.

Returns:
the text/html type.

getTextPlain

public static final InternetMediaType getTextPlain()
Returns the text/plain type.

Returns:
the text/plain type.

cloneAndSetParameters

public static InternetMediaType cloneAndSetParameters(InternetMediaType original,
                                                      java.lang.String[] parameterKeys,
                                                      java.lang.String[] parameterValues)
Clones an InternetMediaType instance and replaces the original parameters with the passed ones.

Parameters:
original - InternetMediaType instance to clone.
parameterKeys - key array for parameters.
parameterValues - value array for parameters.
Returns:

cloneAndSetParameter

public static InternetMediaType cloneAndSetParameter(InternetMediaType original,
                                                     java.lang.String parameterKey,
                                                     java.lang.String parameterValue)
Clones an InternetMediaType instance and replaces the original parameters with the passed one.

Parameters:
original - InternetMediaType instance to clone.
parameterKey - key of the parameter.
parameterValue - value of the parameters.
Returns:

cloneAndAddParameters

public static InternetMediaType cloneAndAddParameters(InternetMediaType original,
                                                      java.lang.String[] parameterKeys,
                                                      java.lang.String[] parameterValues)
Clones an InternetMediaType instance and adds the passed parameters to the original ones.

Parameters:
original - InternetMediaType instance to clone.
parameterKeys - key array for parameters to add.
parameterValues - value array for parameters to add.
Returns:

cloneAndAddParameter

public static InternetMediaType cloneAndAddParameter(InternetMediaType original,
                                                     java.lang.String parameterKey,
                                                     java.lang.String parameterValue)
Clones an InternetMediaType instance and adds the passed parameter to the original ones.

Parameters:
original - InternetMediaType instance to clone.
parameterKey - key of the parameter to add.
parameterValue - value of the parameter to add.
Returns:

getMediaType

public java.lang.String getMediaType()
Returns the complete media type.

Returns:
the media type, e.g.\ "application/xml" for media type "application/xml"

getType

public java.lang.String getType()
Returns the main type.

Returns:
the main type, e.g.\ application for media type "application/xml"

getSubtype

public java.lang.String getSubtype()
Returns the subtype.

Returns:
the subtype, e.g.\ xml for media type "application/xml".

hasType

public boolean hasType(java.lang.String type,
                       java.lang.String subtype)
Checks whether this media type has the given type.

Parameters:
type - the main type to check against. Case insensitive.
subtype - the subtype to check against. Case insensitive.
Returns:
true if the object has the given type, false otherwise.

hasMainType

public boolean hasMainType(java.lang.String type)
Checks whether this media type has the given main type.

Parameters:
type - the main type to check against. Case insensitive.
Returns:
true if the object has the given type, false otherwise.

hasSubType

public boolean hasSubType(java.lang.String subtype)
Checks whether this media type has the given sub type.

Parameters:
subtype - the sub type to check against. Case insensitive.
Returns:
true if the object has the given type, false otherwise.

getParameter

public java.lang.String getParameter(java.lang.String attributeName)
Returns the value of a given attribute.

Parameters:
attributeName - the name of the attribute to get the value of. Case insensitive.
Returns:
the value of a given attribute.

hasParameter

public boolean hasParameter(java.lang.String attributeName)
Checks whether this parameter exists.

Parameters:
attributeName - the parameter to check for.
Returns:
true if the object has the given parameter, false otherwise.

toString

public java.lang.String toString()
Returns a string representation of this media type.

Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object