2 * jFCPlib - PersistentGet.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 * The “PersistentGet” message is sent to the client to inform it about a
23 * persistent download, either in the client-local queue or in the global queue.
25 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
27 public class PersistentGet extends BaseMessage {
30 * Creates a new “PersistentGet” message that wraps the received message.
32 * @param receivedMessage
33 * The received message
35 PersistentGet(FcpMessage receivedMessage) {
36 super(receivedMessage);
40 * Returns the identifier of the request.
42 * @return The identifier of the request
44 public String getIdentifier() {
45 return getField("Identifier");
49 * Returns the URI of the request.
51 * @return The URI of the request
53 public String getURI() {
54 return getField("URI");
58 * Returns the verbosity of the request.
60 * @return The verbosity of the request
62 public Verbosity getVerbosity() {
63 return Verbosity.valueOf(getField("Verbosity"));
67 * Returns the return type of the request.
69 * @return The return type of the request
71 public ReturnType getReturnType() {
73 return ReturnType.valueOf(getField("ReturnType"));
74 } catch (IllegalArgumentException iae1) {
75 return ReturnType.unknown;
80 * Returns the name of the file the data is downloaded to. This field will
81 * only be set if {@link #getReturnType()} is {@link ReturnType#disk}.
83 * @return The name of the file the data is downloaded to
85 public String getFilename() {
86 return getField("Filename");
90 * Returns the name of the temporary file. This field will only be set if
91 * {@link #getReturnType()} is {@link ReturnType#disk}.
93 * @return The name of the temporary file
95 public String getTempFilename() {
96 return getField("TempFilename");
100 * Returns the client token of the request.
102 * @return The client token of the request
104 public String getClientToken() {
105 return getField("ClientToken");
109 * Returns the priority of the request.
111 * @return The priority of the request
113 public Priority getPriority() {
114 return Priority.values()[FcpUtils.safeParseInt(getField("PriorityClass"), Priority.unknown.ordinal())];
118 * Returns the persistence of the request.
120 * @return The persistence of the request, or {@link Persistence#unknown} if
121 * the persistence could not be parsed
123 public Persistence getPersistence() {
125 return Persistence.valueOf(getField("Persistence"));
126 } catch (IllegalArgumentException iae1) {
127 return Persistence.unknown;
132 * Returns whether this request is on the global queue or on the
133 * client-local queue.
135 * @return <code>true</code> if the request is on the global queue,
136 * <code>false</code> if the request is on the client-local queue
138 public boolean isGlobal() {
139 return Boolean.valueOf(getField("Global"));
143 * Returns the maximum number of retries for a failed block.
145 * @return The maximum number of retries for a failed block, <code>-1</code>
146 * for endless retries, <code>-2</code> if the number could not be
149 public int getMaxRetries() {
150 return FcpUtils.safeParseInt(getField("MaxRetries"), -2);