X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Ffcp%2FFCPPluginReply.java;h=df46925b5a5bdf0ffcff071587d37fbe0b5028e4;hb=6f61169f77b19521bb123b4f1151ec1fab7a0f3b;hp=271b8d73fb2e3aa4a7ecbc13af70dc31e6e07188;hpb=f553531be78d6d6d95dc152728f2b8d40242b57d;p=jFCPlib.git
diff --git a/src/net/pterodactylus/fcp/FCPPluginReply.java b/src/net/pterodactylus/fcp/FCPPluginReply.java
index 271b8d7..df46925 100644
--- a/src/net/pterodactylus/fcp/FCPPluginReply.java
+++ b/src/net/pterodactylus/fcp/FCPPluginReply.java
@@ -20,13 +20,15 @@
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
* {@link FCPPluginMessage} message.
- *
+ *
* @author David âBombeâ Roden <bombe@freenetproject.org>
- * @version $Id$
*/
public class FCPPluginReply extends BaseMessage {
@@ -35,7 +37,7 @@ public class FCPPluginReply extends BaseMessage {
/**
* Creates a new âFCPPluginReplyâ message that wraps the received message.
- *
+ *
* @param receivedMessage
* The received message
* @param payloadInputStream
@@ -48,7 +50,7 @@ public class FCPPluginReply extends BaseMessage {
/**
* Returns the name of the plugin.
- *
+ *
* @return The name of the plugin
*/
public String getPluginName() {
@@ -57,7 +59,7 @@ public class FCPPluginReply extends BaseMessage {
/**
* Returns the identifier of the request.
- *
+ *
* @return The identifier of the request
*/
public String getIdentifier() {
@@ -66,7 +68,7 @@ public class FCPPluginReply extends BaseMessage {
/**
* Returns the length of the optional payload.
- *
+ *
* @return The length of the payload, or -1
if there is no
* payload or the length could not be parsed
*/
@@ -76,7 +78,7 @@ public class FCPPluginReply extends BaseMessage {
/**
* Returns a reply from the plugin.
- *
+ *
* @param key
* The name of the reply
* @return The value of the reply
@@ -86,8 +88,26 @@ 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
* payload
*/