From: David ‘Bombe’ Roden Date: Wed, 10 Jun 2009 21:22:56 +0000 (+0200) Subject: Add getReplies() method to return all replies from the plugin. X-Git-Tag: v0.1.1~49 X-Git-Url: https://git.pterodactylus.net/?p=jFCPlib.git;a=commitdiff_plain;h=4654ee7f03bd580815c1387b4da26eaa6ea3f367 Add getReplies() method to return all replies from the plugin. --- diff --git a/src/net/pterodactylus/fcp/FCPPluginReply.java b/src/net/pterodactylus/fcp/FCPPluginReply.java index 84faa54..f9dbc7f 100644 --- a/src/net/pterodactylus/fcp/FCPPluginReply.java +++ b/src/net/pterodactylus/fcp/FCPPluginReply.java @@ -20,6 +20,9 @@ package net.pterodactylus.fcp; import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; /** * The “FCPPluginReply” is sent by a plugin as a response to a @@ -85,6 +88,24 @@ public class FCPPluginReply extends BaseMessage { } /** + * Returns all replies from the plugin. The plugin sends replies as normal + * message fields prefixed by “Replies.”. The keys of the returned map do + * not contain this prefix! + * + * @return All replies from the plugin + */ + public Map getReplies() { + Map fields = getFields(); + Map replies = new HashMap(); + for (Entry field : fields.entrySet()) { + if (field.getKey().startsWith("Replies.")) { + replies.put(field.getKey().substring(8), field.getValue()); + } + } + return replies; + } + + /** * Returns the optional payload. * * @return The payload of the reply, or null if there is no