aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/utils/MimeUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/pixart/messenger/utils/MimeUtils.java')
-rw-r--r--src/main/java/de/pixart/messenger/utils/MimeUtils.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/utils/MimeUtils.java b/src/main/java/de/pixart/messenger/utils/MimeUtils.java
index f90822c2e..366ed308b 100644
--- a/src/main/java/de/pixart/messenger/utils/MimeUtils.java
+++ b/src/main/java/de/pixart/messenger/utils/MimeUtils.java
@@ -14,6 +14,7 @@
* limitations under the License.
*/
package de.pixart.messenger.utils;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -21,6 +22,7 @@ import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
+
/**
* Utilities for dealing with MIME types.
* Used to implement java.net.URLConnection and android.webkit.MimeTypeMap.
@@ -28,6 +30,7 @@ import java.util.Properties;
public final class MimeUtils {
private static final Map<String, String> mimeTypeToExtensionMap = new HashMap<String, String>();
private static final Map<String, String> extensionToMimeTypeMap = new HashMap<String, String>();
+
static {
// The following table is based on /etc/mime.types data minus
// chemical/* MIME types and MIME types that don't map to any
@@ -373,6 +376,7 @@ public final class MimeUtils {
add("x-epoc/x-sisx-app", "sisx");
applyOverrides();
}
+
private static void add(String mimeType, String extension) {
// If we have an existing x -> y mapping, we do not want to
// override it with another mapping x -> y2.
@@ -386,6 +390,7 @@ public final class MimeUtils {
extensionToMimeTypeMap.put(extension, mimeType);
}
}
+
private static InputStream getContentTypesPropertiesStream() {
// User override?
String userTable = System.getProperty("content.types.user.table");
@@ -408,6 +413,7 @@ public final class MimeUtils {
}
return null;
}
+
/**
* This isn't what the RI does. The RI doesn't have hard-coded defaults, so supplying your
* own "content.types.user.table" means you don't get any of the built-ins, and the built-ins
@@ -436,10 +442,13 @@ public final class MimeUtils {
} catch (IOException ignored) {
}
}
+
private MimeUtils() {
}
+
/**
* Returns true if the given MIME type has an entry in the map.
+ *
* @param mimeType A MIME type (i.e. text/plain)
* @return True iff there is a mimeType entry in the map.
*/
@@ -449,8 +458,10 @@ public final class MimeUtils {
}
return mimeTypeToExtensionMap.containsKey(mimeType);
}
+
/**
* Returns the MIME type for the given extension.
+ *
* @param extension A file extension without the leading '.'
* @return The MIME type for the given extension or null iff there is none.
*/
@@ -460,8 +471,10 @@ public final class MimeUtils {
}
return extensionToMimeTypeMap.get(extension.toLowerCase());
}
+
/**
* Returns true if the given extension has a registered MIME type.
+ *
* @param extension A file extension without the leading '.'
* @return True iff there is an extension entry in the map.
*/
@@ -471,10 +484,12 @@ public final class MimeUtils {
}
return extensionToMimeTypeMap.containsKey(extension);
}
+
/**
* Returns the registered extension for the given MIME type. Note that some
* MIME types map to multiple extensions. This call will return the most
* common extension for the given MIME type.
+ *
* @param mimeType A MIME type (i.e. text/plain)
* @return The extension for the given MIME type or null iff there is none.
*/