Class ClipboardContent
- Direct Known Subclasses:
RichTextClipboardData
A set of alternative clipboard representations keyed by MIME type. A clipboard write should
normally include text/plain plus any richer formats it can provide. Clipboard readers negotiate
by inspecting #getMimeTypes() and requesting the representation they understand best.
Values are usually String or byte[]. Ports may support additional native value types, but must
retain the plain-text representation when one is supplied.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final StringA local file reference (a file path / URIString, or aString[]for several files).static final StringGIF image bytes (byte[]).static final Stringstatic final StringJPEG image bytes (byte[]).static final Stringstatic final StringPNG image bytes (byte[]).static final Stringstatic final Stringstatic final StringA newline separated list of URIs, the format desktop browsers and file managers use when a link or a file is dragged out of them. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindPreferredMimeType(String[] preferredMimeTypes) Returns the first available MIME type from the caller's preference list, or null.byte[]Returns the binary (byte[]) representation for a MIME type -- e.g.Returns the representation for a MIME type, or null when it isn't available.String[]getFiles()Returns the#MIME_FILErepresentation as a path array regardless of whether the producer stored oneStringor aString[], or null when no files are available.String[]Returns the available MIME types in preference order.Returns a string representation, or null when the value isn't a string.booleanhasMimeType(String mimeType) Returns true when this content includes the requested MIME type.Adds or replaces a representation.setDataProvider(String mimeType, ClipboardDataProvider provider) Declares a representation that is only built if something reads it, which is how a drag offers a file it has not written yet or an image it has not encoded yet.Sets the#MIME_FILErepresentation from a list of file paths orfile:URIs.
-
Field Details
-
MIME_TEXT
- See Also:
-
MIME_HTML
- See Also:
-
MIME_RTF
- See Also:
-
MIME_MARKDOWN
- See Also:
-
MIME_ASCIIDOC
- See Also:
-
MIME_PNG
-
MIME_JPEG
-
MIME_GIF
-
MIME_FILE
A local file reference (a file path / URIString, or aString[]for several files).- See Also:
-
MIME_URI_LIST
A newline separated list of URIs, the format desktop browsers and file managers use when a link or a file is dragged out of them.- See Also:
-
-
Constructor Details
-
ClipboardContent
public ClipboardContent()
-
-
Method Details
-
setData
Adds or replaces a representation. Passing null removes the MIME type. -
setDataProvider
Declares a representation that is only built if something reads it, which is how a drag offers a file it has not written yet or an image it has not encoded yet.
The provider is asked at most once and its answer is then cached, so
#getData(java.lang.String)behaves exactly as it would for a value passed to#setData(java.lang.String, java.lang.Object). It may run on a native clipboard or drag thread; seeClipboardDataProvider. Passing a null provider removes the MIME type.Parameters
-
mimeType: the MIME type this provider can produce -
provider: the provider, or null to remove the representation
Returns
this instance, for chaining
-
-
getData
-
getBytes
Returns the binary (byte[]) representation for a MIME type -- e.g. the raw bytes of an image or file -- or null when it isn't available or isn't binary. -
getText
-
hasMimeType
Returns true when this content includes the requested MIME type. -
getMimeTypes
Returns the available MIME types in preference order. -
setFiles
Sets the
#MIME_FILErepresentation from a list of file paths orfile:URIs.Ports differ on whether a single file is carried as a
Stringor a one elementString[]; this writes the form the rest of the framework expects, and#getFiles()reads either.Parameters
paths: the file paths, or null to remove the representation
Returns
this instance, for chaining
-
getFiles
Returns the#MIME_FILErepresentation as a path array regardless of whether the producer stored oneStringor aString[], or null when no files are available. -
findPreferredMimeType
-