Update license to GPLv3, fix header comments
[jFCPlib.git] / src / main / java / net / pterodactylus / fcp / ClientPutDiskDir.java
1 /*
2  * jFCPlib - ClientPutDiskDir.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 /**
21  * The “ClientPutDiskDir” message is used to insert a complete directory from
22  * the disk to a single key.
23  *
24  * @author David ‘Bombe’ Roden &lt;bombe@freenetproject.org&gt;
25  */
26 public class ClientPutDiskDir extends FcpMessage {
27
28         /**
29          * Creates a new “ClientPutDiskDir” message.
30          *
31          * @param uri
32          *            The URI to insert the file to
33          * @param identifier
34          *            The identifier of the request
35          * @param directory
36          *            The name of the directory to insert
37          */
38         public ClientPutDiskDir(String uri, String identifier, String directory) {
39                 super("ClientPutDiskDir");
40                 setField("URI", uri);
41                 setField("Identifier", identifier);
42                 setField("Filename", directory);
43         }
44
45         /**
46          * The verbosity of the request. Depending on this parameter you will
47          * received only the bare minimum of messages for the request (i.e. “it
48          * completed”) or a whole lot more.
49          *
50          * @see Verbosity
51          * @param verbosity
52          *            The verbosity of the request
53          */
54         public void setVerbosity(Verbosity verbosity) {
55                 setField("Verbosity", String.valueOf(verbosity));
56         }
57
58         /**
59          * The number of retries for a request if the initial try failed.
60          *
61          * @param maxRetries
62          *            The maximum number of retries after failure, or
63          *            <code>-1</code> to retry forever.
64          */
65         public void setMaxRetries(int maxRetries) {
66                 setField("MaxRetries", String.valueOf(maxRetries));
67         }
68
69         /**
70          * Sets the priority of the request.
71          *
72          * @param priority
73          *            The priority of the request
74          */
75         public void setPriority(Priority priority) {
76                 setField("PriorityClass", String.valueOf(priority));
77         }
78
79         /**
80          * Determines whether the node should really insert the data or generate
81          * the final CHK only.
82          *
83          * @param getCHKOnly
84          *            <code>true</code> to generate the final CHK only,
85          *            <code>false</code> to really insert the data
86          */
87         public void setGetCHKOnly(boolean getCHKOnly) {
88                 setField("GetCHKOnly", String.valueOf(getCHKOnly));
89         }
90
91         /**
92          * Sets whether an insert request should be forked when it is cached.
93          *
94          * @param forkOnCacheable
95          *            {@code true} to fork the insert when it is cached,
96          *            {@code false} otherwise
97          */
98         public void setForkOnCacheable(boolean forkOnCacheable) {
99                 setField("ForkOnCacheable", String.valueOf(forkOnCacheable));
100         }
101
102         /**
103          * Sets the number of additional inserts of single blocks.
104          *
105          * @param extraInsertsSingleBlock
106          *            The number of additional inserts
107          */
108         public void setExtraInsertsSingleBlock(int extraInsertsSingleBlock) {
109                 setField("ExtraInsertsSingleBlock", String.valueOf(extraInsertsSingleBlock));
110         }
111
112         /**
113          * Sets the number of additional inserts of splitfile header blocks.
114          *
115          * @param extraInsertsSplitfileHeaderBlock
116          *            The number of additional inserts
117          */
118         public void setExtraInsertsSplitfileHeaderBlock(int extraInsertsSplitfileHeaderBlock) {
119                 setField("ExtraInsertsSplitfileHeaderBlock", String.valueOf(extraInsertsSplitfileHeaderBlock));
120         }
121
122         /**
123          * Determines whether this request appears on the global queue.
124          *
125          * @param global
126          *            <code>true</code> to put the request on the global queue,
127          *            <code>false</code> for the client-local queue.
128          */
129         public void setGlobal(boolean global) {
130                 setField("Global", String.valueOf(global));
131         }
132
133         /**
134          * Determines whether the node should skip compression because the file has
135          * already been compressed.
136          *
137          * @param dontCompress
138          *            <code>true</code> to skip compression of the data in the
139          *            node, <code>false</code> to allow compression
140          */
141         public void setDontCompress(boolean dontCompress) {
142                 setField("DontCompress", String.valueOf(dontCompress));
143         }
144
145         /**
146          * Sets an optional client token. This client token is mentioned in
147          * progress and other request-related messages and can be used to identify
148          * this request.
149          *
150          * @param clientToken
151          *            The client token
152          */
153         public void setClientToken(String clientToken) {
154                 setField("ClientToken", clientToken);
155         }
156
157         /**
158          * Sets the persistence of this request.
159          *
160          * @param persistence
161          *            The persistence of this request
162          */
163         public void setPersistence(Persistence persistence) {
164                 setField("Persistence", String.valueOf(persistence));
165         }
166
167         /**
168          * Sets the name of the default file. The default file is shown when the
169          * key is requested with an additional name.
170          *
171          * @param defaultName
172          *            The name of the default file
173          */
174         public void setDefaultName(String defaultName) {
175                 setField("DefaultName", defaultName);
176         }
177
178         /**
179          * Sets whether unreadable files allow the insert to continue.
180          *
181          * @param allowUnreadableFiles
182          *            <code>true</code> to just ignore unreadable files,
183          *            <code>false</code> to let the insert fail when an unreadable
184          *            file is encountered
185          */
186         public void setAllowUnreadableFiles(boolean allowUnreadableFiles) {
187                 setField("AllowUnreadableFiles", String.valueOf(allowUnreadableFiles));
188         }
189
190 }