org.awakefw.file.api.client
Class AwakeUrl

java.lang.Object
  extended by org.awakefw.file.api.client.AwakeUrl

public final class AwakeUrl
extends Object

Main class for executing URL downloads.

All long operations that need to be run on a separated thread may be followed in Swing using a Java Progress Bar or Progress Monitor: just implement the AwakeProgressManager interface.

Since:
1.0
Author:
Nicolas de Pomereu
See Also:
HttpProxy, AwakeProgressManager

Constructor Summary
AwakeUrl()
          Constructor.
AwakeUrl(HttpProxy httpProxy)
          Constructor that allows to define a proxy.
AwakeUrl(HttpProxy httpProxy, HttpProtocolParameters httpProtocolParameters)
          Constructor that allows to define a proxy and protocol parameters.
 
Method Summary
 String download(URL url)
          Creates a String from an URL.
 void download(URL url, File file)
          Creates a File from an URL.
 int getHttpStatusCode()
          Returns the http status code of the last executed download.
 String getVersion()
          Returns the Awake File Version.
 void setAwakeProgressManager(AwakeProgressManager awakeProgressManager)
          Allows to set an Awake Progress Manager instance.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AwakeUrl

public AwakeUrl(HttpProxy httpProxy,
                HttpProtocolParameters httpProtocolParameters)
         throws IllegalArgumentException
Constructor that allows to define a proxy and protocol parameters.

Parameters:
httpProxy - the http proxy to use
httpProtocolParameters - the http parameters to use
Throws:
IllegalArgumentException

AwakeUrl

public AwakeUrl(HttpProxy httpProxy)
Constructor that allows to define a proxy.

Parameters:
httpProxy - the http proxy to use

AwakeUrl

public AwakeUrl()
Constructor.

Method Detail

setAwakeProgressManager

public void setAwakeProgressManager(AwakeProgressManager awakeProgressManager)
Allows to set an Awake Progress Manager instance.

Parameters:
awakeProgressManager - the Awake Progress Manager instance

getHttpStatusCode

public int getHttpStatusCode()
Returns the http status code of the last executed download. Will allow to check, for example, if a proxy is required to access the URL.

Returns:
the http status code of the last executed download

download

public void download(URL url,
                     File file)
              throws IllegalArgumentException,
                     UnknownHostException,
                     FileNotFoundException,
                     InterruptedException,
                     IOException
Creates a File from an URL.

Parameters:
url - the URL
file - the file to create from the download.
Throws:
IllegalArgumentException - if url or file is null
UnknownHostException - if Host url (http://www.acme.org) does not exists or no Internet Connection.
FileNotFoundException - if it is impossible to connect to the URL.
InterruptedException - if the download is interrupted by user through an AwakeProgressManager
IOException - For all other IO / Network / System Error

download

public String download(URL url)
                throws UnknownHostException,
                       IOException
Creates a String from an URL.

Parameters:
url - the URL
Returns:
the content of the url
Throws:
UnknownHostException - if Host url (http://www.acme.org) does not exists or no Internet Connection.
FileNotFoundException - if it is impossible to connect to the URL.
IOException - For all other IO / Network / System Error

getVersion

public String getVersion()
Returns the Awake File Version.

Returns:
the Awake File Version


Awake File - Easy file upload & download through HTTP for Android, Swing and JavaFX
Copyright © 2013 KawanSoft SAS