X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Ffcp%2FFCPPluginReply.java;h=c3b5281bba8b81de42224eaf0c269021f5de81ce;hb=dd605aee444057a874fabf7fb0045b8448b0d1cd;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..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,13 +19,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 +36,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 +49,7 @@ public class FCPPluginReply extends BaseMessage { /** * Returns the name of the plugin. - * + * * @return The name of the plugin */ public String getPluginName() { @@ -57,7 +58,7 @@ public class FCPPluginReply extends BaseMessage { /** * Returns the identifier of the request. - * + * * @return The identifier of the request */ public String getIdentifier() { @@ -66,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 */ @@ -76,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 @@ -86,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 */