2 * © 2008 INA Service GmbH
4 package net.pterodactylus.util.fcp;
7 * A “ClientGet” request is used for download files from the Freenet node.
9 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
12 public class ClientGet extends FcpMessage {
15 * Creates a new “ClientGet” request.
20 * The identifier of the request
22 public ClientGet(String uri, String identifier) {
23 this(uri, identifier, ReturnType.direct);
27 * Creates a new “ClientGet” request.
32 * The identifier of the request
34 * The return type of the request
36 public ClientGet(String uri, String identifier, ReturnType returnType) {
39 setField("Identifier", identifier);
40 setField("ReturnType", String.valueOf(returnType));
44 * Sets whether the local data store should be ignored when searching for a
47 * @param ignoreDataStore
48 * <code>true</code> to ignore the local data store,
49 * <code>false</code> to include it
51 public void setIgnoreDataStore(boolean ignoreDataStore) {
52 setField("IgnoreDS", String.valueOf(ignoreDataStore));
56 * Sets whether the search for the key should be restricted to the local
60 * <code>true</code> to restrict the search to the local data
61 * store, <code>false</code> to search on other nodes, too
63 public void setDataStoreOnly(boolean dsOnly) {
64 setField("DSonly", String.valueOf(dsOnly));
68 * Sets the verbosity of the request.
71 * The verbosity of the request
73 public void setVerbosity(Verbosity verbosity) {
74 setField("Verbosity", String.valueOf(verbosity));
78 * Sets the maximum size of the file to retrieve. If the file is larger than
79 * this size the request will fail!
82 * The maximum size of the file to retrieve
84 public void setMaxSize(long maxSize) {
85 setField("MaxSize", String.valueOf(maxSize));
89 * Sets the maximum size of temporary files created by the node. If a
90 * temporary file is larger than this size the request will fail!
93 * The maximum size of temporary files
95 public void setMaxTempSize(long maxTempSize) {
96 setField("MaxTempSize", String.valueOf(maxTempSize));
100 * The maximum number of retries in case a block can not be retrieved.
103 * The maximum number of retries for failed blocks,
104 * <code>-1</code> to try forever
106 public void setMaxRetries(int maxRetries) {
107 setField("MaxRetries", String.valueOf(maxRetries));
111 * Sets the priority of the request.
114 * The priority of the request
116 public void setPriority(Priority priority) {
117 setField("PriorityClass", String.valueOf(priority));
121 * Sets the persistence of the request.
124 * The persistence of the request
126 public void setPersistence(Persistence persistence) {
127 setField("Persistence", String.valueOf(persistence));
131 * Sets the client token of the request.
134 * The client token of the request
136 public void setClientToken(String clientToken) {
137 setField("ClientToken", clientToken);
141 * Sets whether the request should be visible on the global queue.
144 * <code>true</code> to make the request visible on the global
145 * queue, <code>false</code> for client-local queue only
147 public void setGlobal(boolean global) {
148 setField("Global", String.valueOf(global));
152 * Sets whether to request the “binary blob” for a key.
155 * <code>true</code> to request the binary blob,
156 * <code>false</code> to get the “real thing”
158 public void setBinaryBlob(boolean binaryBlob) {
159 setField("BinaryBlob", String.valueOf(binaryBlob));
163 * Sets the allowed MIME types of the requested file. If the MIME type of
164 * the file does not match one of the given MIME types the request will
167 * @param allowedMimeTypes
168 * The allowed MIME types
170 public void setAllowedMimeTypes(String... allowedMimeTypes) {
171 setField("AllowedMIMETypes", FcpUtils.encodeMultiStringField(allowedMimeTypes));
175 * Sets the filename to download the file to. You should only call this
176 * method if your return type is {@link ReturnType#disk}!
179 * The filename to download the file to
181 public void setFilename(String filename) {
182 setField("Filename", filename);
186 * Sets the name for the temporary file. You should only call this method if
187 * your return type is {@link ReturnType#disk}!
189 * @param tempFilename
190 * The name of the temporary file
192 public void setTempFilename(String tempFilename) {
193 setField("TempFilename", tempFilename);