From 4654ee7f03bd580815c1387b4da26eaa6ea3f367 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 10 Jun 2009 23:22:56 +0200 Subject: [PATCH] Add getReplies() method to return all replies from the plugin. --- src/net/pterodactylus/fcp/FCPPluginReply.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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 -- 2.7.4