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>
30 public class FCPPluginReply extends BaseMessage {
32 /** The payload input stream. */
33 private final InputStream payloadInputStream;
36 * Creates a new “FCPPluginReply” message that wraps the received message.
38 * @param receivedMessage
39 * The received message
40 * @param payloadInputStream
41 * The optional input stream for the payload
43 FCPPluginReply(FcpMessage receivedMessage, InputStream payloadInputStream) {
44 super(receivedMessage);
45 this.payloadInputStream = payloadInputStream;
49 * Returns the name of the plugin.
51 * @return The name of the plugin
53 public String getPluginName() {
54 return getField("PluginName");
58 * Returns the identifier of the request.
60 * @return The identifier of the request
62 public String getIdentifier() {
63 return getField("Identifier");
67 * Returns the length of the optional payload.
69 * @return The length of the payload, or <code>-1</code> if there is no
70 * payload or the length could not be parsed
72 public long getDataLength() {
73 return FcpUtils.safeParseLong(getField("DataLength"));
77 * Returns a reply from the plugin.
80 * The name of the reply
81 * @return The value of the reply
83 public String getReply(String key) {
84 return getField("Replies." + key);
88 * Returns the optional payload.
90 * @return The payload of the reply, or <code>null</code> if there is no
93 public InputStream getPayloadInputStream() {
94 return payloadInputStream;