public class Caller
extends java.lang.Object
Caller class handles the low-level communication between the client and last.fm.Artist, Album, User, etc. classes.
If specialized calls which are not covered by the Java API are necessary this class may be used directly.Proxy and a custom User-Agent HTTP header.| Modifier and Type | Method and Description |
|---|---|
Result |
call(java.lang.String method,
Session session,
java.util.Map<java.lang.String,java.lang.String> params) |
Result |
call(java.lang.String method,
Session session,
java.lang.String... params) |
Result |
call(java.lang.String method,
java.lang.String apiKey,
java.util.Map<java.lang.String,java.lang.String> params) |
Result |
call(java.lang.String method,
java.lang.String apiKey,
java.lang.String... params) |
Cache |
getCache()
Returns the current
Cache. |
static Caller |
getInstance()
Returns the single instance of the
Caller class. |
Result |
getLastResult()
Returns the
Result of the last operation, or null if no call operation has been
performed yet. |
java.net.Proxy |
getProxy() |
java.lang.String |
getUserAgent() |
boolean |
isDebugMode() |
java.net.HttpURLConnection |
openConnection(java.lang.String url)
Creates a new
HttpURLConnection, sets the proxy, if available, and sets the User-Agent property. |
void |
setApiRootUrl(java.lang.String apiRootUrl)
Set api root url.
|
void |
setCache(Cache cache)
Sets the active
Cache. |
void |
setDebugMode(boolean debugMode)
Sets the
debugMode property. |
void |
setProxy(java.net.Proxy proxy)
Sets a
Proxy instance this Caller will use for all upcoming HTTP requests. |
void |
setUserAgent(java.lang.String userAgent)
Sets a User Agent this Caller will use for all upcoming HTTP requests.
|
public static Caller getInstance()
Caller class.Callerpublic void setApiRootUrl(java.lang.String apiRootUrl)
apiRootUrl - new api root urlpublic void setProxy(java.net.Proxy proxy)
Proxy instance this Caller will use for all upcoming HTTP requests. May be null.proxy - A Proxy or null.public void setUserAgent(java.lang.String userAgent)
userAgent - a User-Agent stringpublic void setDebugMode(boolean debugMode)
debugMode property. If debugMode is true all call() methods
will print debug information and error messages on failure to stdout and stderr respectively.false. Set this to true while in development and for troubleshooting.debugMode - true to enable debug modepublic void setCache(Cache cache)
Cache. May be null to disable caching.cache - the new Cache or nullpublic Result call(java.lang.String method, java.lang.String apiKey, java.lang.String... params) throws CallException
CallExceptionpublic Result call(java.lang.String method, java.lang.String apiKey, java.util.Map<java.lang.String,java.lang.String> params) throws CallException
CallExceptionpublic Result call(java.lang.String method, Session session, java.util.Map<java.lang.String,java.lang.String> params)
public Result getLastResult()
Result of the last operation, or null if no call operation has been
performed yet.public java.net.HttpURLConnection openConnection(java.lang.String url)
throws java.io.IOException
HttpURLConnection, sets the proxy, if available, and sets the User-Agent property.url - URL to connect tojava.io.IOException - if an I/O exception occurs.public java.net.Proxy getProxy()
public java.lang.String getUserAgent()
public boolean isDebugMode()