| 8 | import io.github.humbleui.jwm.impl.*; |
| 9 | |
| 10 | public class Clipboard { |
| 11 | @ApiStatus.Internal |
| 12 | public static Map<String, ClipboardFormat> _formats = Collections.synchronizedMap(new HashMap<String, ClipboardFormat>()); |
| 13 | |
| 14 | /** |
| 15 | * <p>Set the system clipboard content.</p> |
| 16 | * |
| 17 | * <p>Previse clipboard content is cleared automatically.</p> |
| 18 | * <p>If provided entries list is emtpy, then this function is equivalent to clear call.</p> |
| 19 | * <p>If provided list contains several entries with the same format, then the last will be set.</p> |
| 20 | * |
| 21 | * @param entries List if clipboard entries to set |
| 22 | */ |
| 23 | public static void set(ClipboardEntry... entries) { |
| 24 | assert _onUIThread() : "Should be run on UI thread"; |
| 25 | assert entries.length > 0; |
| 26 | _nSet(entries); |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * <p>Get the system clipboard content.</p> |
| 31 | * |
| 32 | * <p>Clipboard content returned as an entry with specified format and serialized byte data.</p> |
| 33 | * <p>Uses provided formats list to extract preferred clipboard data. First format has |
| 34 | * the highest priority, last specified format has the lowest priority.</p> |
| 35 | * |
| 36 | * <p>If formats list empty or there is no available data with one of specified formats, |
| 37 | * method returns null.</p> |
| 38 | * |
| 39 | * @param formats List of clipboard formats to extract |
| 40 | * @return Extracted clipboard entry; may be null |
| 41 | */ |
| 42 | @Nullable |
| 43 | public static ClipboardEntry get(ClipboardFormat... formats) { |
| 44 | assert _onUIThread() : "Should be run on UI thread"; |
| 45 | assert formats.length > 0: "must contain at least one format entry"; |
| 46 | return _nGet(formats); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * <p>Get list of currently available clipboard data formats.</p> |
| 51 | * |
| 52 | * <p>If there is no data in the system clipboard, this function returns null.</p> |
| 53 | * <p>If there is in the system clipboard some data in formats, which are not |
| 54 | * predefined or are not manually registered by the user, then the implementation |
| 55 | * will automatically register this formats and make its data available to the user.</p> |
| 56 | * |
| 57 | * @return List of available formats; may be null |
| 58 | */ |
| 59 | @Nullable |
| 60 | public static ClipboardFormat[] getFormats() { |
| 61 | assert _onUIThread() : "Should be run on UI thread"; |
| 62 | return _nGetFormats(); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * <p>Clear system clipboard content.</p> |
| 67 | */ |
nothing calls this directly
no outgoing calls
no test coverage detected