diff -r e9d8597d45a6 openide.filesystems/apichanges.xml --- a/openide.filesystems/apichanges.xml Thu Jul 28 10:17:56 2011 +0200 +++ b/openide.filesystems/apichanges.xml Thu Jul 28 11:10:10 2011 +0200 @@ -49,6 +49,24 @@ Filesystems API + + + FileObject.getMIMEType(String... withinMIMETypes) + + + + + +

+ Introducing + FileObject.getMIMEType(String...) + that can be overriden by different implementations + of file system API. +

+
+ + +
FileUtil.getConfigObject diff -r e9d8597d45a6 openide.filesystems/manifest.mf --- a/openide.filesystems/manifest.mf Thu Jul 28 10:17:56 2011 +0200 +++ b/openide.filesystems/manifest.mf Thu Jul 28 11:10:10 2011 +0200 @@ -2,5 +2,5 @@ OpenIDE-Module: org.openide.filesystems OpenIDE-Module-Localizing-Bundle: org/openide/filesystems/Bundle.properties OpenIDE-Module-Layer: org/openide/filesystems/resources/layer.xml -OpenIDE-Module-Specification-Version: 7.49 +OpenIDE-Module-Specification-Version: 7.50 diff -r e9d8597d45a6 openide.filesystems/src/org/openide/filesystems/FileObject.java --- a/openide.filesystems/src/org/openide/filesystems/FileObject.java Thu Jul 28 10:17:56 2011 +0200 +++ b/openide.filesystems/src/org/openide/filesystems/FileObject.java Thu Jul 28 11:10:10 2011 +0200 @@ -571,6 +571,23 @@ String mimeType = FileUtil.getMIMEType(this); return mimeType == null ? "content/unknown" : mimeType; //NOI18N } + + /** Resolves MIME type from the list of acceptable ones. By default + * calls {@link FileUtil#getMIMEType(org.openide.filesystems.FileObject, java.lang.String[])}, + * but subclasses may override this method to be more effective. + * + * @param withinMIMETypes + * A hint to the underlaying infrastructure to + * limit the search to given array of MIME types. + * @return the MIME type for the FileObject, or null if + * the FileObject is unrecognized. It may return {@code content/unknown} instead of {@code null}. + * It is possible for the resulting MIME type to not be a member of given withinMIMETypes + * list. + * @since 7.50 + */ + public String getMIMEType(String... withinMIMETypes) { + return FileUtil.getMIMEType(this, withinMIMETypes); + } /** Get the size of the file. * @return the size of the file in bytes or zero if the file does not contain data (does not diff -r e9d8597d45a6 openide.filesystems/test/unit/src/org/openide/filesystems/FileUtilTest.java --- a/openide.filesystems/test/unit/src/org/openide/filesystems/FileUtilTest.java Thu Jul 28 10:17:56 2011 +0200 +++ b/openide.filesystems/test/unit/src/org/openide/filesystems/FileUtilTest.java Thu Jul 28 11:10:10 2011 +0200 @@ -381,7 +381,7 @@ FileObject fo = FileUtil.createData(testFolder, "fo1.mime1"); String[] withinMIMETypes = null; try { - FileUtil.getMIMEType(fo, withinMIMETypes); + fo.getMIMEType(withinMIMETypes); fail("FileUtil.getMIMEType(fo, null) should throw IllegalArgumentException."); } catch (NullPointerException npe) { // exception correctly thrown @@ -389,7 +389,7 @@ fo = FileUtil.createData(testFolder, "fo2.mime1"); withinMIMETypes = new String[0]; - FileUtil.getMIMEType(fo, withinMIMETypes); + fo.getMIMEType(withinMIMETypes); assertTrue("Resolver should be queried if array of desired MIME types is empty.", MyResolver.wasQueried()); fo = FileUtil.createData(testFolder, "fo3.mime1"); @@ -404,7 +404,7 @@ fo = FileUtil.createData(testFolder, "fo5.mime1"); withinMIMETypes = new String[]{"mime1", "mime2"}; - FileUtil.getMIMEType(fo, withinMIMETypes); + fo.getMIMEType(withinMIMETypes); assertTrue("Resolver should be queried if both items in array of desired MIME types matches MIMEResolver.getMIMETypes.", MyResolver.wasQueried()); } diff -r e9d8597d45a6 openide.filesystems/test/unit/src/org/openide/filesystems/MIMESupportTest.java --- a/openide.filesystems/test/unit/src/org/openide/filesystems/MIMESupportTest.java Thu Jul 28 10:17:56 2011 +0200 +++ b/openide.filesystems/test/unit/src/org/openide/filesystems/MIMESupportTest.java Thu Jul 28 11:10:10 2011 +0200 @@ -396,7 +396,7 @@ assertEquals(3, Lookup.getDefault().lookupAll(MIMEResolver.class).size()); FileObject fo = FileUtil.createData(FileUtil.createMemoryFileSystem().getRoot(), "file.a"); - String mimeType = FileUtil.getMIMEType(fo, "b/b"); + String mimeType = fo.getMIMEType("b/b"); assertEquals("content/unknown", mimeType); mimeType = FileUtil.getMIMEType(fo, "a/a"); assertEquals("a/a", mimeType); @@ -407,7 +407,7 @@ //#161340 - do not cache text/xml if it is falback value FileObject fo1 = FileUtil.createData(FileUtil.createMemoryFileSystem().getRoot(), "file.xml"); - mimeType = FileUtil.getMIMEType(fo1, "a/a"); + mimeType = fo1.getMIMEType("a/a"); assertEquals("Fallback for xml failed.", "text/xml", mimeType); mimeType = FileUtil.getMIMEType(fo1); assertEquals("Fallback MIME type for xml should not be cached.", "xml/xml", mimeType); diff -r e9d8597d45a6 openide.loaders/nbproject/project.xml --- a/openide.loaders/nbproject/project.xml Thu Jul 28 10:17:56 2011 +0200 +++ b/openide.loaders/nbproject/project.xml Thu Jul 28 11:10:10 2011 +0200 @@ -122,7 +122,7 @@ - 7.19 + 7.50 diff -r e9d8597d45a6 openide.loaders/src/org/openide/loaders/ExtensionList.java --- a/openide.loaders/src/org/openide/loaders/ExtensionList.java Thu Jul 28 10:17:56 2011 +0200 +++ b/openide.loaders/src/org/openide/loaders/ExtensionList.java Thu Jul 28 11:10:10 2011 +0200 @@ -169,7 +169,7 @@ } if (mimeTypes != null) { - String mime = FileUtil.getMIMEType(fo, mimeTypes.toArray(new String[0])); + String mime = fo.getMIMEType(mimeTypes.toArray(new String[0])); if (mimeTypes.contains(mime)) { return true; }