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 to
newPaste - whether this is the first file of a new paste reaching the listener; subsequent files of the same paste arrive with false
totalFiles - the total number of files the originating paste contained, as reported by the browser (see Clipboard.PASTE_FILE_COUNT_HEADER)
fileName - the original file name as reported by the browser
contentType - the MIME type as reported by the browser, or null when the browser did not provide one
size - the size of the uploaded body in bytes
bytes - 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
    Constructor
    Description
    PasteFile(long pasteId, boolean newPaste, int totalFiles, String fileName, @Nullable String contentType, long size, byte[] bytes)
    Creates an instance of a PasteFile record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Returns the value of the bytes record component.
    @Nullable String
    Returns the value of the contentType record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the value of the fileName record component.
    final int
    Returns a hash code value for this object.
    boolean
    Returns the value of the newPaste record component.
    long
    Returns the value of the pasteId record component.
    long
    Returns the value of the size record component.
    final String
    Returns a string representation of this record class.
    int
    Returns the value of the totalFiles record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • PasteFile

      public PasteFile(long pasteId, boolean newPaste, int totalFiles, String fileName, @Nullable String contentType, long size, byte[] bytes)
      Creates an instance of a PasteFile record class.
      Parameters:
      pasteId - the value for the pasteId record component
      newPaste - the value for the newPaste record component
      totalFiles - the value for the totalFiles record component
      fileName - the value for the fileName record component
      contentType - the value for the contentType record component
      size - the value for the size record component
      bytes - the value for the bytes record component
  • Method Details

    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • pasteId

      public long pasteId()
      Returns the value of the pasteId record component.
      Returns:
      the value of the pasteId record component
    • newPaste

      public boolean newPaste()
      Returns the value of the newPaste record component.
      Returns:
      the value of the newPaste record component
    • totalFiles

      public int totalFiles()
      Returns the value of the totalFiles record component.
      Returns:
      the value of the totalFiles record component
    • fileName

      public String fileName()
      Returns the value of the fileName record component.
      Returns:
      the value of the fileName record component
    • contentType

      public @Nullable String contentType()
      Returns the value of the contentType record component.
      Returns:
      the value of the contentType record component
    • size

      public long size()
      Returns the value of the size record component.
      Returns:
      the value of the size record component
    • bytes

      public byte[] bytes()
      Returns the value of the bytes record component.
      Returns:
      the value of the bytes record component