org.apache.sling.commons.mime.internal
Class MimeTypeServiceImpl
java.lang.Object
org.apache.sling.commons.mime.internal.MimeTypeServiceImpl
- All Implemented Interfaces:
- EventListener, MimeTypeService, org.osgi.framework.BundleListener
public class MimeTypeServiceImpl
- extends Object
- implements MimeTypeService, org.osgi.framework.BundleListener
The MimeTypeServiceImpl
is the official implementation of the
MimeTypeService
interface.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CORE_MIME_TYPES
public static final String CORE_MIME_TYPES
- See Also:
- Constant Field Values
MIME_TYPES
public static final String MIME_TYPES
- See Also:
- Constant Field Values
MimeTypeServiceImpl
public MimeTypeServiceImpl()
getMimeType
public String getMimeType(String name)
- Description copied from interface:
MimeTypeService
- Returns the MIME type of the extension of the given
name
.
The extension is the part of the name after the last dot. If the name
does not contain a dot, the name as a whole is assumed to be the
extension.
- Specified by:
getMimeType
in interface MimeTypeService
- Parameters:
name
- The name for which the MIME type is to be returned.
- Returns:
- The MIME type for the extension of the name. If the extension
cannot be mapped to a MIME type or
name
is
null
, null
is returned. - See Also:
MimeTypeService.getExtension(String)
getExtension
public String getExtension(String mimeType)
- Description copied from interface:
MimeTypeService
- Returns the primary name extension to which the given
mimeType
maps. The returned extension must map to the
given mimeType
when fed to the
MimeTypeService.getMimeType(String)
method. In other words, the expression
mimeType.equals(getMimeType(getExtension(mimeType)))
must
always be true
for any non-null
MIME type.
A MIME type may be mapped to multiple extensions (e.g.
text/plain
to txt
, log
,
...). This method is expected to returned one of those extensions. It is
up to the implementation to select an appropriate extension if multiple
mappings exist for a single MIME type.
- Specified by:
getExtension
in interface MimeTypeService
- Parameters:
mimeType
- The MIME type whose primary extension is requested.
- Returns:
- A extension which maps to the given MIME type or
null
if no such mapping exists. - See Also:
MimeTypeService.getMimeType(String)
registerMimeType
public void registerMimeType(String mimeType,
String... extensions)
- Specified by:
registerMimeType
in interface MimeTypeService
registerMimeType
public void registerMimeType(InputStream mimeTabStream)
throws IOException
- Specified by:
registerMimeType
in interface MimeTypeService
- Throws:
IOException
activate
protected void activate(org.osgi.service.component.ComponentContext context)
deactivate
protected void deactivate(org.osgi.service.component.ComponentContext context)
bindMimeTypeProvider
protected void bindMimeTypeProvider(MimeTypeProvider mimeTypeProvider)
unbindMimeTypeProvider
protected void unbindMimeTypeProvider(MimeTypeProvider mimeTypeProvider)
bundleChanged
public void bundleChanged(org.osgi.framework.BundleEvent event)
- Specified by:
bundleChanged
in interface org.osgi.framework.BundleListener
Copyright © 2007-2013 The Apache Software Foundation. All Rights Reserved.