+ Introducing + FileObject.getMIMEType(String...) + that can be overriden by different implementations + of file system API. +
+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 @@