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