|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object eu.medsea.mimeutil.detector.MimeDetector eu.medsea.mimeutil.detector.OpendesktopMimeDetector
public class OpendesktopMimeDetector
The Opendesktop shared mime database contains glob rules and magic number lookup information to enable applications to detect the mime types of files.
This class uses the mime.cache file which is one of the files created by the update-mime-database application. This file is a memory mapped file that enables the database to be updated and copied without interrupting applications.
This implementation follows the memory mapped spec so it is not required to restart an application using this mime detector should the underlying mime.cache database change.
For a complete description of the information contained in this file please see: http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info- spec-latest.html
This class also follows, where possible, the RECOMENDED order of detection as detailed in this spec. Thanks go to Mathias Clasen at Red Hat for pointing me to the original xdgmime implementation http://svn.gnome.org/viewvc/glib/trunk/ gio/xdgmime/xdgmimecache.c?revision=7784&view=markup
Constructor Summary | |
---|---|
OpendesktopMimeDetector()
|
|
OpendesktopMimeDetector(String mimeCacheFile)
|
Method Summary | |
---|---|
void |
delete()
You can override this method if for instance you allocated any resources in the init() method that need to be closed or deallocated specially. |
String |
dump()
|
String |
getDescription()
Abstract method to be implement by concrete MimeDetector(s). |
Collection |
getMimeTypesByteArray(byte[] data)
This method is unable to perform glob matching as no name is available. |
Collection |
getMimeTypesFile(File file)
This method resolves mime types closely in accordance with the RECOMENDED order of detection detailed in the Opendesktop shared mime database specification http://standards.freedesktop.org/shared-mime-info-spec/shared -mime-info-spec-latest.html See the Recommended checking order. |
Collection |
getMimeTypesFileName(String fileName)
This method resolves mime types closely in accordance with the RECOMENDED order of detection detailed in the Opendesktop shared mime database specification http://standards.freedesktop.org/shared-mime-info-spec/shared -mime-info-spec-latest.html See the Recommended checking order. |
Collection |
getMimeTypesInputStream(InputStream in)
This method is unable to perform glob matching as no name is available. |
Collection |
getMimeTypesURL(URL url)
This method resolves mime types closely in accordance with the RECOMENDED order of detection detailed in the Opendesktop shared mime database specification http://standards.freedesktop.org/shared-mime-info-spec/shared -mime-info-spec-latest.html See the Recommended checking order. |
Methods inherited from class eu.medsea.mimeutil.detector.MimeDetector |
---|
closeStream, getMimeTypes, getMimeTypes, getMimeTypes, getMimeTypes, getMimeTypes, getName, init |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public OpendesktopMimeDetector(String mimeCacheFile)
public OpendesktopMimeDetector()
Method Detail |
---|
public void delete()
MimeDetector
delete
in class MimeDetector
public String getDescription()
MimeDetector
getDescription
in class MimeDetector
public Collection getMimeTypesFileName(String fileName)
getMimeTypesFileName
in class MimeDetector
public Collection getMimeTypesURL(URL url)
getMimeTypesURL
in class MimeDetector
public Collection getMimeTypesFile(File file) throws UnsupportedOperationException
getMimeTypesFile
in class MimeDetector
UnsupportedOperationException
public Collection getMimeTypesInputStream(InputStream in) throws UnsupportedOperationException
getMimeTypesInputStream
in class MimeDetector
in
- InputStream.
UnsupportedOperationException
public Collection getMimeTypesByteArray(byte[] data) throws UnsupportedOperationException
getMimeTypesByteArray
in class MimeDetector
data
- byte []. Is a byte array that you want to parse for matching mime types.
UnsupportedOperationException
public String dump()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |