2 * jSite2 - SimpleProgress.java -
3 * Copyright © 2008 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 * A “SimpleProgress” message tells the client about the progress of a
24 * {@link ClientGet} or {@link ClientPut} operation.
26 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
29 public class SimpleProgress extends BaseMessage {
32 * Creates a new “SimpleProgress” message that wraps the received message.
34 * @param receivedMessage
35 * The received message
37 SimpleProgress(FcpMessage receivedMessage) {
38 super(receivedMessage);
42 * Returns the total number of blocks. This number may increase as long as
43 * {@link #isFinalizedTotal()} returns <code>false</code>.
45 * @return The total number of blocks
47 public int getTotal() {
48 return FcpUtils.safeParseInt(getField("Total"));
52 * Returns the number of blocks that are required to completet the request.
53 * This number might actually be lower than {@link #getTotal} because of
54 * redundancy information. This number may also increase as long as
55 * {@link #isFinalizedTotal()} returns <code>false</code>.
57 * @return The number of required blocks
59 public int getRequired() {
60 return FcpUtils.safeParseInt(getField("Required"));
64 * Returns the number of blocks that have failed and run out of retries.
66 * @return The number of failed blocks
68 public int getFailed() {
69 return FcpUtils.safeParseInt(getField("Failed"));
73 * Returns the number of fatally failed blocks. A block that failed fatally
74 * can never be completed, even with infinite retries.
76 * @return The number of fatally failed blocks
78 public int getFatallyFailed() {
79 return FcpUtils.safeParseInt(getField("FatallyFailed"));
83 * Returns the number of blocks that have been successfully processed.
85 * @return The number of succeeded blocks
87 public int getSucceeded() {
88 return FcpUtils.safeParseInt(getField("Succeeded"));
92 * Returns whether the total number of blocks (see {@link #getTotal()} has
93 * been finalized. Once the total number of blocks has been finalized for a
94 * request it will not change any more, and this method of every further
95 * SimpleProgress message will always return <code>true</code>.
97 * @return <code>true</code> if the number of total blocks has been
98 * finalized, <code>false</code> otherwise
100 public boolean isFinalizedTotal() {
101 return Boolean.valueOf(getField("FinalizedTotal"));
105 * Returns the identifier of the request.
107 * @return The identifier of the request
109 public String getIdentifier() {
110 return getField("Identifier");