Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright © 2008 BEA Systems, Inc. All Rights Reserved
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bea.p13n.util
Class MimeTypeHelper

    java.lang.Object
      com.bea.p13n.util.MimeTypeHelper

    public class MimeTypeHelper

extends Object

Utility class to help with Mime Types.

This provides support for determining the MIME type based upon a file path/extension, and determining the extensions for a MIME type.

Upon load, this class will attempt to load in the "mime.types" in the same package as it (as a resource via getResource()). If that fails, an error will be thrown. The "mime.types" file should be of the standard Apache group format and provides information on most public mime types.

Since:
  2.0

Nested Class Summary
`static class` | `MimeTypeHelper.ContentType` The data representation of a MIME 1.0 Content Type.

Method Summary
`static List` | `getExtensions(String mimeType)` Get the list of extensions for the given mime type.
`static String` | `getFileExtension(String path)` Get the last most extension from a file path.
`static String` | `getMajor(String mimeType)` Get the major portion of a mime type.
`static String` | `getMimeType(File file)` Get the mime type for the specified file.
`static String` | `getMimeType(String ext)` Get the mime type for the specified extension.
`static String` | `getMimeTypeFromPath(String path)` Get the mime type for the specified file path.
`static String` | `getMinor(String mimeType)` Get the minor portion of a mime type.
`static MimeTypeHelper.ContentType` | `parseContentType(String str)` Parse a MIME 1.0 Content-Type string into a data structure.
`static List` | `split(String str, String seps)` Split a string on a separator and return it as a list.
`static void` | `splitInto(String str, String seps, List l)` Split a string on a separator into the given list

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### getExtensions

    public static List getExtensions(String mimeType)

  Get the list of extensions for the given mime type.

  Parameters
    `mimeType` - the mime type.
  Returns
    the list on success, null on unknown mime type (empty list if no associated mime types).

### getMimeType

    public static String getMimeType(String ext)

  Get the mime type for the specified extension.

  Parameters
    `ext` - the file extensions (no . included).
  Returns
    the mime type, or null if unknown.

### getMimeTypeFromPath

    public static String getMimeTypeFromPath(String path)

  Get the mime type for the specified file path.

  Parameters
    `path` - the file path.
  Returns
    the mime type, or null if unknown.
  See Also
    `getMimeType(java.lang.String)`, `getFileExtension(java.lang.String)`

### getFileExtension

    public static String getFileExtension(String path)

  Get the last most extension from a file path.

  This can handle both UNIX and Win32 paths.

  Parameters
    `path` - the file path.
  Returns
    the extension (no . included), null if none.

### getMimeType

    public static String getMimeType(File file)

  Get the mime type for the specified file.

  Parameters
    `file` - the file.
  Returns
    the mime type, or null if unknown.
  See Also
    `getMimeTypeFromPath(java.lang.String)`

### parseContentType

    public static MimeTypeHelper.ContentType parseContentType(String str)

  Parse a MIME 1.0 Content-Type string into a data structure.

  See RFC 2045 for more details of the structure of a MIME Content-Type string.

  Parameters
    `str` - the content type string.
  Returns
    the ContentType object, or null if invalid str.

### getMajor

    public static String getMajor(String mimeType)

  Get the major portion of a mime type.

  Parameters
    `mimeType` - the mime type.
  Returns
    the major (first) part of the mime type, null on invalid mime type.

### getMinor

    public static String getMinor(String mimeType)

  Get the minor portion of a mime type.

  Parameters
    `mimeType` - the mime type.
  Returns
    the major (first) part of the mime type, null on invalid mime

### split

    public static List split(String str,
                             String seps)

  Split a string on a separator and return it as a list.

  Parameters
    `str` - the string to split.
    `seps` - the separators (as per StringTokenizer).
  Returns
    list of elements.

### splitInto

    public static void splitInto(String str,
                                 String seps,
                                 List l)

  Split a string on a separator into the given list

  Parameters
    `str` - the string to split.
    `seps` - the separators (as per StringTokenizer).
    `l` - the list.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008 BEA Systems, Inc. All Rights Reserved