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
93 * than 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));
134 public void setRealTimeFlag(boolean realTimeFlag) {
135 setField("RealTimeFlag", String.valueOf(realTimeFlag));
139 * Sets the persistence of the request.
142 * The persistence of the request
144 public void setPersistence(Persistence persistence) {
145 setField("Persistence", String.valueOf(persistence));
149 * Sets the client token of the request.
152 * The client token of the request
154 public void setClientToken(String clientToken) {
155 setField("ClientToken", clientToken);
159 * Sets whether the request should be visible on the global queue.
162 * <code>true</code> to make the request visible on the global
163 * queue, <code>false</code> for client-local queue only
165 public void setGlobal(boolean global) {
166 setField("Global", String.valueOf(global));
170 * Sets whether to request the “binary blob” for a key.
173 * <code>true</code> to request the binary blob,
174 * <code>false</code> to get the “real thing”
176 public void setBinaryBlob(boolean binaryBlob) {
177 setField("BinaryBlob", String.valueOf(binaryBlob));
181 * Sets whether to filter the fetched content.
184 * {@code true} to filter content, {@code false} otherwise
186 public void setFilterData(boolean filterData) {
187 setField("FilterData", String.valueOf(filterData));
191 * Sets the allowed MIME types of the requested file. If the MIME type of
192 * the file does not match one of the given MIME types the request will
195 * @param allowedMimeTypes
196 * The allowed MIME types
198 public void setAllowedMimeTypes(String... allowedMimeTypes) {
199 setField("AllowedMIMETypes", FcpUtils.encodeMultiStringField(allowedMimeTypes));
203 * Sets the filename to download the file to. You should only call this
204 * method if your return type is {@link ReturnType#disk}!
207 * The filename to download the file to
209 public void setFilename(String filename) {
210 setField("Filename", filename);
214 * Sets the name for the temporary file. You should only call this method
215 * if your return type is {@link ReturnType#disk}!
217 * @param tempFilename
218 * The name of the temporary file
220 public void setTempFilename(String tempFilename) {
221 setField("TempFilename", tempFilename);