T - the type of elements of the JSON arraypublic class JsonArrayExtractor<T> extends AbstractIteratorExtractor<T>
endIndex, startIndex| Constructor and Description |
|---|
JsonArrayExtractor(com.google.gson.Gson gson)
Constructor that expects a JSON array to be returned directly
as response from a specified URL.
|
JsonArrayExtractor(com.google.gson.Gson gson,
String jsonQuery)
Constructor that expects a JSON array to be contained in the
HTTP response, navigating through the response via a specified query.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Closes potentially open readers/writers and finishes the Extraction process
if it is still ongoing.
|
Iterator<T> |
extractAll()
This method extracts everything there is to extract.
|
protected String |
getHashFromJson(com.google.gson.JsonElement json)
Retrieves a hash value from a JSON object.
|
protected List<T> |
getListFromJson(com.google.gson.JsonElement inputJson)
Parses a JSON object to retrieve a JSON array
and converts the array to a LinkedList.
|
String |
getUniqueVersionString()
Returns a string that can be hashed to generate a unique
identifier for the current version of the extractable elements.
|
String |
getUrl()
Retrieves the URL that is used to retrieve the JSON response.
|
void |
init(AbstractETL<?,?> etl)
Initializes the extractor for a new harvest.
|
void |
setUrl(String url)
Changes the URL that is used to retrieve the JSON response.
|
int |
size()
Returns the number of extractable documents, or -1 if they cannot
be estimated.
|
extractpublic JsonArrayExtractor(com.google.gson.Gson gson,
String jsonQuery)
gson - used to parse the JSON responsejsonQuery - a dot separated object structure at which the JSON array is expectedpublic JsonArrayExtractor(com.google.gson.Gson gson)
gson - used to parse the JSON responsepublic void init(AbstractETL<?,?> etl)
IExtractorinit in interface IExtractor<Iterator<T>>init in class AbstractIteratorExtractor<T>etl - the AbstractETL to which the extractor belongspublic Iterator<T> extractAll()
AbstractIteratorExtractorextractAll in class AbstractIteratorExtractor<T>public int size()
IExtractorsize in interface IExtractor<Iterator<T>>size in class AbstractIteratorExtractor<T>public String getUniqueVersionString()
IExtractorprotected String getHashFromJson(com.google.gson.JsonElement json)
json - the JSON object of which the hash is retrievedprotected List<T> getListFromJson(com.google.gson.JsonElement inputJson) throws ExtractorException
inputJson - the JSON object of which the list is retrievedExtractorException - thrown when the extraction failspublic void clear()
IExtractorpublic String getUrl()
public void setUrl(String url)
url - the new URLCopyright © 2017–2019. All rights reserved.