Package com.vaadin.flow.server.streams
Record Class TransferContext
java.lang.Object
java.lang.Record
com.vaadin.flow.server.streams.TransferContext
- Record Components:
request- The current Vaadin request instanceresponse- The current Vaadin response instancesession- The current Vaadin session instancefileName- The name of the file being transferred. Might benullif the file name is not known.owningElement- The owner element that initiated the transfer. Can be used to get element's attributes or properties.contentLength- the total number of bytes to be transferred or-1if total number is unknown in advance, e.g. when reading from an input streamexception- An exception that occurred during the transfer, ornull.
public record TransferContext(VaadinRequest request, VaadinResponse response, VaadinSession session, String fileName, Element owningElement, long contentLength, Exception exception)
extends Record
A context that is given to all data transfer progress listeners. Holds the
references that may be needed for UI updates in listeners, e.g. showing a
data transfer progress or a notification.
-
Constructor Summary
ConstructorsConstructorDescriptionTransferContext(VaadinRequest request, VaadinResponse response, VaadinSession session, String fileName, Element owningElement, long contentLength) Create a transfer context for data transfer progress listeners.TransferContext(VaadinRequest request, VaadinResponse response, VaadinSession session, String fileName, Element owningElement, long contentLength, Exception exception) Creates an instance of aTransferContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the value of thecontentLengthrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theexceptionrecord component.fileName()Returns the value of thefileNamerecord component.Get ownerComponentfor this data transfer.getUI()Get the current UI instance for this data transfer that can be used to make asynchronnous UI updates withUI.access(com.vaadin.flow.server.Command).final inthashCode()Returns a hash code value for this object.Returns the value of theowningElementrecord component.request()Returns the value of therequestrecord component.response()Returns the value of theresponserecord component.session()Returns the value of thesessionrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
TransferContext
public TransferContext(VaadinRequest request, VaadinResponse response, VaadinSession session, String fileName, Element owningElement, long contentLength) Create a transfer context for data transfer progress listeners.- Parameters:
request- The current Vaadin request instanceresponse- The current Vaadin response instancesession- The current Vaadin session instancefileName- The name of the file being transferred. Might benullif the file name is not known.owningElement- The owner element that initiated the transfer. Can be used to get element's attributes or properties.contentLength- the total number of bytes to be transferred or-1if total number is unknown in advance, e.g. when reading from an input stream
-
TransferContext
public TransferContext(VaadinRequest request, VaadinResponse response, VaadinSession session, String fileName, Element owningElement, long contentLength, Exception exception) Creates an instance of aTransferContextrecord class.- Parameters:
request- the value for therequestrecord componentresponse- the value for theresponserecord componentsession- the value for thesessionrecord componentfileName- the value for thefileNamerecord componentowningElement- the value for theowningElementrecord componentcontentLength- the value for thecontentLengthrecord componentexception- the value for theexceptionrecord component
-
-
Method Details
-
getOwningComponent
Get ownerComponentfor this data transfer.The progress listener may change the component's state during donwload, e.g. disable or hide it during transfer or get the component's own data like id.
- Returns:
- owning component or null if none is defined
-
getUI
Get the current UI instance for this data transfer that can be used to make asynchronnous UI updates withUI.access(com.vaadin.flow.server.Command).- Returns:
- Current UI instance
-
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 '=='. -
request
Returns the value of therequestrecord component.- Returns:
- the value of the
requestrecord component
-
response
Returns the value of theresponserecord component.- Returns:
- the value of the
responserecord component
-
session
Returns the value of thesessionrecord component.- Returns:
- the value of the
sessionrecord component
-
fileName
Returns the value of thefileNamerecord component.- Returns:
- the value of the
fileNamerecord component
-
owningElement
Returns the value of theowningElementrecord component.- Returns:
- the value of the
owningElementrecord component
-
contentLength
public long contentLength()Returns the value of thecontentLengthrecord component.- Returns:
- the value of the
contentLengthrecord component
-
exception
Returns the value of theexceptionrecord component.- Returns:
- the value of the
exceptionrecord component
-