Path: blob/master/src/java.datatransfer/share/classes/sun/datatransfer/DesktopDatatransferService.java
41155 views
/*1* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.datatransfer;2627import java.awt.datatransfer.DataFlavor;28import java.awt.datatransfer.FlavorMap;29import java.util.LinkedHashSet;30import java.util.function.Supplier;3132/**33* Contains services which desktop provides to the datatransfer system to enrich34* it's functionality.35*36* @author Petr Pchelko37* @since 938*/39public interface DesktopDatatransferService {4041/**42* If desktop is present - invokes a {@code Runnable} on the event dispatch43* thread. Otherwise invokes a {@code run()} method directly.44*45* @param r a {@code Runnable} to invoke46*/47void invokeOnEventThread(Runnable r);4849/**50* Get a platform-dependent default unicode encoding to use in datatransfer51* system.52*53* @return default unicode encoding54*/55String getDefaultUnicodeEncoding();5657/**58* Takes an appropriate {@code FlavorMap} from the desktop. If no59* appropriate table is found - uses a provided supplier to instantiate a60* table. If the desktop is absent - creates and returns a system singleton.61*62* @param supplier a constructor that should be used to create a new63* instance of the {@code FlavorMap}64* @return a {@code FlavorMap}65*/66FlavorMap getFlavorMap(Supplier<FlavorMap> supplier);6768/**69* Checks if desktop is present.70*71* @return {@code true} is the desktop is present72*/73boolean isDesktopPresent();7475/**76* Returns platform-specific mappings for the specified native format. If77* there are no platform-specific mappings for this native, the method78* returns an empty {@code Set}.79*80* @param nat a native format to return flavors for81* @return set of platform-specific mappings for a native format82*/83LinkedHashSet<DataFlavor> getPlatformMappingsForNative(String nat);8485/**86* Returns platform-specific mappings for the specified flavor. If there are87* no platform-specific mappings for this flavor, the method returns an88* empty {@code Set}.89*90* @param df {@code DataFlavor} to return mappings for91* @return set of platform-specific mappings for a {@code DataFlavor}92*/93LinkedHashSet<String> getPlatformMappingsForFlavor(DataFlavor df);9495/**96* This method is called for text flavor mappings established while parsing97* the default flavor mappings file. It stores the "eoln" and "terminators"98* parameters which are not officially part of the MIME type. They are MIME99* parameters specific to the flavormap.properties file format.100*/101void registerTextFlavorProperties(String nat, String charset,102String eoln, String terminators);103}104105106