File Release Notes and Changelog
Notes:
/*
* Copyright 2007-2009 Medsea Business Solutions S.L.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
What is mime-util?
It's a very small lightweight extensible utility that allows Java programs to detect MIME types based on file extensions, globbing and magic data.
The API supports MIME type detection from java.io.File, java.io.InputStream, java.net.URL and byte arrays.
MimeDetector(s) provided algorithms for detecting MIME types using various sources such as, support for reading from the native magic files as used
by the Unix file(1) command when used on a Unix OS or internally supplied copies if running on a system that does not support the Unix file(1) command such as Windows.
For a full description of mime-util please visit the mime-util web site at http://ww.medsea.eu/mime-util.
This file contains important release notes for each version of mime-util.
Version 2.0 Released 01-06-2009
This is a major release for mime-util with some significant changes to the public API and the implementations of the MimeDetector(s).
If you are currently using versions prior to 2.0 we suggest you upgrade your project to use the latest 2.x version.
The 2.x public API has now been frozen and we will not be changing it for the foreseeable future unless absolutely necessary.
1. All depricated classes and methods from the 1.x version have now been removed.
2. New website for mime-util launched.
The new site is available at http://www.medsea.eu/mime-util and contains lots of detail regarding the workings of MimeDetector(s)
as well as examples and usage scenarios.
3. eu.medsea.mimeutil.TextMimeDetector.
New MimeDetector added for text content and encoding information
4. Added new utility class eu.medsea.util.EncodingGuesser. This is used by the TextMimeDetector but can be used as a stand alone
utility for you own needs.
5. Only the TextMimeDetector is now enabled by default so you need to be enabled any of the others specifically via your code.
See the Java Doc or the MimeDetector(s) page available on the web site via the Documentation link.
6. A new abstract method Collection getMimeTypesURL(URL url); has been added to the abstract class eu.medsea.detector.MimeDetector that
can be used in your MimeDetector(s) to detect MIME types from URL(s).
7. The getMimeTypes(URLConnection url) method has been removed from the public MimeUtil API as it was not well implemented and only
deferred execution to the InputStream versions of gtMimeTypes(...). For MimeDetector(s) that work with file names or extensions,
the delegation methods were insufficient. You should now use the new getMimeTypes(...) method that takes a URL instead.
8. The mime-util jar file is now also an OSGi bundle and can be use in OSGi containers such as Knopflerfish, Felix and Equinox.
9. The logging calls previously dependent on commons-logging have now been replaced with logging calls to SLF4J. This was done due
to several issues other people had raised in OSGi forums regarding the use of commons-logging. We cannot testify to commons-logging
problems as we migrated the logging before packaging mime-util as an OSGi bundle.
Version 1.3.1 Released 21-03-2009
This version is a bug fix release for version 1.3
1. eu.medsea.mimeutil.detector.ExtensionMimeDetector.
Muli-part extensions were not recognised correctly. The rule here was to general so it would use the longest extension mapping possible and was able
to identify .tar.gz files correctly as an extension but would also not identify files such as myjar-1.2.3.jar as it would use 2.3.jar as the extension.
The extension needed to be recursively parsed until either a match is found or there are no extension parts left to match.
2. eu.medsea.mimeutil.detector.MagicMimeMimeDetector.
a. The byte type matching rules for the magic.mime files did not work as the case condition fell through to the default clause setting the compare
buffer to null.
b. The masked type matching ignored the mask e.g
# This is not the best match for application/vnd.ibm.modcap but it should still work
0 string Z
>2 beshort&0x00FF 0xD3 application/vnd.ibm.modcap
The first line would match OK but the second level match for the beshort&0x00FF ignored the mask
and failed to match the content.
Version 1.3 Released 04-03-2009
This version represents a major refactoring of mime-util with many new features and a more flexible architecture.
It will be the last version released in the 1.x branch. Some of the classes such as the MimeHandler are currently
experimental and are not well documented. These classes are subject to major change when we release version 2.x
and will have their API's pretty well defined then.
1. Depricated the eu.medsea.util.MimeUtil and eu.medsea.util.MimeException classes
These classes are still available but will not be supported any more. Please modify
your code to use the new eu.medsea.mimeutil.MimeUtil and eu.medsea.mimeutil.MimeException classes instead
2. Added eu.medsea.mimeutil.MimeUtil to replace the depricated class
3. Added eu.medsea.mimeutil.MimeException to replace the depricated class
4. Added eu.medsea.mimeutil.MimeType class and eu.medsea.mimeutil.TextMimeType class to represent a mime types
5. Added eu.medsea.mimeutil.MimeTypeHashSet to represent a Collection of mime types
6. Added eu.medsea.mimeutil.detector.MimeDetect as an Abstract class to represent new plugable MimeDetector(s)
7. Added eu.medsea.mimeutil.detector.ExtensionMimeDetect for detecting mime types from file extensions
8. Added eu.medsea.mimeutil.detector.MagicMimeMimeDetector for detecting mime types from files, streams and URL,s
using magic number detection
9. Added eu.medsea.mimeutil.detector.OpendesktopMimeDetector for detecting mime types using the Opendesktop
Shared MIME database see - http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html
This class is disabled by default. To enable this and register it as a listener you can just create an instance of the
class eu.medsea.mimeutil.detector.OpendesktopMimeDetector and a static block in the class will automatically register it.
10. Added many new junit test cases to test the new methods and classes
11. Updated a lot of the java doc as well as the README.txt file
NOTE: The default MimeDetector(s) MagicMimeMimeDetector and ExtensionMimeDetector are enabled by default and will cover 99.9% of
use cases. If however, you are running on a Linux system that supports the OpenDesktop Shared MIME database you should probably
deregister the MagicMimeMimeDetector and the ExtensionMimeDetector and enable the OpendesktopMimeDetector. This is because there
is a considerable overlap with the other default MimeDetector(s) and you will have a more consistent result with other applications
running on the system.
There are no problems caused by having ALL of the MimeDetector(s) active at the same time, you will just get more mime types
returned from the MimeUtil.getMimeTypes(...) calls.
You can enable the OpendesktopMimeDetector by un-commenting the entry in the MimeDetectors file in the root of the jar file or
by just instanciating an instance of the class. If you are running this MimeDetector on a system that does not support the mime.cache file,
such as windows, you can extract it from the jar and place it in a directory called /usr/share/mime/mime.cache. This file cannot be used
directly from the jar file as it is used as a memory mapped file that must be located on the file system.
Version 1.2 Released 27-01-2009
1. This release has been restructured as a maven project
Version 1.1 Released 21-01-2009
1. Fixed all issues arising from version 1.0
2. Added extensive javadoc
3. Added many new features and methods
4. Improved the parsing of the unix file(1) magic.mime files
6. Extended the customisation features for both magic.mime files and file extension mappings
7. Improved the build process
8. Added many unit tests (these can be downloaded separately from the SVN repository)
9. Improved the README documentation
10. Improved the speed for identifying mime types
11. Added the ability to detect the mime type of a stream
We are now actively working on version 2.0 which will include many new features including:
Deployable as an OSGI bundle
Packaged as a maven 2 project
Plugins for Eclipse and Freedesktop
Plus may more new features....
Version 1.0 Released 07-09-2007
1. Initial implementation of the mime detection utility library
We hope you enjoy this project as much as we enjoy developing it, Please feel free to register any
feature requests or bugs on the SourceForge project site http://sourceforge.net/projects/mime-util/
Changes: