3261N/A * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A /** Keyed by content type, returns MimeEntries */ 0N/A /** Keyed by file extension (with the .), returns MimeEntries */ 0N/A // Will be reset if in the platform-specific data file 0N/A * Get the single instance of this class. First use will load the 0N/A * table from a data file. 0N/A // try a wildcard lookup 0N/A * Locate a MimeEntry by the file extension that has been associated 0N/A * with it. Parses general file names, and URLs. 0N/A // REMIND: OS specific delimters appear here 0N/A * Locate a MimeEntry by the file extension that has been associated 0N/A // We failed, now try treating description as type 0N/A // For backward compatibility -- mailcap format files 0N/A // This is not currently used, but may in the future when we add ability 0N/A // to read BOTH the properties format and the mailcap format. 0N/A // First try to load the user-specific table, if it exists 0N/A // No user-table, try to load the default built-in table. 0N/A // No user table, try to load the default built-in table. 0N/A // first, strip out the platform-specific temp file template 0N/A // now, parse the mime-type spec's 0N/A // <entry> ::= <table_tag> | <type_entry> 0N/A // <table_tag> ::= <table_format_version> | <temp_file_template> 0N/A // <type_entry> ::= <type_subtype_pair> '=' <type_attrs_list> 0N/A // <type_subtype_pair> ::= <type> '/' <subtype> 0N/A // <type_attrs_list> ::= <attr_value_pair> [ ';' <attr_value_pair> ]* 0N/A // | [ <attr_value_pair> ]+ 0N/A // <attr_value_pair> ::= <attr_name> '=' <attr_value> 0N/A // <attr_name> ::= 'description' | 'action' | 'application' 0N/A // | 'file_extensions' | 'icon' 0N/A // <attr_value> ::= <legal_char>* 0N/A // Embedded ';' in an <attr_value> are quoted with leading '\' . 0N/A // Interpretation of <attr_value> depends on the <attr_name> it is 0N/A // REMIND handle embedded ';' and '|' and literal '"' 0N/A // REMIND add exception handling... 0N/A // else illegal name exception 0N/A for (
int i =
0; i < n; i++) {
0N/A * Debugging utilities 0N/A public void list(PrintStream out) { 0N/A Enumeration keys = entries.keys(); 0N/A while (keys.hasMoreElements()) { 0N/A String key = (String)keys.nextElement(); 0N/A MimeEntry entry = (MimeEntry)entries.get(key); 0N/A out.println(key + ": " + entry); 0N/A public static void main(String[] args) { 0N/A MimeTable testTable = MimeTable.getDefaultTable(); 0N/A Enumeration e = testTable.elements(); 0N/A while (e.hasMoreElements()) { 0N/A MimeEntry entry = (MimeEntry)e.nextElement(); 0N/A System.out.println(entry); 0N/A testTable.save(File.separator + "tmp" + 0N/A File.separator + "mime_table.save");