001    /**
002     *
003     * Copyright 2003-2004 The Apache Software Foundation
004     *
005     *  Licensed under the Apache License, Version 2.0 (the "License");
006     *  you may not use this file except in compliance with the License.
007     *  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    
018    package javax.activation;
019    
020    /**
021     * @version $Rev: 123383 $ $Date: 2004-12-26 19:11:00 -0800 (Sun, 26 Dec 2004) $
022     */
023    public abstract class CommandMap {
024        private static CommandMap defaultCommandMap = new MailcapCommandMap();
025    
026        /**
027         * Return the default CommandMap. If this has not been explictly set
028         * using setDefaultCommandMap() then a MailcapCommandMap is returned.
029         * @return the default CommandMap
030         */
031        public static CommandMap getDefaultCommandMap() {
032            return defaultCommandMap;
033        }
034    
035        /**
036         * Set the default CommandMap.
037         *
038         * @param commandMap the new default CommandMap; if null resets to a MailcapCommandMap 
039         * @throws SecurityException if the caller does not have "SetFactory" RuntimePermission
040         */
041        public static void setDefaultCommandMap(CommandMap commandMap) {
042            SecurityManager sm = System.getSecurityManager();
043            if (sm != null) {
044                sm.checkSetFactory();
045            }
046            defaultCommandMap = commandMap == null ? new MailcapCommandMap() : commandMap;
047        }
048    
049        public CommandMap() {
050        }
051    
052        public abstract CommandInfo[] getPreferredCommands(String mimeType);
053    
054        public abstract CommandInfo[] getAllCommands(String mimeType);
055    
056        public abstract CommandInfo getCommand(String mimeType, String cmdName);
057    
058        public abstract DataContentHandler createDataContentHandler(String mimeType);
059    }