public class

Configuration

extends Object
java.lang.Object
   ↳ fm.audiobox.core.config.Configuration

Class Overview

Through this class you can control several behavior of the client such as HTTP client or JSON parser libraries.

Here a list of mandatory fields that must be set in order to set up the client:

Not configuring these parameters will result in a ConfigurationException.

TIP: Setter methods of this class are chainable.

Summary

Nested Classes
enum Configuration.Channels AudioBox channels  
enum Configuration.Env AudioBox environments. 
Public Constructors
Configuration()
Initiates a new Configuration ready for production.
Configuration(Configuration.Env environment)
Initiates a new Configuration.
Public Methods
void checkConfiguration()
Check configuration.
Class<? extends Albums> getAlbumsWrapperClass()
Gets the albums wrapper class.
String getApiKey()
Gets the API Consumer Key.
String getApiSecret()
Gets the API Consumer Secret.
String getApplicationName()
Gets the application name.
Class<? extends Artists> getArtistsWrapperClass()
Gets the artists wrapper class.
String getBaseUrl(Configuration.Channels channel, boolean secure)
Gets env base url based on the queried channel.
String getBaseUrl(Configuration.Channels channel)
Gets env base url based on the queried channel.
String getBaseUrl()
Gets API base url.
CredentialDataStore getCredentialDataStore()
Gets data store factory.
String getEnvHost(Configuration.Channels channel)
Gets Env base hostname
GenericUrl getEnvTokenUrl()
Gets env token url.
Configuration.Env getEnvironment()
Gets the environment.
Config getEnvironmentConfiguration(Configuration.Env environment)
Gets environment configuration.
synchronized ExceptionHandler getExceptionHandler()
Gets the configured ExceptionHandler
Class<? extends Genres> getGenresWrapperClass()
Gets the genres wrapper class.
HttpTransport getHttpTransport()
Gets HTTP transport.
JsonFactory getJsonFactory()
Gets JSON factory.
Class<? extends MediaFileWrapper> getMediaFileWrapperClass()
Gets the media file class.
Class<MediaFiles> getMediaFilesWrapperClass()
Gets the media files wrapper class.
CredentialRefreshListener getRefreshListener()
Gets the credential refresh listener.
String getUnsecureBaseUrl(Configuration.Channels channel)
Gets env base url based on the queried channel.
String getUserAgent()
Gets the user agent.
String getVersion()
Gets version.
Configuration setAlbumsWrapperClass(Class<Albums> klass)
Sets the albums wrapper class.
Configuration setApiKey(String apiKey)
Sets the API Consumer Key.
Configuration setApiSecret(String apiSecret)
Sets the API Consumer Secret.
Configuration setApplicationName(String applicationName)
Sets the application name.
Configuration setArtistsWrapperClass(Class<Artists> klass)
Sets the artists wrapper class.
Configuration setCredentialDataStore(CredentialDataStore credentialDataStore)
Sets the data store factory.
Configuration setCredentialRefreshListener(CredentialRefreshListener refreshListener)
Sets the credential refresh listener for the OAuth dance.
Configuration setEnvironment(Configuration.Env environment)
Changes the AudioBox environment (only useful in API development mode).
synchronized void setExceptionHandler(ExceptionHandler handler)
Sets a custom ExceptionHandler
Configuration setGenresWrapperClass(Class<Genres> klass)
Sets the genres wrapper class.
Configuration setHttpTransport(HttpTransport httpTransport)
Sets the HTTP transport.
Configuration setJsonFactory(JsonFactory jsonFactory)
Sets the JSON factory.
Configuration setMediaFileClass(Class<MediaFileWrapper> klass)
Sets the media file class.
Configuration setMediaFilesWrapperClass(Class<MediaFiles> klass)
Sets the media files wrapper class.
Configuration setVersion(String version)
Sets your application version.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Configuration ()

Initiates a new Configuration ready for production.

public Configuration (Configuration.Env environment)

Initiates a new Configuration.

Parameters
environment the to use.

Public Methods

public void checkConfiguration ()

Check configuration.

Throws
ConfigurationException the configuration exception

public Class<? extends Albums> getAlbumsWrapperClass ()

Gets the albums wrapper class.

Returns
  • the class to use for albums parsing.

public String getApiKey ()

Gets the API Consumer Key.

Returns
  • the API Consumer Key

public String getApiSecret ()

Gets the API Consumer Secret.

Returns
  • the API Consumer Secret

public String getApplicationName ()

Gets the application name.

Returns
  • the application name

public Class<? extends Artists> getArtistsWrapperClass ()

Gets the artists wrapper class.

Returns
  • the class to use for artists parsing.

public String getBaseUrl (Configuration.Channels channel, boolean secure)

Gets env base url based on the queried channel.

Parameters
channel the channel to query
secure whether to serve SSL protocol (if available for configured Environment) or not.
Returns
  • the env base url (no trailing slash)

public String getBaseUrl (Configuration.Channels channel)

Gets env base url based on the queried channel.

Parameters
channel the channel to query
Returns
  • the env base url (no trailing slash)

public String getBaseUrl ()

Gets API base url.

Returns
  • the env base url (no trailing slash)

public CredentialDataStore getCredentialDataStore ()

Gets data store factory.

Returns
  • the data store factory

public String getEnvHost (Configuration.Channels channel)

Gets Env base hostname

