2 * jSite2 - AllData.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.fcp;
22 import java.io.InputStream;
25 * The “AllData” message carries the payload of a successful {@link ClientGet}
26 * request. You will only received this message if the {@link ClientGet} request
27 * was started with a return type of {@link ReturnType#direct}. If you get this
28 * message and decide that the data is for you, call
29 * {@link #getPayloadInputStream()} to get the data. If an AllData message
30 * passes through all registered {@link FcpListener}s without the payload being
31 * consumed, the payload is discarded!
33 * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
36 public class AllData extends BaseMessage {
39 private InputStream payloadInputStream;
42 * Creates an “AllData” message that wraps the received message.
44 * @param receivedMessage
45 * The received message
46 * @param payloadInputStream
49 AllData(FcpMessage receivedMessage, InputStream payloadInputStream) {
50 super(receivedMessage);
51 this.payloadInputStream = payloadInputStream;
55 * Returns the identifier of the request.
57 * @return The identifier of the request
59 public String getIdentifier() {
60 return getField("Identifier");
64 * Returns the length of the data.
66 * @return The length of the data, or <code>-1</code> if the length could
69 public long getDataLength() {
70 return FcpUtils.safeParseLong(getField("DataLength"));
74 * Returns the startup time of the request.
76 * @return The startup time of the request (in milliseconds since Jan 1,
77 * 1970 UTC), or <code>-1</code> if the time could not be parsed
79 public long getStartupTime() {
80 return FcpUtils.safeParseLong(getField("StartupTime"));
84 * Returns the completion time of the request.
86 * @return The completion time of the request (in milliseconds since Jan 1,
87 * 1970 UTC), or <code>-1</code> if the time could not be parsed
89 public long getCompletionTime() {
90 return FcpUtils.safeParseLong(getField("CompletionTime"));
94 * Returns the payload input stream.
98 public InputStream getPayloadInputStream() {
99 return payloadInputStream;