2 * jSite2 - FCPPluginReply.java -
3 * Copyright © 2008 David Roden
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 package net.pterodactylus.fcp;
22 import java.io.InputStream;
25 * The “FCPPluginReply” is sent by a plugin as a response to a
26 * {@link FCPPluginMessage} message.
28 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
31 public class FCPPluginReply extends BaseMessage {
33 /** The payload input stream. */
34 private final InputStream payloadInputStream;
37 * Creates a new “FCPPluginReply” message that wraps the received message.
39 * @param receivedMessage
40 * The received message
41 * @param payloadInputStream
42 * The optional input stream for the payload
44 FCPPluginReply(FcpMessage receivedMessage, InputStream payloadInputStream) {
45 super(receivedMessage);
46 this.payloadInputStream = payloadInputStream;
50 * Returns the name of the plugin.
52 * @return The name of the plugin
54 public String getPluginName() {
55 return getField("PluginName");
59 * Returns the identifier of the request.
61 * @return The identifier of the request
63 public String getIdentifier() {
64 return getField("Identifier");
68 * Returns the length of the optional payload.
70 * @return The length of the payload, or <code>-1</code> if there is no
71 * payload or the length could not be parsed
73 public long getDataLength() {
74 return FcpUtils.safeParseLong(getField("DataLength"));
78 * Returns a reply from the plugin.
81 * The name of the reply
82 * @return The value of the reply
84 public String getReply(String key) {
85 return getField("Replies." + key);
89 * Returns the optional payload.
91 * @return The payload of the reply, or <code>null</code> if there is no
94 public InputStream getPayloadInputStream() {
95 return payloadInputStream;