public static void main(String[] args) { Callee1 c1 = new Callee1(); Callee2 c2 = new Callee2(); MyIncrement.f(c2); Caller caller1 = new Caller(c1); Caller caller2 = new Caller(c2.getCallbackReference()); caller1.go(); caller1.go(); caller2.go(); caller2.go(); }
/** * Retrieves detailed artist info for the given artist or mbid entry. * * @param artistOrMbid Name of the artist or an mbid * @param locale The language to fetch info in, or <code>null</code> * @param apiKey The API key * @return detailed artist info */ public static final Artist getInfo( final Context context, final String artistOrMbid, final Locale locale, final String apiKey) { final Map<String, String> mParams = new WeakHashMap<String, String>(); mParams.put("artist", artistOrMbid); if (locale != null && locale.getLanguage().length() != 0) { mParams.put("lang", locale.getLanguage()); } final Result mResult = Caller.getInstance(context).call("artist.getInfo", apiKey, mParams); return ResponseBuilder.buildItem(mResult, Artist.class); }
/** * Get the tags applied by an individual user to an album on Last.fm. * * @param artist The artist name in question * @param album The album name in question * @param session A Session instance * @return a list of tags */ public static Collection<String> getTags(String artist, String album, Session session) { Result result = Caller.getInstance().call("album.getTags", session, "artist", artist, "album", album); if (!result.isSuccessful()) return Collections.emptyList(); DomElement element = result.getContentElement(); Collection<String> tags = new ArrayList<String>(); for (DomElement domElement : element.getChildren("tag")) { tags.add(domElement.getChildText("name")); } return tags; }
/** * Get the metadata for an album on Last.fm using the album name or a musicbrainz id. See * playlist.fetch on how to get the album playlist. * * @param artist Artist's name * @param albumOrMbid Album name or MBID * @param apiKey The API key * @return Album metadata */ public static Album getInfo(String artist, String albumOrMbid, String apiKey) { Map<String, String> params = new HashMap<String, String>(); if (StringUtilities.isMbid(albumOrMbid)) { params.put("mbid", albumOrMbid); } else { params.put("artist", artist); params.put("album", albumOrMbid); } Result result = Caller.getInstance().call("album.getInfo", apiKey, params); DomElement element = result.getContentElement(); return albumFromElement(element); }
/** * Get the metadata for an album on Last.fm using the album name or a musicbrainz id. See * playlist.fetch on how to get the album playlist. * * @param artist Artist's name * @param albumOrMbid Album name or MBID * @param username The username for the context of the request. If supplied, the user's playcount * for this album is included in the response. * @param apiKey The API key * @return Album metadata */ public static final Album getInfo( final Context context, final String artist, final String albumOrMbid, final String username, final String apiKey) { final Map<String, String> params = new HashMap<String, String>(); params.put("artist", artist); params.put("album", albumOrMbid); MapUtilities.nullSafePut(params, "username", username); final Result result = Caller.getInstance(context).call("album.getInfo", apiKey, params); return ResponseBuilder.buildItem(result, Album.class); }
public static PaginatedResult<User> getMembers(String group, int page, String apiKey) { Result result = Caller.getInstance() .call("group.getMembers", apiKey, "group", group, "page", String.valueOf(page)); if (!result.isSuccessful()) return new PaginatedResult<User>(0, 0, Collections.<User>emptyList()); DomElement root = result.getContentElement(); Collection<DomElement> children = root.getChildren("user"); List<User> users = new ArrayList<User>(children.size()); for (DomElement child : children) { users.add(User.userFromElement(child)); } page = Integer.parseInt(root.getAttribute("page")); int total = Integer.parseInt(root.getAttribute("totalPages")); return new PaginatedResult<User>(page, total, users); }
/** * Use the last.fm corrections data to check whether the supplied artist has a correction to a * canonical artist. This method returns a new {@link Artist} object containing the corrected * data, or <code>null</code> if the supplied Artist was not found. * * @param artist The artist name to correct * @return a new {@link Artist}, or <code>null</code> */ public static final Artist getCorrection(final Context context, final String artist) { Result result = null; try { result = Caller.getInstance(context).call("artist.getCorrection", "<key>", "artist", artist); if (!result.isSuccessful()) { return null; } final DomElement correctionElement = result.getContentElement().getChild("correction"); if (correctionElement == null) { return new Artist(artist, null); } final DomElement artistElem = correctionElement.getChild("artist"); return FACTORY.createItemFromElement(artistElem); } catch (final Exception ignored) { return null; } }
/** @see hk.hku.cecid.piazza.commons.util.Logger#fatal(java.lang.Object) */ public void fatal(Object msg) { (logger == null ? Logger.getLogger(Caller.getName()) : logger).fatal(msg); }
/** @see hk.hku.cecid.piazza.commons.util.Logger#error(java.lang.Object) */ public void error(Object msg) { (logger == null ? Logger.getLogger(Caller.getName()) : logger).error(msg); }
/** @see hk.hku.cecid.piazza.commons.util.Logger#debug(java.lang.Object) */ public void debug(Object msg) { (logger == null ? Logger.getLogger(Caller.getName()) : logger).debug(msg); }
/** * Tag an album using a list of user supplied tags.<br> * * @param artist The artist name in question * @param album The album name in question * @param tags A comma delimited list of user supplied tags to apply to this album. Accepts a * maximum of 10 tags. * @param session The Session instance * @return the Result of the operation * @see Authenticator */ public static Result addTags(String artist, String album, String tags, Session session) { return Caller.getInstance() .call("album.addTags", session, "artist", artist, "album", album, "tags", tags); }
public void logStackTrace(Throwable throwable) { (logger == null ? Logger.getLogger(Caller.getName()) : logger).fatal(throwable); }
/** @see hk.hku.cecid.piazza.commons.util.Logger#info(java.lang.Object, java.lang.Throwable) */ public void info(Object msg, Throwable throwable) { (logger == null ? Logger.getLogger(Caller.getName()) : logger).info(msg, throwable); }
public void setPhoneNumber(IPhonenumber phonenumber) { super.setPhoneNumber(phonenumber); this.addPhonenumber(phonenumber); }
/** @see hk.hku.cecid.piazza.commons.util.Logger#warn(java.lang.Object) */ public void warn(Object msg) { (logger == null ? Logger.getLogger(Caller.getName()) : logger).warn(msg); }
/** @see hk.hku.cecid.piazza.commons.util.Logger#info(java.lang.Object) */ public void info(Object msg) { (logger == null ? Logger.getLogger(Caller.getName()) : logger).info(msg); }
/** * Remove a user's tag from an album. * * @param artist The artist name in question * @param album The album name in question * @param tag A single user tag to remove from this album. * @param session The Session instance * @return the Result of the operation * @see Authenticator */ public static Result removeTag(String artist, String album, String tag, Session session) { return Caller.getInstance() .call("album.removeTag", session, "artist", artist, "album", album, "tag", tag); }
/** * Checks if the logger itself is in debug mode. * * @return true if the logger itself is in debug mode. */ public boolean isDebugEnabled() { return (logger == null ? Logger.getLogger(Caller.getName()) : logger).isDebugEnabled(); }
/** * Sets the state of one of the components in the progress window. This method doesn't need to be * invoked from the <cite>Swing</cite> thread. * * @param task The value to change as one of the {@link Caller#TITLE} or {@link Caller#LABEL} * constants. * @param value The new value. */ private void set(final int task, final Object value) { final Caller caller = new Caller(task); caller.value = value; EventQueue.invokeLater(caller); }