net.dontdrinkandroot.lastfm.api.ws.fetcher

## Class DefaultFetcher

- java.lang.Object
- - net.dontdrinkandroot.lastfm.api.ws.fetcher.AbstractFetcher
  - - net.dontdrinkandroot.lastfm.api.ws.fetcher.DefaultFetcher

All Implemented Interfaces:
  Fetcher

    public class DefaultFetcher
    extends AbstractFetcher
    implements Fetcher

This class is responsible for actually fetching the data from last.fm and converting it to a dom Document.

Author:
  Philip W. Sorst

### Field Summary

### Fields inherited from class net.dontdrinkandroot.lastfm.api.ws.fetcher.AbstractFetcher

`baseUrl, factory, logger`

### Constructor Summary

Constructors
Constructor and Description
`DefaultFetcher()`

### Method Summary

Methods
`protected LastfmResponse` `fetchResponse(HttpURLConnection conn)`
`LastfmResponse` `get(Map<String,String> parameters)` Perform a get request to the Last.fm API.
`double` `getWebRequestsPerSecond()` Get the current number of requests per second.
`LastfmResponse` `post(Map<String,String> parameters)` Perform a post request to the Last.fm API.

### Methods inherited from class net.dontdrinkandroot.lastfm.api.ws.fetcher.AbstractFetcher

`buildParameterString, buildUrl, openConnection, parseDoc`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### DefaultFetcher

    public DefaultFetcher()
                   throws ParserConfigurationException

Throws:
  `ParserConfigurationException`

### Method Detail

#### get

    public LastfmResponse get(Map<String,String> parameters)
                       throws LastfmWebServicesException

Description copied from interface: `Fetcher`
Perform a get request to the Last.fm API.

Specified by:
  `get` in interface `Fetcher`
Parameters:
  `parameters` - A Key/Value map of HTTP parameters.
Returns:
  The response returned from Last.fm.
Throws:
  `LastfmWebServicesException` - Thrown on any fetching errors encountered.

#### post

    public LastfmResponse post(Map<String,String> parameters)
                        throws LastfmWebServicesException

Description copied from interface: `Fetcher`
Perform a post request to the Last.fm API.

Specified by:
  `post` in interface `Fetcher`
Parameters:
  `parameters` - A Key/Value map of HTTP parameters.
Returns:
  The response returned from Last.fm.
Throws:
  `LastfmWebServicesException` - Thrown on any fetching errors encountered.

#### getWebRequestsPerSecond

    public final double getWebRequestsPerSecond()

Description copied from interface: `Fetcher`
Get the current number of requests per second. The returned value depends on the implementation and can mean the requests/sec over a specific interval or overall.

Specified by:
  `getWebRequestsPerSecond` in interface `Fetcher`
Returns:
  The number of requests that this fetcher performed per second.

#### fetchResponse

    protected LastfmResponse fetchResponse(HttpURLConnection conn)
                                    throws LastfmWebServicesException

Throws:
  `LastfmWebServicesException`