org.exoplatform.common.util
Class MediaType

java.lang.Object
  extended by org.exoplatform.common.util.MediaType

public class MediaType
extends java.lang.Object

Created by The eXo Platform SAS Author : eXoPlatform exo@exoplatform.com Jun 25, 2010


Field Summary
static java.lang.String MEDIA_TYPE_WILDCARD
          Wildcard type.
static java.lang.String WILDCARD
           
 
Constructor Summary
MediaType(java.lang.String mediaType)
          Creates an instance of specified mediatype.
MediaType(java.lang.String type, java.lang.String subtype)
          Creates an instance of mediatype with specified type and subtype.
 
Method Summary
 java.lang.String getSubtype()
           
 java.lang.String getType()
           
 boolean isCompatible(MediaType other)
          Check if this media type is compatible with another media type.
 void setSubtype(java.lang.String subtype)
           
 void setType(java.lang.String type)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MEDIA_TYPE_WILDCARD

public static final java.lang.String MEDIA_TYPE_WILDCARD
Wildcard type.

See Also:
Constant Field Values

WILDCARD

public static final java.lang.String WILDCARD
See Also:
Constant Field Values
Constructor Detail

MediaType

public MediaType(java.lang.String mediaType)
Creates an instance of specified mediatype.

Parameters:
mediaType - mediatype, f.e.: text/plain

MediaType

public MediaType(java.lang.String type,
                 java.lang.String subtype)
Creates an instance of mediatype with specified type and subtype.

Parameters:
type - main type f.e. 'text' in 'text/xml'.
subtype - subtype f.e. 'xmk' in 'text/xml'.
Method Detail

getType

public java.lang.String getType()

setType

public void setType(java.lang.String type)

getSubtype

public java.lang.String getSubtype()

setSubtype

public void setSubtype(java.lang.String subtype)

isCompatible

public boolean isCompatible(MediaType other)
Check if this media type is compatible with another media type. E.g. image/* is compatible with image/jpeg, image/png, etc. Media type parameters are ignored. The function is commutative.

Parameters:
other - the media type to compare with
Returns:
true if the types are compatible, false otherwise.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2010 eXo Platform SAS. All Rights Reserved.