2 * ${project_name} - ${file_name} -
3 * Copyright \u00A9 ${year} David Roden
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 package net.pterodactylus.util.fcp;
23 * The “PersistentGet” message is sent to the client to inform it about a
24 * persistent download, either in the client-local queue or in the global queue.
26 * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
29 public class PersistentGet extends BaseMessage {
32 * Creates a new “PersistentGet” message that wraps the received message.
34 * @param receivedMessage
35 * The received message
37 PersistentGet(FcpMessage receivedMessage) {
38 super(receivedMessage);
42 * Returns the identifier of the request.
44 * @return The identifier of the request
46 public String getIdentifier() {
47 return getField("Identifier");
51 * Returns the URI of the request.
53 * @return The URI of the request
55 public String getURI() {
56 return getField("URI");
60 * Returns the verbosity of the request.
62 * @return The verbosity of the request
64 public Verbosity getVerbosity() {
65 return Verbosity.valueOf(getField("Verbosity"));
69 * Returns the return type of the request.
71 * @return The return type of the request
73 public ReturnType getReturnType() {
75 return ReturnType.valueOf(getField("ReturnType"));
76 } catch (IllegalArgumentException iae1) {
77 return ReturnType.unknown;
82 * Returns the name of the file the data is downloaded to. This field will
83 * only be set if {@link #getReturnType()} is {@link ReturnType#disk}.
85 * @return The name of the file the data is downloaded to
87 public String getFilename() {
88 return getField("Filename");
92 * Returns the name of the temporary file. This field will only be set if
93 * {@link #getReturnType()} is {@link ReturnType#disk}.
95 * @return The name of the temporary file
97 public String getTempFilename() {
98 return getField("TempFilename");
102 * Returns the client token of the request.
104 * @return The client token of the request
106 public String getClientToken() {
107 return getField("ClientToken");
111 * Returns the priority of the request.
113 * @return The priority of the request
115 public Priority getPriority() {
116 return Priority.values()[FcpUtils.safeParseInt(getField("PriorityClass"), 7)];
120 * Returns the persistence of the request.
122 * @return The persistence of the request, or {@link Persistence#unknown} if
123 * the persistence could not be parsed
125 public Persistence getPersistence() {
127 return Persistence.valueOf(getField("Persistence"));
128 } catch (IllegalArgumentException iae1) {
129 return Persistence.unknown;
134 * Returns whether this request is on the global queue or on the
135 * client-local queue.
137 * @return <code>true</code> if the request is on the global queue,
138 * <code>false</code> if the request is on the client-local queue
140 public boolean isGlobal() {
141 return Boolean.valueOf(getField("Global"));
145 * Returns the maximum number of retries for a failed block.
147 * @return The maximum number of retries for a failed block, <code>-1</code>
148 * for endless retries, <code>-2</code> if the number could not be
151 public int getMaxRetries() {
152 return FcpUtils.safeParseInt(getField("MaxRetries"), -2);