diff options
author | Anthony Green <green@gcc.gnu.org> | 2000-02-21 05:54:29 +0000 |
---|---|---|
committer | Anthony Green <green@gcc.gnu.org> | 2000-02-21 05:54:29 +0000 |
commit | 06440a12a2aba035710fe478b88f6224d77b5815 (patch) | |
tree | 5348c0d2f6947295be47163fd566b9b5264a8749 /libjava/gnu | |
parent | 38b3a2c089296350450e5dc0db2c279529fa6909 (diff) | |
download | gcc-06440a12a2aba035710fe478b88f6224d77b5815.zip gcc-06440a12a2aba035710fe478b88f6224d77b5815.tar.gz gcc-06440a12a2aba035710fe478b88f6224d77b5815.tar.bz2 |
Makefile.in: Rebuilt.
* Makefile.in: Rebuilt.
* Makefile.am (ordinary_java_source_files): Add
gnu/gcj/io/DefaultMimeTypes.java and gnu/gcj/io/MimeTypes.java
* scripts/MakeDefaultMimeTypes.java: New file.
* scripts/mime.types: New file.
* scripts/classes.pl: Moved from top level.
* classes.pl: Moved to scripts directory.
* java/net/URLConnection.java: Implement guessContentTypeFromName.
* gnu/gcj/io/MimeTypes.java: New file.
* gnu/gcj/io/DefaultMimeTypes.java: New file.
From-SVN: r32086
Diffstat (limited to 'libjava/gnu')
-rw-r--r-- | libjava/gnu/gcj/io/DefaultMimeTypes.java | 139 | ||||
-rw-r--r-- | libjava/gnu/gcj/io/MimeTypes.java | 86 |
2 files changed, 225 insertions, 0 deletions
diff --git a/libjava/gnu/gcj/io/DefaultMimeTypes.java b/libjava/gnu/gcj/io/DefaultMimeTypes.java new file mode 100644 index 0000000..e25fe88 --- /dev/null +++ b/libjava/gnu/gcj/io/DefaultMimeTypes.java @@ -0,0 +1,139 @@ +// Do not edit this file! Create a new version with MakeDefaultMimeTypes. + +/* Copyright (C) 2000 Red Hat, Inc. + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.gcj.io; + +public class DefaultMimeTypes +{ + public static final String[] types = { + "midi", "audio/midi" + , "sit", "application/x-stuffit" + , "ram", "audio/x-pn-realaudio" + , "ez", "application/andrew-inset" + , "jpeg", "image/jpeg" + , "sv4crc", "application/x-sv4crc" + , "sv4cpio", "application/x-sv4cpio" + , "txt", "text/plain" + , "spl", "application/x-futuresplash" + , "ras", "image/x-cmu-raster" + , "sh", "application/x-sh" + , "dcr", "application/x-director" + , "msh", "model/mesh" + , "swf", "application/x-shockwave-flash" + , "hdf", "application/x-hdf" + , "bcpio", "application/x-bcpio" + , "zip", "application/zip" + , "gif", "image/gif" + , "me", "application/x-troff-me" + , "gtar", "application/x-gtar" + , "tex", "application/x-tex" + , "xyz", "chemical/x-pdb" + , "hqx", "application/mac-binhex40" + , "ms", "application/x-troff-ms" + , "oda", "application/oda" + , "vcd", "application/x-cdlink" + , "aifc", "audio/x-aiff" + , "skd", "application/x-koan" + , "smil", "application/smil" + , "asc", "text/plain" + , "aiff", "audio/x-aiff" + , "xml", "text/xml" + , "tr", "application/x-troff" + , "nc", "application/x-netcdf" + , "dxr", "application/x-director" + , "skm", "application/x-koan" + , "wrl", "model/vrml" + , "tsv", "text/tab-separated-values" + , "mpeg", "video/mpeg" + , "skp", "application/x-koan" + , "src", "application/x-wais-source" + , "rpm", "application/x-rpm" + , "skt", "application/x-koan" + , "ai", "application/postscript" + , "cpt", "application/mac-compactpro" + , "mp2", "audio/mpeg" + , "man", "application/x-troff-man" + , "mp3", "audio/mpeg" + , "mesh", "model/mesh" + , "igs", "model/iges" + , "shar", "application/x-shar" + , "au", "audio/basic" + , "texi", "application/x-texinfo" + , "cpio", "application/x-cpio" + , "jpe", "image/jpeg" + , "lzh", "application/octet-stream" + , "jpg", "image/jpeg" + , "cdf", "application/x-netcdf" + , "etx", "text/x-setext" + , "texinfo", "application/x-texinfo" + , "sgml", "text/sgml" + , "roff", "application/x-troff" + , "pgm", "image/x-portable-graymap" + , "pgn", "application/x-chess-pgn" + , "bin", "application/octet-stream" + , "png", "image/png" + , "tar", "application/x-tar" + , "mid", "audio/midi" + , "mov", "video/quicktime" + , "movie", "video/x-sgi-movie" + , "mif", "application/vnd.mif" + , "pnm", "image/x-portable-anymap" + , "mpga", "audio/mpeg" + , "smi", "application/smil" + , "t", "application/x-troff" + , "tiff", "image/tiff" + , "xbm", "image/x-xbitmap" + , "htm", "text/html" + , "mpe", "video/mpeg" + , "dms", "application/octet-stream" + , "mpg", "video/mpeg" + , "lha", "application/octet-stream" + , "latex", "application/x-latex" + , "ps", "application/postscript" + , "sgm", "text/sgml" + , "tif", "image/tiff" + , "ice", "x-conference/x-cooltalk" + , "snd", "audio/basic" + , "html", "text/html" + , "pbm", "image/x-portable-bitmap" + , "xpm", "image/x-xpixmap" + , "iges", "model/iges" + , "aif", "audio/x-aiff" + , "avi", "video/x-msvideo" + , "csh", "application/x-csh" + , "wav", "audio/x-wav" + , "xwd", "image/x-xwindowdump" + , "js", "application/x-javascript" + , "silo", "model/mesh" + , "vrml", "model/vrml" + , "tcl", "application/x-tcl" + , "css", "text/css" + , "eps", "application/postscript" + , "class", "application/octet-stream" + , "qt", "video/quicktime" + , "doc", "application/msword" + , "ustar", "application/x-ustar" + , "ppm", "image/x-portable-pixmap" + , "ppt", "application/vnd.ms-powerpoint" + , "ra", "audio/x-realaudio" + , "rgb", "image/x-rgb" + , "rtf", "text/rtf" + , "kar", "audio/midi" + , "dvi", "application/x-dvi" + , "rm", "audio/x-pn-realaudio" + , "exe", "application/octet-stream" + , "pdb", "chemical/x-pdb" + , "pdf", "application/pdf" + , "rtx", "text/richtext" + , "dir", "application/x-director" + , "ief", "image/ief" + }; +} + diff --git a/libjava/gnu/gcj/io/MimeTypes.java b/libjava/gnu/gcj/io/MimeTypes.java new file mode 100644 index 0000000..36d3eb8 --- /dev/null +++ b/libjava/gnu/gcj/io/MimeTypes.java @@ -0,0 +1,86 @@ +/* Copyright (C) 2000 Red Hat, Inc. + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.gcj.io; + +import java.util.*; +import java.io.*; + +public class MimeTypes +{ + private static Hashtable mime_types; + + public static void fillFromFile (Hashtable table, String fname) + throws IOException + { + LineNumberReader reader = + new LineNumberReader (new FileReader (fname)); + + while (reader.ready ()) + { + StringTokenizer tokenizer = + new StringTokenizer (reader.readLine ()); + + try + { + String t = tokenizer.nextToken (); + + if (! t.startsWith ("#")) + { + while (true) + { + // Read the next extension + String e = tokenizer.nextToken (); + if (! e.startsWith ("#")) + table.put (e, t); + else + break; + } + } + } catch (NoSuchElementException ex) { + // Do nothing. + } + } + } + + // This is the primary interface to this class. + public static String getMimeTypeFromExtension (String extension) + { + if (mime_types == null) + { + mime_types = new Hashtable (); + + // First populate the hash table with the default mime type + // mappings. + int i = DefaultMimeTypes.types.length; + while (i > 1) + { + mime_types.put (DefaultMimeTypes.types[i - 2], + DefaultMimeTypes.types[i - 1]); + i = i - 2; + } + + // Now read mime types from /etc/mime.types if it exists. + // This should override the default values. + try { + fillFromFile (mime_types, "/etc/mime.types"); + } catch (IOException ex) { + // Do nothing. + } + + // Now read mime types from ~/.mime.types. + // FIXME: We can't currently parse this file. + } + + String type = (String) mime_types.get (extension); + if (type == null) + return ("application/octet-stream"); + else + return (type); + } +} |