T - the type of the data that is expected from the REST endpoint.public class RestSource<T> extends InputStreamDataReader<T> implements WritableDataReader<T>
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
requestMade |
| Constructor and Description |
|---|
RestSource()
Create a new RestSource
|
RestSource(java.lang.String host,
InputStreamConverter<T> converter)
Create a new RestSource and specifies the endpoint and the converter
|
| Modifier and Type | Method and Description |
|---|---|
java.io.InputStream |
createInputStream()
Create the inputstream for this request.
|
protected void |
createRequest() |
T |
get()
Obtain the next entity of data.
|
java.lang.String |
getConsumerKey()
Return the consumer key (used with oauth) for this request
|
java.lang.String |
getConsumerSecret()
Return the consumer secret (if used with oauth) for this request
|
java.lang.String |
getContentType() |
java.lang.String |
getDataString()
Return the datastring that will be send with this request
|
MultiValuedMap |
getFormParams()
Return a
MultiValuedMap for the form parameters in this request. |
java.util.Map<java.lang.String,java.lang.String> |
getQueryParams()
Return the query parameters as a
Map |
java.lang.String |
getRequestMethod()
Return the request method for this request.
|
java.util.Map<java.lang.String,java.lang.String> |
getRequestProperties()
Return the request properties as a
Map |
int |
getTimeout()
Get the timeout value specified for this instance
|
boolean |
next()
Check if more data is available on this DataReader.
|
void |
setConsumerKey(java.lang.String consumerKey)
Set the consumer key for this request.
|
void |
setConsumerSecret(java.lang.String consumerSecret)
Set the consumer secret
|
void |
setContentType(java.lang.String contentType)
Set the contentType for this request.
|
void |
setDataString(java.lang.String dataString)
Explicitly set the datastring for this request.
|
void |
setFormParams(java.util.Map<java.lang.String,java.lang.String> formParams)
Set the form parameters as a
Map. |
void |
setFormParams(MultiValuedMap formParams)
Set the form parameters as a
MultiValuedMap |
void |
setHost(java.lang.String host)
Set the host parameter for this endpoint.
|
void |
setPath(java.lang.String path)
Explicitly sets the path for this resource.
|
void |
setQueryParams(java.util.Map<java.lang.String,java.lang.String> queryParams)
Set the query parameters as a
Map |
void |
setRequestMethod(java.lang.String requestMethod)
Set the request method for this request as a
String
(e.g. |
void |
setRequestProperties(java.util.Map<java.lang.String,java.lang.String> requestProperties)
Set the request properties as a
Map |
void |
setTimeout(int timeout)
Set the timeout value for this instance.
|
void |
writeBack()
Initiates the writeback call.
|
getConverter, getInputStream, setConverter, setInputStreamiteratorpublic RestSource()
public RestSource(java.lang.String host,
InputStreamConverter<T> converter)
host - the host parameter of the endpointconverter - the Converter that will be used to convert the
raw data into Java objects of type T.public void setHost(java.lang.String host)
host - the host parameter for this endpoint.public void setPath(java.lang.String path)
path - the path. If null, the path will be the empty Stringprotected void createRequest()
public T get()
DataReaderget in interface DataReader<T>get in class InputStreamDataReader<T>public boolean next()
DataReadernext in interface DataReader<T>next in class InputStreamDataReader<T>public java.io.InputStream createInputStream()
throws java.io.IOException
InputStreamjava.io.IOException - in case the InputStream cannot be created
successfully.public java.lang.String getConsumerKey()
public void setConsumerKey(java.lang.String consumerKey)
consumerKey - the consumerKey to setpublic java.lang.String getConsumerSecret()
public void setConsumerSecret(java.lang.String consumerSecret)
consumerSecret - the consumerSecret to setpublic java.util.Map<java.lang.String,java.lang.String> getRequestProperties()
Mappublic void setRequestProperties(java.util.Map<java.lang.String,java.lang.String> requestProperties)
MaprequestProperties - the requestProperties to setpublic java.util.Map<java.lang.String,java.lang.String> getQueryParams()
Mappublic void setQueryParams(java.util.Map<java.lang.String,java.lang.String> queryParams)
MapqueryParams - the queryParams to set. If null, this call is ignoredpublic MultiValuedMap getFormParams()
MultiValuedMap for the form parameters in this request.public void setFormParams(java.util.Map<java.lang.String,java.lang.String> formParams)
Map. This is a convenience method,
as form parameters can also be passed as a MultiValuedMapformParams - the formParams to setpublic void setFormParams(MultiValuedMap formParams)
MultiValuedMapformParams - the formParams to setpublic java.lang.String getDataString()
public void setDataString(java.lang.String dataString)
dataString - the dataString to setpublic java.lang.String getRequestMethod()
public void setRequestMethod(java.lang.String requestMethod)
String
(e.g. "POST", "GET")requestMethod - the requestMethod to setpublic void writeBack()
WritableDataReaderwriteBack in interface WritableDataReader<T>public int getTimeout()
public void setTimeout(int timeout)
timeout - the timeout valuepublic java.lang.String getContentType()
public void setContentType(java.lang.String contentType)
contentType - the contentType to set