org.jboss.soa.esb.actions.soap.attachment
Class MimeUtils

java.lang.Object
  extended by org.jboss.soa.esb.actions.soap.attachment.MimeUtils

public class MimeUtils
extends java.lang.Object

Generic mime utility class.

Author:
Jason T. Greene

Nested Class Summary
static interface MimeUtils.ByteArrayConverter
           
static class MimeUtils.ImageConverter
           
static class MimeUtils.RealByteArrayConverter
           
static class MimeUtils.SourceConverter
           
static class MimeUtils.StreamConverter
           
static class MimeUtils.StringConverter
           
 
Constructor Summary
MimeUtils()
           
 
Method Summary
static javax.xml.namespace.QName convertMimeTypeToXmlType(java.lang.String mimeType)
          Converts a MIME type into a proprietary JBossWS attachment xml type.
static java.lang.String getBaseMimeType(java.lang.String mimeType)
          Gets the base portion of a MIME type string.
static MimeUtils.ByteArrayConverter getConverterForContentType(java.lang.String contentType)
           
static MimeUtils.ByteArrayConverter getConverterForJavaType(java.lang.Class targetClazz)
           
static boolean isMemberOf(java.lang.String mimeType, java.util.Set mimeTypes)
          Checks if there is a matching mime pattern for mimeType in mimeTypes.
static java.lang.Class resolveClass(java.lang.String mimeType)
          Resolve the class for a mype type.
static java.lang.String resolveMimeType(java.lang.Class clazz)
           
static java.lang.String resolveMimeType(java.lang.Object obj)
          Resolve the mime type for an object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MimeUtils

public MimeUtils()
Method Detail

convertMimeTypeToXmlType

public static javax.xml.namespace.QName convertMimeTypeToXmlType(java.lang.String mimeType)
Converts a MIME type into a proprietary JBossWS attachment xml type.

Parameters:
mimeType - the MIME type string to convert
Returns:
the xml type that this mime type corresponds to

getBaseMimeType

public static java.lang.String getBaseMimeType(java.lang.String mimeType)
Gets the base portion of a MIME type string. This basically just strips off any type parameter elements.

Parameters:
mimeType - any MIME type string
Returns:
a reduced MIME string containing no type parameters

isMemberOf

public static boolean isMemberOf(java.lang.String mimeType,
                                 java.util.Set mimeTypes)
Checks if there is a matching mime pattern for mimeType in mimeTypes. This will return true if there is an exact match (for example text/plain = text/plain), or if there is a wildcard subtype match (text/plain = text/*).

Parameters:
mimeType - the mime type to search for
mimeTypes - the set of mime types to search
Returns:
true if there is a match, false if not

resolveClass

public static java.lang.Class resolveClass(java.lang.String mimeType)
Resolve the class for a mype type. Defaults to DataHandler if no mapping could be found.


resolveMimeType

public static java.lang.String resolveMimeType(java.lang.Object obj)
Resolve the mime type for an object. Default to application/octet-stream if no mapping could be found.


resolveMimeType

public static java.lang.String resolveMimeType(java.lang.Class clazz)

getConverterForJavaType

public static MimeUtils.ByteArrayConverter getConverterForJavaType(java.lang.Class targetClazz)

getConverterForContentType

public static MimeUtils.ByteArrayConverter getConverterForContentType(java.lang.String contentType)