jaxws/src/share/classes/javax/activation/DataContentHandler.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
import java.awt.datatransfer.DataFlavor;
474761f14bca Initial load
duke
parents:
diff changeset
    29
import java.awt.datatransfer.UnsupportedFlavorException;
474761f14bca Initial load
duke
parents:
diff changeset
    30
import java.io.InputStream;
474761f14bca Initial load
duke
parents:
diff changeset
    31
import java.io.IOException;
474761f14bca Initial load
duke
parents:
diff changeset
    32
import java.io.OutputStream;
474761f14bca Initial load
duke
parents:
diff changeset
    33
import javax.activation.DataSource;
474761f14bca Initial load
duke
parents:
diff changeset
    34
474761f14bca Initial load
duke
parents:
diff changeset
    35
/**
474761f14bca Initial load
duke
parents:
diff changeset
    36
 * The DataContentHandler interface is implemented by objects that can
474761f14bca Initial load
duke
parents:
diff changeset
    37
 * be used to extend the capabilities of the DataHandler's implementation
474761f14bca Initial load
duke
parents:
diff changeset
    38
 * of the Transferable interface. Through <code>DataContentHandlers</code>
474761f14bca Initial load
duke
parents:
diff changeset
    39
 * the framework can be extended to convert streams in to objects, and
474761f14bca Initial load
duke
parents:
diff changeset
    40
 * to write objects to streams. <p>
474761f14bca Initial load
duke
parents:
diff changeset
    41
 *
474761f14bca Initial load
duke
parents:
diff changeset
    42
 * Applications don't generally call the methods in DataContentHandlers
474761f14bca Initial load
duke
parents:
diff changeset
    43
 * directly. Instead, an application calls the equivalent methods in
474761f14bca Initial load
duke
parents:
diff changeset
    44
 * DataHandler. The DataHandler will attempt to find an appropriate
474761f14bca Initial load
duke
parents:
diff changeset
    45
 * DataContentHandler that corresponds to its MIME type using the
474761f14bca Initial load
duke
parents:
diff changeset
    46
 * current DataContentHandlerFactory. The DataHandler then calls
474761f14bca Initial load
duke
parents:
diff changeset
    47
 * through to the methods in the DataContentHandler.
474761f14bca Initial load
duke
parents:
diff changeset
    48
 *
474761f14bca Initial load
duke
parents:
diff changeset
    49
 * @since 1.6
474761f14bca Initial load
duke
parents:
diff changeset
    50
 */
474761f14bca Initial load
duke
parents:
diff changeset
    51
474761f14bca Initial load
duke
parents:
diff changeset
    52
public interface DataContentHandler {
474761f14bca Initial load
duke
parents:
diff changeset
    53
    /**
474761f14bca Initial load
duke
parents:
diff changeset
    54
     * Returns an array of DataFlavor objects indicating the flavors the
474761f14bca Initial load
duke
parents:
diff changeset
    55
     * data can be provided in. The array should be ordered according to
474761f14bca Initial load
duke
parents:
diff changeset
    56
     * preference for providing the data (from most richly descriptive to
474761f14bca Initial load
duke
parents:
diff changeset
    57
     * least descriptive).
474761f14bca Initial load
duke
parents:
diff changeset
    58
     *
474761f14bca Initial load
duke
parents:
diff changeset
    59
     * @return The DataFlavors.
474761f14bca Initial load
duke
parents:
diff changeset
    60
     */
474761f14bca Initial load
duke
parents:
diff changeset
    61
    public DataFlavor[] getTransferDataFlavors();
474761f14bca Initial load
duke
parents:
diff changeset
    62
474761f14bca Initial load
duke
parents:
diff changeset
    63
    /**
474761f14bca Initial load
duke
parents:
diff changeset
    64
     * Returns an object which represents the data to be transferred.
474761f14bca Initial load
duke
parents:
diff changeset
    65
     * The class of the object returned is defined by the representation class
474761f14bca Initial load
duke
parents:
diff changeset
    66
     * of the flavor.
474761f14bca Initial load
duke
parents:
diff changeset
    67
     *
474761f14bca Initial load
duke
parents:
diff changeset
    68
     * @param df The DataFlavor representing the requested type.
474761f14bca Initial load
duke
parents:
diff changeset
    69
     * @param ds The DataSource representing the data to be converted.
474761f14bca Initial load
duke
parents:
diff changeset
    70
     * @return The constructed Object.
474761f14bca Initial load
duke
parents:
diff changeset
    71
     * @exception UnsupportedFlavorException    if the handler doesn't
474761f14bca Initial load
duke
parents:
diff changeset
    72
     *                                          support the requested flavor
474761f14bca Initial load
duke
parents:
diff changeset
    73
     * @exception IOException   if the data can't be accessed
474761f14bca Initial load
duke
parents:
diff changeset
    74
     */
474761f14bca Initial load
duke
parents:
diff changeset
    75
    public Object getTransferData(DataFlavor df, DataSource ds)
474761f14bca Initial load
duke
parents:
diff changeset
    76
                                throws UnsupportedFlavorException, IOException;
474761f14bca Initial load
duke
parents:
diff changeset
    77
474761f14bca Initial load
duke
parents:
diff changeset
    78
    /**
474761f14bca Initial load
duke
parents:
diff changeset
    79
     * Return an object representing the data in its most preferred form.
474761f14bca Initial load
duke
parents:
diff changeset
    80
     * Generally this will be the form described by the first DataFlavor
474761f14bca Initial load
duke
parents:
diff changeset
    81
     * returned by the <code>getTransferDataFlavors</code> method.
474761f14bca Initial load
duke
parents:
diff changeset
    82
     *
474761f14bca Initial load
duke
parents:
diff changeset
    83
     * @param ds The DataSource representing the data to be converted.
474761f14bca Initial load
duke
parents:
diff changeset
    84
     * @return The constructed Object.
474761f14bca Initial load
duke
parents:
diff changeset
    85
     * @exception IOException   if the data can't be accessed
474761f14bca Initial load
duke
parents:
diff changeset
    86
     */
474761f14bca Initial load
duke
parents:
diff changeset
    87
    public Object getContent(DataSource ds) throws IOException;
474761f14bca Initial load
duke
parents:
diff changeset
    88
474761f14bca Initial load
duke
parents:
diff changeset
    89
    /**
474761f14bca Initial load
duke
parents:
diff changeset
    90
     * Convert the object to a byte stream of the specified MIME type
474761f14bca Initial load
duke
parents:
diff changeset
    91
     * and write it to the output stream.
474761f14bca Initial load
duke
parents:
diff changeset
    92
     *
474761f14bca Initial load
duke
parents:
diff changeset
    93
     * @param obj       The object to be converted.
474761f14bca Initial load
duke
parents:
diff changeset
    94
     * @param mimeType  The requested MIME type of the resulting byte stream.
474761f14bca Initial load
duke
parents:
diff changeset
    95
     * @param os        The output stream into which to write the converted
474761f14bca Initial load
duke
parents:
diff changeset
    96
     *                  byte stream.
474761f14bca Initial load
duke
parents:
diff changeset
    97
     * @exception IOException   errors writing to the stream
474761f14bca Initial load
duke
parents:
diff changeset
    98
     */
474761f14bca Initial load
duke
parents:
diff changeset
    99
    public void writeTo(Object obj, String mimeType, OutputStream os)
474761f14bca Initial load
duke
parents:
diff changeset
   100
                                                       throws IOException;
474761f14bca Initial load
duke
parents:
diff changeset
   101
}