2 * jFCPlib - ClientGet.java - Copyright © 2008 David Roden
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.
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.
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.
19 package net.pterodactylus.fcp;
22 * A “ClientGet” request is used for download files from the Freenet node.
24 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
26 public class ClientGet extends FcpMessage {
29 * Creates a new “ClientGet” request.
34 * The identifier of the request
36 public ClientGet(String uri, String identifier) {
37 this(uri, identifier, ReturnType.direct);
41 * Creates a new “ClientGet” request.
46 * The identifier of the request
48 * The return type of the request
50 public ClientGet(String uri, String identifier, ReturnType returnType) {
53 setField("Identifier", identifier);
54 setField("ReturnType", String.valueOf(returnType));
58 * Sets whether the local data store should be ignored when searching for a
61 * @param ignoreDataStore
62 * <code>true</code> to ignore the local data store,
63 * <code>false</code> to include it
65 public void setIgnoreDataStore(boolean ignoreDataStore) {
66 setField("IgnoreDS", String.valueOf(ignoreDataStore));
70 * Sets whether the search for the key should be restricted to the local
74 * <code>true</code> to restrict the search to the local data
75 * store, <code>false</code> to search on other nodes, too
77 public void setDataStoreOnly(boolean dsOnly) {
78 setField("DSonly", String.valueOf(dsOnly));
82 * Sets the verbosity of the request.
85 * The verbosity of the request
87 public void setVerbosity(Verbosity verbosity) {
88 setField("Verbosity", String.valueOf(verbosity));
92 * Sets the maximum size of the file to retrieve. If the file is larger than
93 * this size the request will fail!
96 * The maximum size of the file to retrieve
98 public void setMaxSize(long maxSize) {
99 setField("MaxSize", String.valueOf(maxSize));
103 * Sets the maximum size of temporary files created by the node. If a
104 * temporary file is larger than this size the request will fail!
107 * The maximum size of temporary files
109 public void setMaxTempSize(long maxTempSize) {
110 setField("MaxTempSize", String.valueOf(maxTempSize));
114 * The maximum number of retries in case a block can not be retrieved.
117 * The maximum number of retries for failed blocks,
118 * <code>-1</code> to try forever
120 public void setMaxRetries(int maxRetries) {
121 setField("MaxRetries", String.valueOf(maxRetries));
125 * Sets the priority of the request.
128 * The priority of the request
130 public void setPriority(Priority priority) {
131 setField("PriorityClass", String.valueOf(priority));
135 * Sets the persistence of the request.
138 * The persistence of the request
140 public void setPersistence(Persistence persistence) {
141 setField("Persistence", String.valueOf(persistence));
145 * Sets the client token of the request.
148 * The client token of the request
150 public void setClientToken(String clientToken) {
151 setField("ClientToken", clientToken);
155 * Sets whether the request should be visible on the global queue.
158 * <code>true</code> to make the request visible on the global
159 * queue, <code>false</code> for client-local queue only
161 public void setGlobal(boolean global) {
162 setField("Global", String.valueOf(global));
166 * Sets whether to request the “binary blob” for a key.
169 * <code>true</code> to request the binary blob,
170 * <code>false</code> to get the “real thing”
172 public void setBinaryBlob(boolean binaryBlob) {
173 setField("BinaryBlob", String.valueOf(binaryBlob));
177 * Sets the allowed MIME types of the requested file. If the MIME type of
178 * the file does not match one of the given MIME types the request will
181 * @param allowedMimeTypes
182 * The allowed MIME types
184 public void setAllowedMimeTypes(String... allowedMimeTypes) {
185 setField("AllowedMIMETypes", FcpUtils.encodeMultiStringField(allowedMimeTypes));
189 * Sets the filename to download the file to. You should only call this
190 * method if your return type is {@link ReturnType#disk}!
193 * The filename to download the file to
195 public void setFilename(String filename) {
196 setField("Filename", filename);
200 * Sets the name for the temporary file. You should only call this method if
201 * your return type is {@link ReturnType#disk}!
203 * @param tempFilename
204 * The name of the temporary file
206 public void setTempFilename(String tempFilename) {
207 setField("TempFilename", tempFilename);