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

## org.modeshape.graph.mimetype
Class ExtensionBasedMimeTypeDetector

    java.lang.Object
      org.modeshape.common.util.MimeTypeUtil
          org.modeshape.graph.mimetype.ExtensionBasedMimeTypeDetector

All Implemented Interfaces:
  MimeTypeDetector

    @Immutable
    public class ExtensionBasedMimeTypeDetector

extends MimeTypeUtil
implements MimeTypeDetector

A `MimeTypeDetector` that attempts to match the extension of the supplied name against a set of known file extensions.

Field Summary
`static MimeTypeDetectorConfig` | `CONFIGURATION` A default configuration that may be used to `add` the `ExtensionBasedMimeTypeDetector` to a `MimeTypeDetector` instance.

Fields inherited from class org.modeshape.common.util.MimeTypeUtil
`MIME_TYPE_EXTENSIONS_RESOURCE_PATH`

Constructor Summary
`ExtensionBasedMimeTypeDetector()` Create a default instance of the extension-based MIME type detector.
`ExtensionBasedMimeTypeDetector(Map<String,String> extensionsToMimeTypes)` Create an instance of the extension-based MIME type detector by using the supplied mappings.
`ExtensionBasedMimeTypeDetector(Map<String,String> extensionsToMimeTypes, boolean initWithDefaults)` Create an instance of the extension-based MIME type detector by using the supplied mappings.

Method Summary
`String` | `mimeTypeOf(String name, InputStream content)` Returns the MIME-type of a data source, using its supplied content and/or its supplied name, depending upon the implementation.

Methods inherited from class org.modeshape.common.util.MimeTypeUtil
`getDefaultMappings, load, mimeTypeOf, mimeTypeOf`

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

Field Detail

### CONFIGURATION

    public static final MimeTypeDetectorConfig CONFIGURATION

  A default configuration that may be used to `add` the `ExtensionBasedMimeTypeDetector` to a `MimeTypeDetector` instance.

Constructor Detail

### ExtensionBasedMimeTypeDetector

    public ExtensionBasedMimeTypeDetector()

  Create a default instance of the extension-based MIME type detector. The set of extension patterns to MIME-types is loaded from the "`org/modeshape/mime.types`" classpath resource.

### ExtensionBasedMimeTypeDetector

    public ExtensionBasedMimeTypeDetector(Map<String,String> extensionsToMimeTypes)

  Create an instance of the extension-based MIME type detector by using the supplied mappings. The set of extension patterns to MIME-types is loaded from the "`org/modeshape/mime.types`" classpath resource, but the supplied extension mappings override any default mappings.

  Parameters:
    `extensionsToMimeTypes` - the mapping of extension patterns to MIME types, which will override the default mappings; may be null if the default mappings are to be used

### ExtensionBasedMimeTypeDetector

    public ExtensionBasedMimeTypeDetector(Map<String,String> extensionsToMimeTypes,
                                          boolean initWithDefaults)

  Create an instance of the extension-based MIME type detector by using the supplied mappings. If requested, the set of extension patterns to MIME-types is loaded from the "org/modeshape/graph/mime.types" classpath resource and any supplied extension mappings override any default mappings.

  Parameters:
    `extensionsToMimeTypes` - the mapping of extension patterns to MIME types, which will override the default mappings; may be null if the default mappings are to be used
    `initWithDefaults` - true if the default mappings are to be loaded first

Method Detail

### mimeTypeOf

    public String mimeTypeOf(String name,
                             InputStream content)

  Returns the MIME-type of a data source, using its supplied content and/or its supplied name, depending upon the implementation. If the MIME-type cannot be determined, either a "default" MIME-type or `null` may be returned, where the former will prevent earlier registered MIME-type detectors from being consulted.

  Note that detector implementations should not `close` the supplied input stream.

  Specified by:
    `mimeTypeOf` in interface `MimeTypeDetector`
  Parameters:
    `name` - The name of the data source; may be `null`.
    `content` - The content of the data source; may be `null`.
  Returns:
    The MIME-type of the data source, or optionally `null` if the MIME-type could not be determined.
  See Also:
    `MimeTypeDetector.mimeTypeOf(java.lang.String, java.io.InputStream)`

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

Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.