jdk/src/java.desktop/share/classes/sun/datatransfer/DesktopDatatransferService.java
author ddehaven
Tue, 19 Aug 2014 10:32:16 -0700
changeset 26037 508779ce6619
parent 26010 jdk/src/share/classes/sun/datatransfer/DesktopDatatransferService.java@9a3cf8ee0776
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26010
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
     1
/*
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
     4
 *
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    10
 *
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    15
 * accompanied this code).
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    16
 *
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    20
 *
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    23
 * questions.
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    24
 */
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    25
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    26
package sun.datatransfer;
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    27
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    28
import java.awt.datatransfer.DataFlavor;
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    29
import java.awt.datatransfer.FlavorMap;
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    30
import java.util.LinkedHashSet;
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    31
import java.util.function.Supplier;
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    32
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    33
/**
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    34
 * Contains services which desktop provides to the datatransfer system
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    35
 * to enrich it's functionality
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    36
 *
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    37
 * @author Petr Pchelko
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    38
 * @since 1.9
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    39
 */
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    40
public interface DesktopDatatransferService {
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    41
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    42
    /**
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    43
     * If desktop is present - invokes a {@code Runnable} on
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    44
     * the event dispatch thread. Otherwise invokes a {@code run()}
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    45
     * method directly.
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    46
     *
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    47
     * @param r a {@code Runnable} to invoke
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    48
     */
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    49
    void invokeOnEventThread(Runnable r);
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    50
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    51
    /**
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    52
     * Get a platform-dependent default unicode encoding to use in
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    53
     * datatransfer system.
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    54
     *
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    55
     * @return default unicode encoding
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    56
     */
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    57
    String getDefaultUnicodeEncoding();
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    58
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    59
    /**
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    60
     * Takes an appropriate {@code FlavorMap} from the desktop.
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    61
     * If no appropriate table is found - uses a provided supplier to
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    62
     * instantiate a table. If the desktop is absent - creates and returns
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    63
     * a system singleton.
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    64
     *
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    65
     * @param supplier a constructor that should be used to create a new instance of
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    66
     *                 the {@code FlavorMap}
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    67
     * @return a {@code FlavorMap}
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    68
     */
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    69
    FlavorMap getFlavorMap(Supplier<FlavorMap> supplier);
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    70
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    71
    /**
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    72
     * Checks if desktop is present
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    73
     *
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    74
     * @return {@code true} is the desktop is present
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    75
     */
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    76
    boolean isDesktopPresent();
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    77
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    78
    /**
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    79
     * Returns platform-specific mappings for the specified native format.
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    80
     * If there are no platform-specific mappings for this native, the method
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    81
     * returns an empty {@code Set}
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    82
     *
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    83
     * @param nat a native format to return flavors for
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    84
     * @return set of platform-specific mappings for a native format
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    85
     */
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    86
    LinkedHashSet<DataFlavor> getPlatformMappingsForNative(String nat);
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    87
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    88
    /**
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    89
     * Returns platform-specific mappings for the specified flavor.
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    90
     * If there are no platform-specific mappings for this flavor, the method
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    91
     * returns an empty {@code Set}
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    92
     *
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    93
     * @param df {@code DataFlavor} to return mappings for
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    94
     * @return set of platform-specific mappings for a {@code DataFlavor}
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    95
     */
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    96
    LinkedHashSet<String> getPlatformMappingsForFlavor(DataFlavor df);
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    97
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    98
    /**
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
    99
     * This method is called for text flavor mappings established while parsing
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
   100
     * the default flavor mappings file. It stores the "eoln" and "terminators"
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
   101
     * parameters which are not officially part of the MIME type. They are
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
   102
     * MIME parameters specific to the flavormap.properties file format.
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
   103
     */
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
   104
    void registerTextFlavorProperties(String nat, String charset,
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
   105
                                      String eoln, String terminators);
9a3cf8ee0776 8037485: Refactor java.awt.datatransfer to eliminate dependency on AWT
pchelko
parents:
diff changeset
   106
}