net.netheos.pcsapi.models
Class CDownloadRequest

java.lang.Object
  extended by net.netheos.pcsapi.models.CDownloadRequest

public class CDownloadRequest
extends Object

Class that parametrizes a download request: path + bytes sink + (optional) byte range


Constructor Summary
CDownloadRequest(CPath path, ByteSink byteSink)
           
 
Method Summary
 ByteSink getByteSink()
          If no progress listener has been set, return the byte sink defined in constructor, otherwise decorate it.
 Headers getHttpHeaders()
          Get the HTTP headers to be used for download request.
 CPath getPath()
          Get the file path to download
 CDownloadRequest setProgressListener(ProgressListener pl)
          Defines an object that will be notified during download.
 CDownloadRequest setRange(long offset, long length)
          Defines a range for partial content download.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CDownloadRequest

public CDownloadRequest(CPath path,
                        ByteSink byteSink)
Method Detail

getPath

public CPath getPath()
Get the file path to download

Returns:
The file path

getHttpHeaders

public Headers getHttpHeaders()
Get the HTTP headers to be used for download request. Default implementation only handles Range header.

Returns:
The headers

setRange

public CDownloadRequest setRange(long offset,
                                 long length)
Defines a range for partial content download. Note that second parameter is a length, not an offset (this differs from http header Range header raw value).

Parameters:
offset - The start offset to download the file, or <0 for downloading only end of file
length - (never 0) The data length to download, or <0 for downloading up to end of file
Returns:
This download request

setProgressListener

public CDownloadRequest setProgressListener(ProgressListener pl)
Defines an object that will be notified during download.

Parameters:
pl - the progress listener
Returns:
this download request

getByteSink

public ByteSink getByteSink()
If no progress listener has been set, return the byte sink defined in constructor, otherwise decorate it.

Returns:
the byte sink to be used for download operations.


Copyright © 2014. All Rights Reserved.