X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Ffcp%2FFCPPluginReply.java;h=c3b5281bba8b81de42224eaf0c269021f5de81ce;hb=e0d4c56493b97a16514ca865cad0ae42a2d8a5a2;hp=84faa540b2e66a07771d7cc6e863ff73cb6d536d;hpb=64c2c9bd494f3ea9d1ae84f8d86827dea025bee6;p=jFCPlib.git
diff --git a/src/net/pterodactylus/fcp/FCPPluginReply.java b/src/net/pterodactylus/fcp/FCPPluginReply.java
index 84faa54..c3b5281 100644
--- a/src/net/pterodactylus/fcp/FCPPluginReply.java
+++ b/src/net/pterodactylus/fcp/FCPPluginReply.java
@@ -1,6 +1,5 @@
/*
- * jSite2 - FCPPluginReply.java -
- * Copyright © 2008 David Roden
+ * jFCPlib - FCPPluginReply.java - Copyright © 2008 David Roden
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,11 +19,14 @@
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>
*/
public class FCPPluginReply extends BaseMessage {
@@ -34,7 +36,7 @@ public class FCPPluginReply extends BaseMessage {
/**
* Creates a new âFCPPluginReplyâ message that wraps the received message.
- *
+ *
* @param receivedMessage
* The received message
* @param payloadInputStream
@@ -47,7 +49,7 @@ public class FCPPluginReply extends BaseMessage {
/**
* Returns the name of the plugin.
- *
+ *
* @return The name of the plugin
*/
public String getPluginName() {
@@ -56,7 +58,7 @@ public class FCPPluginReply extends BaseMessage {
/**
* Returns the identifier of the request.
- *
+ *
* @return The identifier of the request
*/
public String getIdentifier() {
@@ -65,7 +67,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
*/
@@ -75,7 +77,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
@@ -85,8 +87,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
*/