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