Package it.unipd.dei.eis.data.sources
Class TheGuardianDataSource
- java.lang.Object
-
- it.unipd.dei.eis.data.sources.DataSource<TheGuardianDataEntity,Object>
-
- it.unipd.dei.eis.data.sources.TheGuardianDataSource
-
public class TheGuardianDataSource extends DataSource<TheGuardianDataEntity,Object>
TheGuardianDataSource is the data source for The Guardian records. It contains the data source logic.
-
-
Field Summary
Fields Modifier and Type Field Description private static StringBASE_URLThe BASE_URL field is used to build the URL of the request.private static SimpleDateFormatDATE_FORMATThe dateFormat field is used to format the date.private static StringENV_API_KEYThe ENV_API_KEY field is used to get the API key from the environment variables.private static StringFIELDSThe FIELDS field is used to build the URL of the request.private okhttp3.OkHttpClienthttpClientThe httpClient field is used to send the HTTP request.static StringIDThe ID field is used to identify the data source.private static intMAX_PAGE_SIZEThe MAX_PAGE_SIZE field is used to limit the number of articles per page.private static StringRESPONSE_FORMATThe RESPONSE_FORMAT field is used to build the URL of the request.private static StringSEARCH_ENDPOINTThe SEARCH_ENDPOINT field is used to build the URL of the request.-
Fields inherited from class it.unipd.dei.eis.data.sources.DataSource
decoder, encoder, id
-
-
Constructor Summary
Constructors Constructor Description TheGuardianDataSource()The TheGuardianDataSource constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<TheGuardianDataEntity>getData(Context context)The get method is used to get the data from The Guardian API and deserialize it.-
Methods inherited from class it.unipd.dei.eis.data.sources.DataSource
get, set, setData
-
-
-
-
Field Detail
-
ID
public static final String ID
The ID field is used to identify the data source.- See Also:
- Constant Field Values
-
ENV_API_KEY
private static final String ENV_API_KEY
The ENV_API_KEY field is used to get the API key from the environment variables.
-
BASE_URL
private static final String BASE_URL
The BASE_URL field is used to build the URL of the request.- See Also:
- Constant Field Values
-
SEARCH_ENDPOINT
private static final String SEARCH_ENDPOINT
The SEARCH_ENDPOINT field is used to build the URL of the request.- See Also:
- Constant Field Values
-
RESPONSE_FORMAT
private static final String RESPONSE_FORMAT
The RESPONSE_FORMAT field is used to build the URL of the request.- See Also:
- Constant Field Values
-
FIELDS
private static final String FIELDS
The FIELDS field is used to build the URL of the request.- See Also:
- Constant Field Values
-
DATE_FORMAT
private static final SimpleDateFormat DATE_FORMAT
The dateFormat field is used to format the date.
-
MAX_PAGE_SIZE
private static final int MAX_PAGE_SIZE
The MAX_PAGE_SIZE field is used to limit the number of articles per page.- See Also:
- Constant Field Values
-
httpClient
private final okhttp3.OkHttpClient httpClient
The httpClient field is used to send the HTTP request.
-
-
Method Detail
-
getData
public List<TheGuardianDataEntity> getData(Context context)
The get method is used to get the data from The Guardian API and deserialize it. Pagination is processed in an asynchronous way using multiple threads.- Overrides:
getDatain classDataSource<TheGuardianDataEntity,Object>- Parameters:
context- the context of the request- Returns:
- the list of TheGuardianDataEntity objects
-
-