Record Class PasteFile
java.lang.Object
java.lang.Record
com.vaadin.flow.component.clipboard.PasteFile
- Record Components:
pasteId- the paste sequence number this file belongs tonewPaste- whether this is the first file of a new paste reaching the listener; subsequent files of the same paste arrive withfalsetotalFiles- the total number of files the originating paste contained, as reported by the browser (seeClipboard.PASTE_FILE_COUNT_HEADER)fileName- the original file name as reported by the browsercontentType- the MIME type as reported by the browser, ornullwhen the browser did not provide onesize- the size of the uploaded body in bytesbytes- the uploaded body
- All Implemented Interfaces:
Serializable
public record PasteFile(long pasteId, boolean newPaste, int totalFiles, String fileName, @Nullable String contentType, long size, byte[] bytes)
extends Record
implements Serializable
A single file delivered to a
Clipboard.onFilePaste(com.vaadin.flow.component.Component, com.vaadin.flow.server.streams.UploadHandler) listener through
PasteFileHandler.inMemory or the onFile step of a
session. Carries the file's bytes plus the
metadata needed to render it (fileName(), contentType(),
size()) and the correlation needed to group it with the rest of the
paste it came from (pasteId(), newPaste(),
totalFiles()).
The paste id is the monotonic sequence number emitted by
the client paste-upload helper (see Clipboard.PASTE_ID_HEADER). All
files originating from the same paste gesture share one id; subsequent pastes
carry strictly larger ids. newPaste() is true on the first
file of each paste to reach the listener. Every file the browser uploads is
delivered — pastes do not cancel each other even when their uploads
interleave in transit, so application code wanting a "show the latest paste
only" UI tracks the highest paste id seen and filters in its own callback.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]bytes()Returns the value of thebytesrecord component.@Nullable StringReturns the value of thecontentTyperecord component.final booleanIndicates whether some other object is "equal to" this one.fileName()Returns the value of thefileNamerecord component.final inthashCode()Returns a hash code value for this object.booleannewPaste()Returns the value of thenewPasterecord component.longpasteId()Returns the value of thepasteIdrecord component.longsize()Returns the value of thesizerecord component.final StringtoString()Returns a string representation of this record class.intReturns the value of thetotalFilesrecord component.
-
Constructor Details
-
PasteFile
public PasteFile(long pasteId, boolean newPaste, int totalFiles, String fileName, @Nullable String contentType, long size, byte[] bytes) Creates an instance of aPasteFilerecord class.- Parameters:
pasteId- the value for thepasteIdrecord componentnewPaste- the value for thenewPasterecord componenttotalFiles- the value for thetotalFilesrecord componentfileName- the value for thefileNamerecord componentcontentType- the value for thecontentTyperecord componentsize- the value for thesizerecord componentbytes- the value for thebytesrecord component
-
-
Method Details
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
pasteId
public long pasteId()Returns the value of thepasteIdrecord component.- Returns:
- the value of the
pasteIdrecord component
-
newPaste
public boolean newPaste()Returns the value of thenewPasterecord component.- Returns:
- the value of the
newPasterecord component
-
totalFiles
public int totalFiles()Returns the value of thetotalFilesrecord component.- Returns:
- the value of the
totalFilesrecord component
-
fileName
Returns the value of thefileNamerecord component.- Returns:
- the value of the
fileNamerecord component
-
contentType
Returns the value of thecontentTyperecord component.- Returns:
- the value of the
contentTyperecord component
-
size
public long size()Returns the value of thesizerecord component.- Returns:
- the value of the
sizerecord component
-
bytes
public byte[] bytes()Returns the value of thebytesrecord component.- Returns:
- the value of the
bytesrecord component
-