Package org.eclipse.aether.transfer
Class TransferEvent
- java.lang.Object
-
- org.eclipse.aether.transfer.TransferEvent
-
public final class TransferEvent extends java.lang.ObjectAn event fired to a transfer listener during an artifact/metadata transfer.- See Also:
TransferListener,TransferEvent.Builder
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTransferEvent.BuilderA builder to create transfer events.static classTransferEvent.EventTypeThe type of the event.static classTransferEvent.RequestTypeThe type of the request/transfer being performed.
-
Field Summary
Fields Modifier and Type Field Description private java.nio.ByteBufferdataBufferprivate java.lang.Exceptionexceptionprivate TransferEvent.RequestTyperequestTypeprivate TransferResourceresourceprivate RepositorySystemSessionsessionprivate longtransferredBytesprivate TransferEvent.EventTypetype
-
Constructor Summary
Constructors Constructor Description TransferEvent(TransferEvent.Builder builder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.nio.ByteBuffergetDataBuffer()Gets the byte buffer holding the transferred bytes since the last event.intgetDataLength()Gets the number of bytes that have been transferred since the last event.java.lang.ExceptiongetException()Gets the error that occurred during the transfer.TransferEvent.RequestTypegetRequestType()Gets the type of the request/transfer.TransferResourcegetResource()Gets the resource that is being transferred.RepositorySystemSessiongetSession()Gets the repository system session during which the event occurred.longgetTransferredBytes()Gets the total number of bytes that have been transferred since the download/upload of the resource was started.TransferEvent.EventTypegetType()Gets the type of the event.java.lang.StringtoString()
-
-
-
Field Detail
-
type
private final TransferEvent.EventType type
-
requestType
private final TransferEvent.RequestType requestType
-
session
private final RepositorySystemSession session
-
resource
private final TransferResource resource
-
dataBuffer
private final java.nio.ByteBuffer dataBuffer
-
transferredBytes
private final long transferredBytes
-
exception
private final java.lang.Exception exception
-
-
Constructor Detail
-
TransferEvent
TransferEvent(TransferEvent.Builder builder)
-
-
Method Detail
-
getType
public TransferEvent.EventType getType()
Gets the type of the event.- Returns:
- The type of the event, never
null.
-
getRequestType
public TransferEvent.RequestType getRequestType()
Gets the type of the request/transfer.- Returns:
- The type of the request/transfer, never
null.
-
getSession
public RepositorySystemSession getSession()
Gets the repository system session during which the event occurred.- Returns:
- The repository system session during which the event occurred, never
null.
-
getResource
public TransferResource getResource()
Gets the resource that is being transferred.- Returns:
- The resource being transferred, never
null.
-
getTransferredBytes
public long getTransferredBytes()
Gets the total number of bytes that have been transferred since the download/upload of the resource was started. If a download has been resumed, the returned count includes the bytes that were already downloaded during the previous attempt. In other words, the ratio of transferred bytes to the content length of the resource indicates the percentage of transfer completion.- Returns:
- The total number of bytes that have been transferred since the transfer started, never negative.
- See Also:
getDataLength(),TransferResource.getResumeOffset()
-
getDataBuffer
public java.nio.ByteBuffer getDataBuffer()
Gets the byte buffer holding the transferred bytes since the last event. A listener must assume this buffer to be owned by the event source and must not change any byte in this buffer. Also, the buffer is only valid for the duration of the event callback, i.e. the next event might reuse the same buffer (with updated contents). Therefore, if the actual event processing is deferred, the byte buffer would have to be cloned to create an immutable snapshot of its contents.- Returns:
- The (read-only) byte buffer or
nullif not applicable to the event, i.e. if the event type is notTransferEvent.EventType.PROGRESSED.
-
getDataLength
public int getDataLength()
Gets the number of bytes that have been transferred since the last event.- Returns:
- The number of bytes that have been transferred since the last event, possibly zero but never negative.
- See Also:
getTransferredBytes()
-
getException
public java.lang.Exception getException()
Gets the error that occurred during the transfer.- Returns:
- The error that occurred or
nullif none.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-