Update license to GPLv3, fix header comments
[jFCPlib.git] / src / main / java / net / pterodactylus / fcp / FCPPluginMessage.java
1 /*
2  * jFCPlib - FCPPluginMessage.java - Copyright © 2008–2016 David Roden
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 package net.pterodactylus.fcp;
19
20 import java.io.InputStream;
21
22 /**
23  * An “CPPluginMessage” sends a message with custom parameters and (optional)
24  * payload to a plugin.
25  *
26  * @author David ‘Bombe’ Roden &lt;bombe@freenetproject.org&gt;
27  */
28 public class FCPPluginMessage extends FcpMessage {
29
30         /**
31          * @deprecated Use {@link #FCPPluginMessage(String, String)} instead
32          */
33         @Deprecated
34         public FCPPluginMessage(String pluginClass) {
35                 super("FCPPluginMessage");
36                 setField("PluginName", pluginClass);
37         }
38
39         public FCPPluginMessage(String identifier, String pluginClass) {
40                 this(pluginClass);
41                 setField("Identifier", identifier);
42         }
43
44         /**
45          * @deprecated Use {@link #FCPPluginMessage(String, String)} instead
46          */
47         @Deprecated
48         public void setIdentifier(String identifier) {
49                 setField("Identifier", identifier);
50         }
51
52         /**
53          * Sets a custom parameter for the plugin.
54          *
55          * @param key
56          *      The key of the parameter
57          * @param value
58          *      The value of the parameter
59          */
60         public void setParameter(String key, String value) {
61                 setField("Param." + key, value);
62         }
63
64         /**
65          * @deprecated Use {@link #setData(InputStream, long)} instead
66          */
67         @Deprecated
68         public void setDataLength(long dataLength) {
69                 setField("DataLength", String.valueOf(dataLength));
70         }
71
72         public void setData(InputStream payloadInputStream, long dataLength) {
73                 setPayloadInputStream(payloadInputStream);
74                 setDataLength(dataLength);
75         }
76
77 }