Parameters
channel the channel to query
Returns
  • the Env based host channel

public GenericUrl getEnvTokenUrl ()

Gets env token url.

Returns
  • the env token url

public Configuration.Env getEnvironment ()

Gets the environment.

Returns
  • the environment

public Config getEnvironmentConfiguration (Configuration.Env environment)

Gets environment configuration.

Parameters
environment the environment
Returns
  • the environment configuration

public synchronized ExceptionHandler getExceptionHandler ()

Gets the configured ExceptionHandler

Returns

public Class<? extends Genres> getGenresWrapperClass ()

Gets the genres wrapper class.

Returns
  • the class to use for genres parsing.

public HttpTransport getHttpTransport ()

Gets HTTP transport.

Returns
  • the HTTP transport

public JsonFactory getJsonFactory ()

Gets JSON factory.

Returns
  • the JSON factory

public Class<? extends MediaFileWrapper> getMediaFileWrapperClass ()

Gets the media file class.

Returns
  • the class to use for media file parsing.

public Class<MediaFiles> getMediaFilesWrapperClass ()

Gets the media files wrapper class.

Returns
  • the class to use for media files parsing.

public CredentialRefreshListener getRefreshListener ()

Gets the credential refresh listener.

Returns
  • the configured com.google.api.client.auth.oauth2.CredentialRefreshListener

public String getUnsecureBaseUrl (Configuration.Channels channel)

Gets env base url based on the queried channel.

Parameters
channel the channel to query
Returns
  • the env base url (no trailing slash)

public String getUserAgent ()

Gets the user agent.

Returns
  • the user agent

public String getVersion ()

Gets version.

Returns
  • the version

public Configuration setAlbumsWrapperClass (Class<Albums> klass)

Sets the albums wrapper class.

Use this configuration method to set your own class to use as albums parser.

Default is Albums.

Parameters
klass the class to use for albums parsing.
Returns

public Configuration setApiKey (String apiKey)

Sets the API Consumer Key.

To get one register your application here: https://audiobox.fm/oauth2/applications

Parameters
apiKey the API Consumer Key
Returns

public Configuration setApiSecret (String apiSecret)

Sets the API Consumer Secret.

To get one register your application here: https://audiobox.fm/oauth2/applications

Parameters
apiSecret the API Consumer Secret
Returns

public Configuration setApplicationName (String applicationName)

Sets the application name.

Parameters
applicationName the application name
Returns

public Configuration setArtistsWrapperClass (Class<Artists> klass)

Sets the artists wrapper class.

Use this configuration method to set your own class to use as artists parser.

Default is Artists.

Parameters
klass the class to use for artists parsing.
Returns

public Configuration setCredentialDataStore (CredentialDataStore credentialDataStore)

Sets the data store factory.

You should provide one like FileDataStoreFactory, MemoryDataStoreFactory or implementing one by extending the com.google.api.client.util.store.AbstractDataStoreFactory.

Parameters
credentialDataStore the data store factory
Returns

public Configuration setCredentialRefreshListener (CredentialRefreshListener refreshListener)

Sets the credential refresh listener for the OAuth dance.

Parameters
refreshListener the com.google.api.client.auth.oauth2.CredentialRefreshListener to set
Returns

public Configuration setEnvironment (Configuration.Env environment)

Changes the AudioBox environment (only useful in API development mode).

Do not use this method if you are working on a production application.

Returns

public synchronized void setExceptionHandler (ExceptionHandler handler)

Sets a custom ExceptionHandler

Parameters
handler the ExceptionHandler to use for next (and subsequent) request.

public Configuration setGenresWrapperClass (Class<Genres> klass)

Sets the genres wrapper class.

Use this configuration method to set your own class to use as genres parser.

Default is Genres.

Parameters
klass the class to use for genres parsing.
Returns

public Configuration setHttpTransport (HttpTransport httpTransport)

Sets the HTTP transport.

Should be one of:

  • NetHttpTransport: based on HttpURLConnection that is found in all Java SDKs, and thus usually the simplest choice.
  • ApacheHttpTransport: based on the popular Apache HttpClient that allows for more customization.
  • UrlFetchTransport: based on URL Fetch Java API in the Google App Engine SDK

Parameters
httpTransport the http transport
Returns

public Configuration setJsonFactory (JsonFactory jsonFactory)

Sets the JSON factory.

Should be one of:

  • JacksonFactory: based on the popular Jackson library which is considered the fastest in terms of parsing/serialization speed
  • GsonFactory: based on the Google GSON library which is a lighter-weight option (small size) that is pretty fast also (though not quite as fast as Jackson)
  • AndroidJsonFactory: based on the JSON library built-in to Android Honeycomb (SDK 3.0) or higher that is identical to the Google GSON library

Parameters
jsonFactory the json factory
Returns

public Configuration setMediaFileClass (Class<MediaFileWrapper> klass)

Sets the media file class.

Use this configuration method to set your own class to use for media file parsing.

Default is MediaFileWrapper.

Parameters
klass the class to use for artists parsing.
Returns

public Configuration setMediaFilesWrapperClass (Class<MediaFiles> klass)

Sets the media files wrapper class.

Use this configuration method to set your own class to use as media files parser.

Default is MediaFiles.

Parameters
klass the class to use for media files parsing.
Returns

public Configuration setVersion (String version)

Sets your application version.

Parameters
version the version string
Returns