org.sonatype.aether.util.listener
Class DefaultTransferEvent

java.lang.Object
  extended by org.sonatype.aether.util.listener.DefaultTransferEvent
All Implemented Interfaces:
TransferEvent

public class DefaultTransferEvent
extends Object
implements TransferEvent

A simple transfer event.

Author:
Benjamin Bentmann

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.sonatype.aether.transfer.TransferEvent
TransferEvent.EventType, TransferEvent.RequestType
 
Constructor Summary
DefaultTransferEvent()
           
 
Method Summary
 ByteBuffer getDataBuffer()
          Gets the byte buffer holding the transferred bytes since the last event.
 int getDataLength()
          Gets the number of bytes that have been transferred since the last event.
 Exception getException()
          Gets the error that occurred during the transfer.
 TransferEvent.RequestType getRequestType()
          Gets the type of the request/transfer.
 TransferResource getResource()
          Gets the resource that is being transferred.
 long getTransferredBytes()
          Gets the total number of bytes that have been transferred since the download/upload was started.
 TransferEvent.EventType getType()
          Gets the type of the event.
 DefaultTransferEvent setDataBuffer(byte[] buffer, int offset, int length)
          Wraps the given byte[]-array into a ByteBuffer as the content for this event.
 DefaultTransferEvent setDataBuffer(ByteBuffer dataBuffer)
          Sets the byte buffer holding the transferred bytes since the last event.
 DefaultTransferEvent setException(Exception exception)
          Sets the error that occurred during the transfer.
 DefaultTransferEvent setRequestType(TransferEvent.RequestType requestType)
          Sets the type of the request/transfer.
 DefaultTransferEvent setResource(TransferResource resource)
          Sets the resource being transferred.
 DefaultTransferEvent setTransferredBytes(long transferredBytes)
          Sets the total number of bytes that have been transferred so far during the download/upload.
 DefaultTransferEvent setType(TransferEvent.EventType type)
          Sets the type of the event.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultTransferEvent

public DefaultTransferEvent()
Method Detail

getType

public TransferEvent.EventType getType()
Description copied from interface: TransferEvent
Gets the type of the event.

Specified by:
getType in interface TransferEvent
Returns:
The type of the event, never null.

setType

public DefaultTransferEvent setType(TransferEvent.EventType type)
Sets the type of the event.

Parameters:
type - The type of the event, must not be null.
Returns:
This event for chaining, never null.

getRequestType

public TransferEvent.RequestType getRequestType()
Description copied from interface: TransferEvent
Gets the type of the request/transfer.

Specified by:
getRequestType in interface TransferEvent
Returns:
The type of the request/transfer, never null.

setRequestType

public DefaultTransferEvent setRequestType(TransferEvent.RequestType requestType)
Sets the type of the request/transfer.

Parameters:
requestType - The request/transfer type, must not be null.
Returns:
This event for chaining, never null.

getResource

public TransferResource getResource()
Description copied from interface: TransferEvent
Gets the resource that is being transferred.

Specified by:
getResource in interface TransferEvent
Returns:
The resource being transferred, never null.

setResource

public DefaultTransferEvent setResource(TransferResource resource)
Sets the resource being transferred.

Parameters:
resource - The resource being transferred, must not be null.
Returns:
This event for chaining, never null.

getTransferredBytes

public long getTransferredBytes()
Description copied from interface: TransferEvent
Gets the total number of bytes that have been transferred since the download/upload was started.

Specified by:
getTransferredBytes in interface TransferEvent
Returns:
The total number of bytes that have been transferred since the transfer started, never negative.
See Also:
TransferEvent.getDataLength()

setTransferredBytes

public DefaultTransferEvent setTransferredBytes(long transferredBytes)
Sets the total number of bytes that have been transferred so far during the download/upload.

Parameters:
transferredBytes - The total number of bytes that have been transferred so far during the download/upload, must not be negative.
Returns:
This event for chaining, never null.

getDataLength

public int getDataLength()
Description copied from interface: TransferEvent
Gets the number of bytes that have been transferred since the last event.

Specified by:
getDataLength in interface TransferEvent
Returns:
The number of bytes that have been transferred since the last event, possibly zero but never negative.
See Also:
TransferEvent.getTransferredBytes()

getDataBuffer

public ByteBuffer getDataBuffer()
Description copied from interface: TransferEvent
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.

Specified by:
getDataBuffer in interface TransferEvent
Returns:
The (read-only) byte buffer or null if not applicable to the event, i.e. if the event type is not TransferEvent.EventType.PROGRESSED.

setDataBuffer

public DefaultTransferEvent setDataBuffer(byte[] buffer,
                                          int offset,
                                          int length)
Wraps the given byte[]-array into a ByteBuffer as the content for this event.

Parameters:
buffer - The array to use, must not be null.
offset - the starting point of valid bytes in the array.
length - the number of valid bytes.
Returns:
This event for chaining, never null.

setDataBuffer

public DefaultTransferEvent setDataBuffer(ByteBuffer dataBuffer)
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 be null.
Returns:
This event for chaining, never null.

getException

public Exception getException()
Description copied from interface: TransferEvent
Gets the error that occurred during the transfer.

Specified by:
getException in interface TransferEvent
Returns:
The error that occurred or null if none.

setException

public DefaultTransferEvent setException(Exception exception)
Sets the error that occurred during the transfer.

Parameters:
exception - The error that occurred during the transfer, may be null if none.
Returns:
This event for chaining, never null.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2010-2011 Sonatype, Inc.. All Rights Reserved.