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