X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Futil%2Fmime%2FDefaultMIMETypes.java;h=9e380a5b8d86042b1755f02785c3b55637f9a0de;hb=bbfa208695e2a7f1bb555f841623945767f296e7;hp=c821912992a45c59c46c7e75ec5864b46e3c2f35;hpb=da127cd41fa65b7ec217f8e9f525ed7534abf5e1;p=jSite.git diff --git a/src/de/todesbaum/util/mime/DefaultMIMETypes.java b/src/de/todesbaum/util/mime/DefaultMIMETypes.java index c821912..9e380a5 100644 --- a/src/de/todesbaum/util/mime/DefaultMIMETypes.java +++ b/src/de/todesbaum/util/mime/DefaultMIMETypes.java @@ -1,4 +1,4 @@ -/* taken from freenet (http://www.freenetproject.org/) */ +/* taken from freenet (http://www.freenetproject.org/) */ package de.todesbaum.util.mime; import java.util.HashMap; @@ -10,23 +10,23 @@ import java.util.Vector; * Holds the default MIME types. */ public class DefaultMIMETypes { - + /** Default MIME type - what to set it to if we don't know any better */ public static final String DEFAULT_MIME_TYPE = "application/octet-stream"; - + /** MIME types: number -> name */ private static List mimeTypesByNumber = new Vector(); - + /** MIME types: name -> number */ private static Map mimeTypesByName = new HashMap(); - + /** MIME types by extension. One extension maps to one MIME type, but not necessarily * the other way around. */ private static Map mimeTypesByExtension = new HashMap(); - + /** Primary extension by MIME type number. */ private static Map primaryExtensionByMimeNumber = new HashMap(); - + /** * Add a MIME type, without any extensions. * @param number The number of the MIME type for compression. This *must not change* @@ -73,7 +73,7 @@ public class DefaultMIMETypes { } if(outExtension != null) primaryExtensionByMimeNumber.put(t, outExtension); - + } /** @@ -91,7 +91,7 @@ public class DefaultMIMETypes { protected static synchronized void addMIMEType(short number, String type, String extensions, String outExtension) { addMIMEType(number, type, extensions.split(" "), outExtension); } - + /** * Get a known MIME type by number. */ @@ -100,7 +100,7 @@ public class DefaultMIMETypes { return null; return mimeTypesByNumber.get(x); } - + /** * Get the number of a MIME type, or -1 if it is not in the table of known MIME * types, in which case it will have to be sent uncompressed. @@ -110,13 +110,13 @@ public class DefaultMIMETypes { if(x != null) return x.shortValue(); return -1; } - + /* From toad's /etc/mime.types - * cat /etc/mime.types | sed "/^$/d;/#/d" | tr --squeeze '\t' ' ' | - * (y=0; while read x; do echo "$x" | + * cat /etc/mime.types | sed "/^$/d;/#/d" | tr --squeeze '\t' ' ' | + * (y=0; while read x; do echo "$x" | * sed -n "s/^\([^ ]*\)$/addMIMEType\($y, \"\1\"\);/p;s/^\([^ (),]\+\) \(.*\)$/addMIMEType\($y, \"\1\", \"\2\"\);/p;"; y=$((y+1)); done) */ - + static { addMIMEType((short) 0, "application/activemessage"); addMIMEType((short) 1, "application/andrew-inset", "ez"); @@ -807,7 +807,7 @@ public class DefaultMIMETypes { addMIMEType((short) 686, "x-conference/x-cooltalk", "ice"); addMIMEType((short) 687, "x-world/x-vrml", "vrm vrml wrl"); } - + /** Guess a MIME type from a filename */ public static String guessMIMEType(String arg) { int x = arg.lastIndexOf('.'); @@ -826,7 +826,7 @@ public class DefaultMIMETypes { if(typeNumber < 0) return null; return primaryExtensionByMimeNumber.get(typeNumber); } - + public static String[] getAllMIMETypes() { return mimeTypesByNumber.toArray(new String[mimeTypesByNumber.size()]); }