1 /** 2 * 3 * Copyright 2003-2004 The Apache Software Foundation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package javax.activation; 19 20 /** 21 * @version $Rev: 123383 $ $Date: 2004-12-26 19:11:00 -0800 (Sun, 26 Dec 2004) $ 22 */ 23 public abstract class CommandMap { 24 private static CommandMap defaultCommandMap = new MailcapCommandMap(); 25 26 /** 27 * Return the default CommandMap. If this has not been explictly set 28 * using setDefaultCommandMap() then a MailcapCommandMap is returned. 29 * @return the default CommandMap 30 */ 31 public static CommandMap getDefaultCommandMap() { 32 return defaultCommandMap; 33 } 34 35 /** 36 * Set the default CommandMap. 37 * 38 * @param commandMap the new default CommandMap; if null resets to a MailcapCommandMap 39 * @throws SecurityException if the caller does not have "SetFactory" RuntimePermission 40 */ 41 public static void setDefaultCommandMap(CommandMap commandMap) { 42 SecurityManager sm = System.getSecurityManager(); 43 if (sm != null) { 44 sm.checkSetFactory(); 45 } 46 defaultCommandMap = commandMap == null ? new MailcapCommandMap() : commandMap; 47 } 48 49 public CommandMap() { 50 } 51 52 public abstract CommandInfo[] getPreferredCommands(String mimeType); 53 54 public abstract CommandInfo[] getAllCommands(String mimeType); 55 56 public abstract CommandInfo getCommand(String mimeType, String cmdName); 57 58 public abstract DataContentHandler createDataContentHandler(String mimeType); 59 }