- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<DataFormat,Object>
-
- javafx.scene.input.ClipboardContent
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<DataFormat,Object>
public class ClipboardContent extends HashMap<DataFormat,Object>
Data container forClipboard
data. It can hold multiple data in several data formats.- Since:
- JavaFX 2.0
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Constructor Summary
Constructors Constructor Description ClipboardContent()
-
Method Summary
Modifier and Type Method Description List<File>
getFiles()
Gets the List of Files from theClipboardContent
which had previously been put.String
getHtml()
Gets the HTML String from theClipboardContent
which had previously been put.Image
getImage()
Gets the Image from theClipboardContent
which had previously been put.String
getRtf()
Gets the RTF String from theClipboardContent
which had previously been put.String
getString()
Gets the plain text String from theClipboardContent
which had previously been put.String
getUrl()
Gets the URL String from theClipboardContent
which had previously been put.boolean
hasFiles()
Gets whether a List of Files (DataFormat.FILES
) has been put to thisClipboardContent
.boolean
hasHtml()
Gets whether an HTML String (DataFormat.HTML
) has been put to thisClipboardContent
.boolean
hasImage()
Gets whether an Image (DataFormat.IMAGE
) has been put to thisClipboardContent
.boolean
hasRtf()
Gets whether a RTF String (DataFormat.RTF
) has been put to thisClipboardContent
.boolean
hasString()
Gets whether a plain text String (DataFormat.PLAIN_TEXT
) has been put to thisClipboardContent
.boolean
hasUrl()
Gets whether a URL String (DataFormat.URL
) has been put to thisClipboardContent
.boolean
putFiles(List<File> files)
Puts a List of Files into theClipboardContent
.boolean
putFilesByPath(List<String> filePaths)
Puts a List of Files into theClipboardContent
, based on the file path.boolean
putHtml(String html)
Puts an HTML String into theClipboardContent
.boolean
putImage(Image i)
Puts an Image into theClipboardContent
.boolean
putRtf(String rtf)
Puts a RTF String into theClipboardContent
.boolean
putString(String s)
Puts a plain text String into theClipboardContent
.boolean
putUrl(String url)
Puts a URL String into theClipboardContent
.-
Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
-
-
-
Method Detail
-
hasString
public final boolean hasString()
Gets whether a plain text String (DataFormat.PLAIN_TEXT
) has been put to thisClipboardContent
.- Returns:
- true if
containsKey(DataFormat.PLAIN_TEXT)
returns true, false otherwise
-
putString
public final boolean putString(String s)
Puts a plain text String into theClipboardContent
. This is equivalent to invokingput(DataFormat.PLAIN_TEXT, s)
. Setting this value to null effectively clears it from theClipboardContent
.- Parameters:
s
- The string to place. This may be null.- Returns:
- always true (the string is always successfully put)
-
getString
public final String getString()
Gets the plain text String from theClipboardContent
which had previously been put. This is equivalent to invokingget(DataFormat.PLAIN_TEXT)
. If no such entry exists, null is returned.- Returns:
- The String in the
ClipboardContent
associated withDataFormat.PLAIN_TEXT
, or null if there is not one.
-
hasUrl
public final boolean hasUrl()
Gets whether a URL String (DataFormat.URL
) has been put to thisClipboardContent
.- Returns:
- true if
containsKey(DataFormat.URL)
returns true, false otherwise
-
putUrl
public final boolean putUrl(String url)
Puts a URL String into theClipboardContent
. This is equivalent to invokingput(DataFormat.URL, url)
. Setting this value to null effectively clears it from theClipboardContent
.- Parameters:
url
- The string to place. This may be null.- Returns:
- always true (the URL is always successfully put)
-
getUrl
public final String getUrl()
Gets the URL String from theClipboardContent
which had previously been put. This is equivalent to invokingget(DataFormat.URL)
. If no such entry exists, null is returned.- Returns:
- The String in the
ClipboardContent
associated withDataFormat.URL
, or null if there is not one.
-
hasHtml
public final boolean hasHtml()
Gets whether an HTML String (DataFormat.HTML
) has been put to thisClipboardContent
.- Returns:
- true if
containsKey(DataFormat.HTML)
returns true, false otherwise
-
putHtml
public final boolean putHtml(String html)
Puts an HTML String into theClipboardContent
. This is equivalent to invokingput(DataFormat.HTML, html)
. Setting this value to null effectively clears it from theClipboardContent
.- Parameters:
html
- The string to place. This may be null.- Returns:
- always true (the HTML is always successfully put)
-
getHtml
public final String getHtml()
Gets the HTML String from theClipboardContent
which had previously been put. This is equivalent to invokingget(DataFormat.HTML)
. If no such entry exists, null is returned.- Returns:
- The String in the
ClipboardContent
associated withDataFormat.HTML
, or null if there is not one.
-
hasRtf
public final boolean hasRtf()
Gets whether a RTF String (DataFormat.RTF
) has been put to thisClipboardContent
.- Returns:
- true if
containsKey(DataFormat.RTF)
returns true, false otherwise
-
putRtf
public final boolean putRtf(String rtf)
Puts a RTF String into theClipboardContent
. This is equivalent to invokingput(DataFormat.RTF, rtf)
. Setting this value to null effectively clears it from theClipboardContent
.- Parameters:
rtf
- The string to place. This may be null.- Returns:
- always true (the RTF is always successfully put)
-
getRtf
public final String getRtf()
Gets the RTF String from theClipboardContent
which had previously been put. This is equivalent to invokingget(DataFormat.RTF)
. If no such entry exists, null is returned.- Returns:
- The String in the
ClipboardContent
associated withDataFormat.RTF
, or null if there is not one.
-
hasImage
public final boolean hasImage()
Gets whether an Image (DataFormat.IMAGE
) has been put to thisClipboardContent
.- Returns:
- true if
containsKey(DataFormat.IMAGE)
returns true, false otherwise
-
putImage
public final boolean putImage(Image i)
Puts an Image into theClipboardContent
. This is equivalent to invokingput(DataFormat.IMAGE, i)
. Setting this value to null effectively clears it from theClipboardContent
. When an image is placed on the clipboard in this manner, an operating system dependent image is loaded onto the clipboard (such as TIFF on Mac or DIB on Windows).- Parameters:
i
- The image to place. This may be null.- Returns:
- always true (the image is always successfully put)
-
getImage
public final Image getImage()
Gets the Image from theClipboardContent
which had previously been put. This is equivalent to invokingget(DataFormat.IMAGE)
. If no such entry exists, null is returned.- Returns:
- The Image in the
ClipboardContent
associated withDataFormat.IMAGE
, or null if there is not one.
-
hasFiles
public final boolean hasFiles()
Gets whether a List of Files (DataFormat.FILES
) has been put to thisClipboardContent
.- Returns:
- true if
containsKey(DataFormat.FILES)
returns true, false otherwise
-
putFiles
public final boolean putFiles(List<File> files)
Puts a List of Files into theClipboardContent
. This is equivalent to invokingput(DataFormat.FILES, files)
. Setting this value to null effectively clears it from theClipboardContent
.- Parameters:
files
- The files to place. This may be null.- Returns:
- always true (the files are always successfully put)
-
putFilesByPath
public final boolean putFilesByPath(List<String> filePaths)
Puts a List of Files into theClipboardContent
, based on the file path. This is simply a convenience method which constructs a List of Files and invokes theputFiles(java.util.List<java.io.File>)
method.- Parameters:
filePaths
- The files to place. This may be null.- Returns:
- always true (the files are always successfully put)
-
getFiles
public final List<File> getFiles()
Gets the List of Files from theClipboardContent
which had previously been put. This is equivalent to invokingget(DataFormat.FILES)
. If no such entry exists, null is returned.- Returns:
- The List of Files in the
ClipboardContent
associated withDataFormat.FILES
, or null if there is not one.
-
-