Package de.umass.lastfm
Class Caller
java.lang.Object
de.umass.lastfm.Caller
The
Direct usage of this class should be unnecessary since all method calls are available via the methods in the
Supports the setting of a custom
Caller class handles the low-level communication between the client and last.fm.Direct usage of this class should be unnecessary since all method calls are available via the methods in the
Artist, Album, User, etc. classes.
If specialized calls which are not covered by the Java API are necessary this class may be used directly.Supports the setting of a custom
Proxy and a custom User-Agent HTTP header.- Author:
- Janni Kovacs
-
Method Summary
Modifier and TypeMethodDescriptiongetCache()Returns the currentCache.static CallerReturns the single instance of theCallerclass.Returns theResultof the last operation, ornullif no call operation has been performed yet.getProxy()booleanopenConnection(String url) Creates a newHttpURLConnection, sets the proxy, if available, and sets the User-Agent property.voidsetApiRootUrl(String apiRootUrl) Set api root url.voidSets the activeCache.voidsetDebugMode(boolean debugMode) Sets thedebugModeproperty.voidSets aProxyinstance this Caller will use for all upcoming HTTP requests.voidsetUserAgent(String userAgent) Sets a User Agent this Caller will use for all upcoming HTTP requests.
-
Method Details
-
getInstance
Returns the single instance of theCallerclass.- Returns:
- a
Caller
-
setApiRootUrl
Set api root url.- Parameters:
apiRootUrl- new api root url
-
setProxy
Sets aProxyinstance this Caller will use for all upcoming HTTP requests. May benull.- Parameters:
proxy- AProxyornull.
-
setUserAgent
Sets a User Agent this Caller will use for all upcoming HTTP requests. For testing purposes use "tst". If you distribute your application use an identifiable User-Agent.- Parameters:
userAgent- a User-Agent string
-
setDebugMode
public void setDebugMode(boolean debugMode) Sets thedebugModeproperty. IfdebugModeistrueall call() methods will print debug information and error messages on failure to stdout and stderr respectively.
Default isfalse. Set this totruewhile in development and for troubleshooting.- Parameters:
debugMode-trueto enable debug mode
-
getCache
Returns the currentCache.- Returns:
- the Cache
-
setCache
Sets the activeCache. May benullto disable caching.- Parameters:
cache- the new Cache ornull
-
call
- Throws:
CallException
-
call
- Throws:
CallException
-
call
-
call
-
getLastResult
Returns theResultof the last operation, ornullif no call operation has been performed yet.- Returns:
- the last Result object
-
openConnection
Creates a newHttpURLConnection, sets the proxy, if available, and sets the User-Agent property.- Parameters:
url- URL to connect to- Returns:
- a new connection.
- Throws:
IOException- if an I/O exception occurs.
-
getProxy
-
getUserAgent
-
isDebugMode
public boolean isDebugMode()
-