Package org.eclipse.aether.transfer
Class TransferEvent.Builder
java.lang.Object
org.eclipse.aether.transfer.TransferEvent.Builder
- Enclosing class:
- TransferEvent
A builder to create transfer events.
-
Constructor Summary
ConstructorDescriptionBuilder
(RepositorySystemSession session, TransferResource resource) Creates a new transfer event builder for the specified session and the given resource. -
Method Summary
Modifier and TypeMethodDescriptionaddTransferredBytes
(long transferredBytes) Increments the total number of bytes that have been transferred so far during the download/upload.build()
Builds a new transfer event from the current values of this builder.copy()
Creates a new transfer event builder from the current values of this builder.Sets the type of the event and resets event-specific fields.setDataBuffer
(byte[] buffer, int offset, int length) Sets the byte buffer holding the transferred bytes since the last event.setDataBuffer
(ByteBuffer dataBuffer) Sets the byte buffer holding the transferred bytes since the last event.setException
(Exception exception) Sets the error that occurred during the transfer.setRequestType
(TransferEvent.RequestType requestType) Sets the type of the request/transfer.setTransferredBytes
(long transferredBytes) Sets the total number of bytes that have been transferred so far during the download/upload of the resource.Sets the type of the event.
-
Constructor Details
-
Builder
Creates a new transfer event builder for the specified session and the given resource.- Parameters:
session
- The repository system session, must not benull
.resource
- The resource being transferred, must not benull
.
-
-
Method Details
-
copy
Creates a new transfer event builder from the current values of this builder. The state of this builder remains unchanged.- Returns:
- The new event builder, never
null
.
-
resetType
Sets the type of the event and resets event-specific fields. In more detail, the data buffer and the exception fields are set tonull
. Furthermore, the total number of transferred bytes is set to0
if the event type isTransferEvent.EventType.STARTED
.- Parameters:
type
- The type of the event, must not benull
.- Returns:
- This event builder for chaining, never
null
.
-
setType
Sets the type of the event. When re-using the same builder to generate a sequence of events for one transfer,resetType(TransferEvent.EventType)
might be more handy.- Parameters:
type
- The type of the event, must not benull
.- Returns:
- This event builder for chaining, never
null
.
-
setRequestType
Sets the type of the request/transfer.- Parameters:
requestType
- The request/transfer type, must not benull
.- Returns:
- This event builder for chaining, never
null
.
-
setTransferredBytes
Sets the total number of bytes that have been transferred so far during the download/upload of the resource. If a download is being resumed, the count must include the bytes that were already downloaded in the previous attempt and from which the current transfer started. In this case, the event typeTransferEvent.EventType.STARTED
should indicate from what byte the download resumes.- Parameters:
transferredBytes
- The total number of bytes that have been transferred so far during the download/upload of the resource, must not be negative.- Returns:
- This event builder for chaining, never
null
. - See Also:
-
addTransferredBytes
Increments the total number of bytes that have been transferred so far during the download/upload.- Parameters:
transferredBytes
- The number of bytes that have been transferred since the last event, must not be negative.- Returns:
- This event builder for chaining, never
null
.
-
setDataBuffer
Sets the byte buffer holding the transferred bytes since the last event.- Parameters:
buffer
- The byte buffer holding the transferred bytes since the last event, may benull
if not applicable to the event.offset
- The starting point of valid bytes in the array.length
- The number of valid bytes, must not be negative.- Returns:
- This event builder for chaining, never
null
.
-
setDataBuffer
Sets the byte buffer holding the transferred bytes since the last event.- Parameters:
dataBuffer
- The byte buffer holding the transferred bytes since the last event, may benull
if not applicable to the event.- Returns:
- This event builder for chaining, never
null
.
-
setException
Sets the error that occurred during the transfer.- Parameters:
exception
- The error that occurred during the transfer, may benull
if none.- Returns:
- This event builder for chaining, never
null
.
-
build
Builds a new transfer event from the current values of this builder. The state of the builder itself remains unchanged.- Returns:
- The transfer event, never
null
.
-