libjava/ChangeLog:
[official-gcc.git] / libjava / classpath / javax / activation / CommandMap.java
blobfd749612a3021dbae74248f9fa5704346dfffdde
1 /* CommandMap.java -- Registry of available command objects.
2 Copyright (C) 2004, 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
38 package javax.activation;
40 /**
41 * Registry of command objects available to the system.
43 * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
44 * @version 1.1
46 public abstract class CommandMap
49 /* Class scope */
51 private static CommandMap defaultCommandMap;
53 /**
54 * Returns the default command map.
55 * This returns a MailcapCommandMap if no value has been set using
56 * <code>setDefaultCommandMap</code>.
58 public static CommandMap getDefaultCommandMap()
60 if (defaultCommandMap == null)
62 defaultCommandMap = new MailcapCommandMap();
64 return defaultCommandMap;
67 /**
68 * Sets the default command map.
69 * @param commandMap the new default command map
71 public static void setDefaultCommandMap(CommandMap commandMap)
73 SecurityManager security = System.getSecurityManager();
74 if (security != null)
76 try
78 security.checkSetFactory();
80 catch (SecurityException e)
82 if (commandMap != null && CommandMap.class.getClassLoader() !=
83 commandMap.getClass().getClassLoader())
85 throw e;
89 defaultCommandMap = commandMap;
92 /* Instance scope */
94 /**
95 * Returns the list of preferred commands for a MIME type.
96 * @param mimeType the MIME type
98 public abstract CommandInfo[] getPreferredCommands(String mimeType);
101 * Returns the complete list of commands for a MIME type.
102 * @param mimeType the MIME type
104 public abstract CommandInfo[] getAllCommands(String mimeType);
107 * Returns the command corresponding to the specified MIME type and
108 * command name.
109 * @param mimeType the MIME type
110 * @param cmdName the command name
112 public abstract CommandInfo getCommand(String mimeType, String cmdName);
115 * Returns a DataContentHandler corresponding to the MIME type.
116 * @param mimeType the MIME type
118 public abstract DataContentHandler createDataContentHandler(String mimeType);
121 * Get all the MIME types known to this command map.
122 * If the command map doesn't support this operation, null is returned.
123 * @return array of MIME types as strings, or null if not supported
124 * @since JAF 1.1
126 public String[] getMimeTypes()
128 return null;
132 * Get the preferred command list from a MIME Type. The actual semantics
133 * are determined by the implementation of the CommandMap.
134 * <p>
135 * The <code>DataSource</code> provides extra information, such as
136 * the file name, that a CommandMap implementation may use to further
137 * refine the list of commands that are returned. The implementation
138 * in this class simply calls the <code>getPreferredCommands</code>
139 * method that ignores this argument.
140 * @param mimeType the MIME type
141 * @param ds a DataSource for the data
142 * @return the CommandInfo classes that represent the command Beans.
143 * @since JAF 1.1
145 public CommandInfo[] getPreferredCommands(String mimeType,
146 DataSource ds)
148 return getPreferredCommands(mimeType);
152 * Get all the available commands for this type. This method
153 * should return all the possible commands for this MIME type.
154 * <p>
155 * The <code>DataSource</code> provides extra information, such as
156 * the file name, that a CommandMap implementation may use to further
157 * refine the list of commands that are returned. The implementation
158 * in this class simply calls the <code>getAllCommands</code>
159 * method that ignores this argument.
160 * @param mimeType the MIME type
161 * @param ds a DataSource for the data
162 * @return the CommandInfo objects representing all the commands.
163 * @since JAF 1.1
165 public CommandInfo[] getAllCommands(String mimeType, DataSource ds)
167 return getAllCommands(mimeType);
171 * Get the default command corresponding to the MIME type.
172 * <p>
173 * The <code>DataSource</code> provides extra information, such as
174 * the file name, that a CommandMap implementation may use to further
175 * refine the command that is chosen. The implementation
176 * in this class simply calls the <code>getCommand</code>
177 * method that ignores this argument.
178 * @param mimeType the MIME type
179 * @param cmdName the command name
180 * @param ds a DataSource for the data
181 * @return the CommandInfo corresponding to the command.
182 * @since JAF 1.1
184 public CommandInfo getCommand(String mimeType, String cmdName,
185 DataSource ds)
187 return getCommand(mimeType, cmdName);
191 * Locate a DataContentHandler that corresponds to the MIME type.
192 * The mechanism and semantics for determining this are determined
193 * by the implementation of the particular CommandMap.
194 * <p>
195 * The <code>DataSource</code> provides extra information, such as
196 * the file name, that a CommandMap implementation may use to further
197 * refine the choice of DataContentHandler. The implementation
198 * in this class simply calls the <code>createDataContentHandler</code>
199 * method that ignores this argument.
200 * @param mimeType the MIME type
201 * @param ds a DataSource for the data
202 * @return the DataContentHandler for the MIME type
203 * @since JAF 1.1
205 public DataContentHandler createDataContentHandler(String mimeType,
206 DataSource ds)
208 return createDataContentHandler(mimeType);