src/share/jaf_classes/javax/activation/CommandMap.java

Tue, 06 Mar 2012 16:09:35 -0800

author
ohair
date
Tue, 06 Mar 2012 16:09:35 -0800
changeset 286
f50545b5e2f1
child 494
2fcd3ddb57a6
permissions
-rw-r--r--

7150322: Stop using drop source bundles in jaxws
Reviewed-by: darcy, ohrstrom

ohair@286 1 /*
ohair@286 2 * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
ohair@286 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ohair@286 4 *
ohair@286 5 * This code is free software; you can redistribute it and/or modify it
ohair@286 6 * under the terms of the GNU General Public License version 2 only, as
ohair@286 7 * published by the Free Software Foundation. Oracle designates this
ohair@286 8 * particular file as subject to the "Classpath" exception as provided
ohair@286 9 * by Oracle in the LICENSE file that accompanied this code.
ohair@286 10 *
ohair@286 11 * This code is distributed in the hope that it will be useful, but WITHOUT
ohair@286 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ohair@286 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ohair@286 14 * version 2 for more details (a copy is included in the LICENSE file that
ohair@286 15 * accompanied this code).
ohair@286 16 *
ohair@286 17 * You should have received a copy of the GNU General Public License version
ohair@286 18 * 2 along with this work; if not, write to the Free Software Foundation,
ohair@286 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ohair@286 20 *
ohair@286 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@286 22 * or visit www.oracle.com if you need additional information or have any
ohair@286 23 * questions.
ohair@286 24 */
ohair@286 25
ohair@286 26 package javax.activation;
ohair@286 27
ohair@286 28
ohair@286 29 /**
ohair@286 30 * The CommandMap class provides an interface to a registry of
ohair@286 31 * command objects available in the system.
ohair@286 32 * Developers are expected to either use the CommandMap
ohair@286 33 * implementation included with this package (MailcapCommandMap) or
ohair@286 34 * develop their own. Note that some of the methods in this class are
ohair@286 35 * abstract.
ohair@286 36 *
ohair@286 37 * @since 1.6
ohair@286 38 */
ohair@286 39 public abstract class CommandMap {
ohair@286 40 private static CommandMap defaultCommandMap = null;
ohair@286 41
ohair@286 42 /**
ohair@286 43 * Get the default CommandMap.
ohair@286 44 * <p>
ohair@286 45 *
ohair@286 46 * <ul>
ohair@286 47 * <li> In cases where a CommandMap instance has been previously set
ohair@286 48 * to some value (via <i>setDefaultCommandMap</i>)
ohair@286 49 * return the CommandMap.
ohair@286 50 * <li>
ohair@286 51 * In cases where no CommandMap has been set, the CommandMap
ohair@286 52 * creates an instance of <code>MailcapCommandMap</code> and
ohair@286 53 * set that to the default, returning its value.
ohair@286 54 *
ohair@286 55 * </ul>
ohair@286 56 *
ohair@286 57 * @return the CommandMap
ohair@286 58 */
ohair@286 59 public static CommandMap getDefaultCommandMap() {
ohair@286 60 if (defaultCommandMap == null)
ohair@286 61 defaultCommandMap = new MailcapCommandMap();
ohair@286 62
ohair@286 63 return defaultCommandMap;
ohair@286 64 }
ohair@286 65
ohair@286 66 /**
ohair@286 67 * Set the default CommandMap. Reset the CommandMap to the default by
ohair@286 68 * calling this method with <code>null</code>.
ohair@286 69 *
ohair@286 70 * @param commandMap The new default CommandMap.
ohair@286 71 * @exception SecurityException if the caller doesn't have permission
ohair@286 72 * to change the default
ohair@286 73 */
ohair@286 74 public static void setDefaultCommandMap(CommandMap commandMap) {
ohair@286 75 SecurityManager security = System.getSecurityManager();
ohair@286 76 if (security != null) {
ohair@286 77 try {
ohair@286 78 // if it's ok with the SecurityManager, it's ok with me...
ohair@286 79 security.checkSetFactory();
ohair@286 80 } catch (SecurityException ex) {
ohair@286 81 // otherwise, we also allow it if this code and the
ohair@286 82 // factory come from the same class loader (e.g.,
ohair@286 83 // the JAF classes were loaded with the applet classes).
ohair@286 84 if (CommandMap.class.getClassLoader() !=
ohair@286 85 commandMap.getClass().getClassLoader())
ohair@286 86 throw ex;
ohair@286 87 }
ohair@286 88 }
ohair@286 89 defaultCommandMap = commandMap;
ohair@286 90 }
ohair@286 91
ohair@286 92 /**
ohair@286 93 * Get the preferred command list from a MIME Type. The actual semantics
ohair@286 94 * are determined by the implementation of the CommandMap.
ohair@286 95 *
ohair@286 96 * @param mimeType the MIME type
ohair@286 97 * @return the CommandInfo classes that represent the command Beans.
ohair@286 98 */
ohair@286 99 abstract public CommandInfo[] getPreferredCommands(String mimeType);
ohair@286 100
ohair@286 101 /**
ohair@286 102 * Get the preferred command list from a MIME Type. The actual semantics
ohair@286 103 * are determined by the implementation of the CommandMap. <p>
ohair@286 104 *
ohair@286 105 * The <code>DataSource</code> provides extra information, such as
ohair@286 106 * the file name, that a CommandMap implementation may use to further
ohair@286 107 * refine the list of commands that are returned. The implementation
ohair@286 108 * in this class simply calls the <code>getPreferredCommands</code>
ohair@286 109 * method that ignores this argument.
ohair@286 110 *
ohair@286 111 * @param mimeType the MIME type
ohair@286 112 * @param ds a DataSource for the data
ohair@286 113 * @return the CommandInfo classes that represent the command Beans.
ohair@286 114 * @since JAF 1.1
ohair@286 115 */
ohair@286 116 public CommandInfo[] getPreferredCommands(String mimeType, DataSource ds) {
ohair@286 117 return getPreferredCommands(mimeType);
ohair@286 118 }
ohair@286 119
ohair@286 120 /**
ohair@286 121 * Get all the available commands for this type. This method
ohair@286 122 * should return all the possible commands for this MIME type.
ohair@286 123 *
ohair@286 124 * @param mimeType the MIME type
ohair@286 125 * @return the CommandInfo objects representing all the commands.
ohair@286 126 */
ohair@286 127 abstract public CommandInfo[] getAllCommands(String mimeType);
ohair@286 128
ohair@286 129 /**
ohair@286 130 * Get all the available commands for this type. This method
ohair@286 131 * should return all the possible commands for this MIME type. <p>
ohair@286 132 *
ohair@286 133 * The <code>DataSource</code> provides extra information, such as
ohair@286 134 * the file name, that a CommandMap implementation may use to further
ohair@286 135 * refine the list of commands that are returned. The implementation
ohair@286 136 * in this class simply calls the <code>getAllCommands</code>
ohair@286 137 * method that ignores this argument.
ohair@286 138 *
ohair@286 139 * @param mimeType the MIME type
ohair@286 140 * @param ds a DataSource for the data
ohair@286 141 * @return the CommandInfo objects representing all the commands.
ohair@286 142 * @since JAF 1.1
ohair@286 143 */
ohair@286 144 public CommandInfo[] getAllCommands(String mimeType, DataSource ds) {
ohair@286 145 return getAllCommands(mimeType);
ohair@286 146 }
ohair@286 147
ohair@286 148 /**
ohair@286 149 * Get the default command corresponding to the MIME type.
ohair@286 150 *
ohair@286 151 * @param mimeType the MIME type
ohair@286 152 * @param cmdName the command name
ohair@286 153 * @return the CommandInfo corresponding to the command.
ohair@286 154 */
ohair@286 155 abstract public CommandInfo getCommand(String mimeType, String cmdName);
ohair@286 156
ohair@286 157 /**
ohair@286 158 * Get the default command corresponding to the MIME type. <p>
ohair@286 159 *
ohair@286 160 * The <code>DataSource</code> provides extra information, such as
ohair@286 161 * the file name, that a CommandMap implementation may use to further
ohair@286 162 * refine the command that is chosen. The implementation
ohair@286 163 * in this class simply calls the <code>getCommand</code>
ohair@286 164 * method that ignores this argument.
ohair@286 165 *
ohair@286 166 * @param mimeType the MIME type
ohair@286 167 * @param cmdName the command name
ohair@286 168 * @param ds a DataSource for the data
ohair@286 169 * @return the CommandInfo corresponding to the command.
ohair@286 170 * @since JAF 1.1
ohair@286 171 */
ohair@286 172 public CommandInfo getCommand(String mimeType, String cmdName,
ohair@286 173 DataSource ds) {
ohair@286 174 return getCommand(mimeType, cmdName);
ohair@286 175 }
ohair@286 176
ohair@286 177 /**
ohair@286 178 * Locate a DataContentHandler that corresponds to the MIME type.
ohair@286 179 * The mechanism and semantics for determining this are determined
ohair@286 180 * by the implementation of the particular CommandMap.
ohair@286 181 *
ohair@286 182 * @param mimeType the MIME type
ohair@286 183 * @return the DataContentHandler for the MIME type
ohair@286 184 */
ohair@286 185 abstract public DataContentHandler createDataContentHandler(String
ohair@286 186 mimeType);
ohair@286 187
ohair@286 188 /**
ohair@286 189 * Locate a DataContentHandler that corresponds to the MIME type.
ohair@286 190 * The mechanism and semantics for determining this are determined
ohair@286 191 * by the implementation of the particular CommandMap. <p>
ohair@286 192 *
ohair@286 193 * The <code>DataSource</code> provides extra information, such as
ohair@286 194 * the file name, that a CommandMap implementation may use to further
ohair@286 195 * refine the choice of DataContentHandler. The implementation
ohair@286 196 * in this class simply calls the <code>createDataContentHandler</code>
ohair@286 197 * method that ignores this argument.
ohair@286 198 *
ohair@286 199 * @param mimeType the MIME type
ohair@286 200 * @param ds a DataSource for the data
ohair@286 201 * @return the DataContentHandler for the MIME type
ohair@286 202 * @since JAF 1.1
ohair@286 203 */
ohair@286 204 public DataContentHandler createDataContentHandler(String mimeType,
ohair@286 205 DataSource ds) {
ohair@286 206 return createDataContentHandler(mimeType);
ohair@286 207 }
ohair@286 208
ohair@286 209 /**
ohair@286 210 * Get all the MIME types known to this command map.
ohair@286 211 * If the command map doesn't support this operation,
ohair@286 212 * null is returned.
ohair@286 213 *
ohair@286 214 * @return array of MIME types as strings, or null if not supported
ohair@286 215 * @since JAF 1.1
ohair@286 216 */
ohair@286 217 public String[] getMimeTypes() {
ohair@286 218 return null;
ohair@286 219 }
ohair@286 220 }

mercurial