Package com.illumon.iris.quandl
Class QuandlHelpers
java.lang.Object
com.illumon.iris.quandl.QuandlHelpers
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.http.HttpResponseExecutes an HTTP get for the passed request string and returns the HttpResponse object.static TableTries datatables and time series sources to find the requested Quandl database and source.static TablegetQuandl(String database, String dataName, StatusCallback progress) Tries datatables and time series sources to find the requested Quandl database and source.static TablegetQuandl(String database, String dataName, StatusCallback progress, String... args) Tries datatables and time series sources to find the requested Quandl database and source.static TableTries datatables and time series sources to find the requested Quandl database and source.static voidgetQuandlCsvFile(org.apache.http.HttpResponse response, String httpGetString, StatusCallback progress, File csvFile) Downloads a Quandl CSV file based on the http get string passed in, and takes a StatusCallback object to update status and/or a progress bar, and a File object to write the downloaded data to.static InputStreamgetQuandlCsvStream(org.apache.http.HttpResponse response, String httpGetString, StatusCallback progress) Downloads a Quandl CSV file based on the http get string passed in, and takes a StatusCallback object to update status and/or a progress bar, and a File object to write the downloaded data to.static TablegetQuandlDatasets(String database) Returns a table of Quandl dataset catalog information for the specified Quandl database.static TablegetQuandlDatasets(String database, StatusCallback progress) Returns a table of Quandl dataset catalog information for the specified Quandl database.static TablegetQuandlDatasets(String database, String dataset, StatusCallback progress, String... args) Returns a table of Quandl dataset catalog information for the specified Quandl database.static TablegetQuandlDatasets(String database, String dataset, String... args) Returns a table of Quandl dataset catalog information for the specified Quandl database.static TablegetQuandlTable(String database, String tableName) Creates a table from a Quandl datatablestatic TablegetQuandlTable(String database, String tableName, StatusCallback progress) Creates a table from a Quandl datatable, and also takes a StatusCallback object to update status or a progress bar.static TablegetQuandlTable(String database, String tableName, StatusCallback progress, String... args) Creates a table from a Quandl datatable, and also takes a StatusCallback object to update status or a progress bar, and a list of optional arguments to pass to the Quandl API.static TablegetQuandlTable(String database, String tableName, String... args) Creates a table from a Quandl datatable, and also takes a list of optional arguments to pass to the Quandl API.static TablegetQuandlTimeSeries(String database, String dataset) Returns a table for one or a group of Quandl datasets from the specified database and the name, name pattern, or name list specified for the dataset(s).static TablegetQuandlTimeSeries(String database, String dataset, StatusCallback progress) Returns a table for one or a group of Quandl datasets from the specified database and the name, name pattern, or name list specified for the dataset(s).static TablegetQuandlTimeSeries(String database, String dataset, StatusCallback progress, String... args) Returns a table for one or a group of Quandl datasets from the specified database and the name, name pattern, or name list specified for the dataset(s).static TablegetQuandlTimeSeries(String database, String dataset, String... args) Returns a table for one or a group of Quandl datasets from the specified database and the name, name pattern, or name list specified for the dataset(s).static longstatic StringprepareArgs(String apiKey, String... args) Formats the http parameters list and adds the api_key, if it's not already included in the parametersstatic StringReturns the current Quandl API key valuestatic voidquandlAPIKey(String key) Sets the Quandl API keystatic InputStreamreadQuandlZippedStream(InputStream source) Reads the first file (normally the only file) from inputstream representing a zipped file.static voidsetZipTimeout(long value)
-
Field Details
-
VALUECOLUMNNAME
- See Also:
-
quandlBaseUrl
-
-
Constructor Details
-
QuandlHelpers
public QuandlHelpers()
-
-
Method Details
-
quandlAPIKey
Returns the current Quandl API key value- Returns:
- the API key value
-
quandlAPIKey
Sets the Quandl API key- Parameters:
key- the API key value to set
-
getZipTimeout
public static long getZipTimeout() -
setZipTimeout
public static void setZipTimeout(long value) -
execGet
Executes an HTTP get for the passed request string and returns the HttpResponse object.- Parameters:
getString- a complete URI for an HTTP get- Returns:
- an HttpResponse object representing the connection to the HTTP server
-
getQuandl
Tries datatables and time series sources to find the requested Quandl database and source. No optional arguments to the Quandl API.- Parameters:
database- Quandl database namedataName- Quandl datatable or dataset name- Returns:
- an Iris table
- Throws:
IOException- if HTTP download or file/stream handling calls encounter problems
-
getQuandl
public static Table getQuandl(String database, String dataName, StatusCallback progress) throws IOException Tries datatables and time series sources to find the requested Quandl database and source. Also takes a StatusCallback object to allow status updates and/or progress bar tracking.- Parameters:
database- Quandl database namedataName- Quandl datatable or dataset nameprogress- A StatusCallback to log progress or update a progress bar- Returns:
- an Iris table
- Throws:
IOException- if HTTP download or file/stream handling calls encounter problems
-
getQuandl
Tries datatables and time series sources to find the requested Quandl database and source. Also takes a list of optional arguments to pass to the Quandl API.- Parameters:
database- Quandl database namedataName- Quandl datatable or dataset nameargs- Optional varargs of Quandl API arguments- Returns:
- an Iris table
- Throws:
IOException- if HTTP download or file/stream handling calls encounter problems
-
getQuandl
public static Table getQuandl(String database, String dataName, StatusCallback progress, String... args) throws IOException Tries datatables and time series sources to find the requested Quandl database and source. Also takes a StatusCallback object to allow status updates and/or progress bar tracking, and a list of optional arguments to pass to the Quandl API.- Parameters:
database- Quandl database namedataName- Quandl datatable or dataset nameprogress- A StatusCallback to log progress or update a progress barargs- Optional varargs of Quandl API arguments- Returns:
- an Iris table
- Throws:
IOException- if HTTP download or file/stream handling calls encounter problems
-
getQuandlTable
Creates a table from a Quandl datatable- Parameters:
database- Quandl database nametableName- Quandl datatable name- Returns:
- an Iris table
- Throws:
IOException- if HTTP download or file/stream handling calls encounter problems
-
getQuandlTable
public static Table getQuandlTable(String database, String tableName, StatusCallback progress) throws IOException Creates a table from a Quandl datatable, and also takes a StatusCallback object to update status or a progress bar.- Parameters:
database- Quandl database nametableName- Quandl datatable nameprogress- A StatusCallback to log progress or update a progress bar- Returns:
- an Iris table
- Throws:
IOException- if HTTP download or file/stream handling calls encounter problems
-
getQuandlTable
public static Table getQuandlTable(String database, String tableName, String... args) throws IOException Creates a table from a Quandl datatable, and also takes a list of optional arguments to pass to the Quandl API.- Parameters:
database- Quandl database nametableName- Quandl datatable nameargs- Optional varargs of Quandl API arguments- Returns:
- an Iris table
- Throws:
IOException- if HTTP download or file/stream handling calls encounter problems
-
getQuandlTable
public static Table getQuandlTable(String database, String tableName, StatusCallback progress, String... args) throws IOException Creates a table from a Quandl datatable, and also takes a StatusCallback object to update status or a progress bar, and a list of optional arguments to pass to the Quandl API.- Parameters:
database- Quandl database nametableName- Quandl datatable nameprogress- A StatusCallback to log progress or update a progress barargs- Optional varargs of Quandl API arguments- Returns:
- an Iris table object
- Throws:
IOException- if HTTP download or file/stream handling calls encounter problems
-
prepareArgs
Formats the http parameters list and adds the api_key, if it's not already included in the parameters- Parameters:
apiKey- an apiKey to append to the HTTP arguments string, if it's not already in the passed argumentsargs- a varargs list of HTTP arguments to include the final HTTP arguments string being formatted- Returns:
- a string of HTTP arguments to pass to the Quandl API get method
-
getQuandlTimeSeries
Returns a table for one or a group of Quandl datasets from the specified database and the name, name pattern, or name list specified for the dataset(s). Patterns use * for wildcard, while lists are comma-separated.- Parameters:
database- Quandl database namedataset- A Quandl dataset name, list, or pattern to match- Returns:
- an Iris table
- Throws:
IOException- if HTTP download or file/stream handling calls encounter problems
-
getQuandlTimeSeries
public static Table getQuandlTimeSeries(String database, String dataset, String... args) throws IOException Returns a table for one or a group of Quandl datasets from the specified database and the name, name pattern, or name list specified for the dataset(s). Patterns use * for wildcard, while lists are comma-separated. Also takes a list of optional arguments to pass to the Quandl API.- Parameters:
database- Quandl database namedataset- A Quandl dataset name, list, or pattern to matchargs- a varargs list of HTTP arguments to include the final HTTP arguments string being formatted- Returns:
- an Iris table
- Throws:
IOException- if HTTP download or file/stream handling calls encounter problems
-
getQuandlTimeSeries
public static Table getQuandlTimeSeries(String database, String dataset, StatusCallback progress) throws IOException Returns a table for one or a group of Quandl datasets from the specified database and the name, name pattern, or name list specified for the dataset(s). Patterns use * for wildcard, while lists are comma-separated.- Parameters:
database- Quandl database namedataset- A Quandl dataset name, list, or pattern to matchprogress- a StatusCallback that can be used to log progress events and/or update a progress bar; if passed null, a logging StatusCallback will be created.- Returns:
- an Iris table
- Throws:
IOException- if HTTP download or file/stream handling calls encounter problems
-
getQuandlTimeSeries
public static Table getQuandlTimeSeries(String database, String dataset, StatusCallback progress, String... args) throws IOException Returns a table for one or a group of Quandl datasets from the specified database and the name, name pattern, or name list specified for the dataset(s). Patterns use * for wildcard, while lists are comma-separated. Also takes a list of optional arguments to pass to the Quandl API.- Parameters:
database- Quandl database namedataset- A Quandl dataset name, list, or pattern to matchprogress- a StatusCallback that can be used to log progress events and/or update a progress bar; if passed null, a logging StatusCallback will be created.args- a varargs list of HTTP arguments to include the final HTTP arguments string being formatted- Returns:
- an Iris table
- Throws:
IOException- if HTTP download or file/stream handling calls encounter problemsRuntimeException- if dataset information can't be retrieved.
-
readQuandlZippedStream
Reads the first file (normally the only file) from inputstream representing a zipped file. This is used to handle, in-memory, zipped content downloaded from the Quandl API.- Parameters:
source- InputStream providing a zipped package, normally containing just one file- Returns:
- InputStream representing the first file from the zipped stream (source), or null if there is no file in the source InputStream.
- Throws:
IOException- if HTTP download or file/stream handling calls encounter problems
-
getQuandlCsvFile
public static void getQuandlCsvFile(org.apache.http.HttpResponse response, String httpGetString, StatusCallback progress, File csvFile) Downloads a Quandl CSV file based on the http get string passed in, and takes a StatusCallback object to update status and/or a progress bar, and a File object to write the downloaded data to.- Parameters:
response- an HttpResponse object holding the response from the Quandl API serverhttpGetString- the HTTP get string that was passed when calling the Quandl APIprogress- a StatusCallback that can be used to log progress events and/or update a progress bar; if passed null, a logging StatusCallback will be created.csvFile- a File object to which the downloaded CSV should be written
-
getQuandlCsvStream
public static InputStream getQuandlCsvStream(org.apache.http.HttpResponse response, String httpGetString, StatusCallback progress) Downloads a Quandl CSV file based on the http get string passed in, and takes a StatusCallback object to update status and/or a progress bar, and a File object to write the downloaded data to.- Parameters:
response- an HttpResponse object holding the response from the Quandl API serverhttpGetString- the HTTP get string that was passed when calling the Quandl API. If httpGetString is NULL, the results are expected to be un-zipped.progress- a StatusCallback that can be used to log progress events and/or update a progress bar; if passed null, a logging StatusCallback will be created.- Returns:
- a InputStream object providing access to the CSV data
-
getQuandlDatasets
Returns a table of Quandl dataset catalog information for the specified Quandl database.- Parameters:
database- Quandl database name for which to retrieve catalog information- Returns:
- an Iris table
- Throws:
IOException- if HTTP download or file/stream handling calls encounter problems
-
getQuandlDatasets
Returns a table of Quandl dataset catalog information for the specified Quandl database. Also takes a StatusCallback object to update status or a progress bar.- Parameters:
database- Quandl database name for which to retrieve catalog informationprogress- a StatusCallback that can be used to log progress events and/or update a progress bar- Returns:
- an Iris table
- Throws:
IOException- if HTTP download or file/stream handling calls encounter problems
-
getQuandlDatasets
public static Table getQuandlDatasets(String database, String dataset, String... args) throws IOException Returns a table of Quandl dataset catalog information for the specified Quandl database. Also takes a list of optional arguments to pass to the Quandl API.- Parameters:
database- Quandl database name for which to retrieve catalog informationdataset- A Quandl dataset name, list, or pattern to matchargs- a varargs list of HTTP arguments to include the final HTTP arguments string being formatted- Returns:
- an Iris table
- Throws:
IOException- if HTTP download or file/stream handling calls encounter problems
-
getQuandlDatasets
public static Table getQuandlDatasets(String database, String dataset, StatusCallback progress, String... args) throws IOException Returns a table of Quandl dataset catalog information for the specified Quandl database. Also takes a list of optional arguments to pass to the Quandl API, and a StatusCallback object to update status or a progress bar.- Parameters:
database- Quandl database name for which to retrieve catalog informationdataset- A Quandl dataset name, list, or pattern to matchprogress- a StatusCallback that can be used to log progress events and/or update a progress barargs- a varargs list of HTTP arguments to include the final HTTP arguments string being formatted- Returns:
- an Iris table
- Throws:
IOException- if HTTP download or file/stream handling calls encounter problems
-