2 * © 2008 INA Service GmbH
4 package net.pterodactylus.util.fcp;
6 import java.io.InputStream;
9 * The “AllData” message carries the payload of a successful {@link ClientGet}
10 * request. You will only received this message if the {@link ClientGet} request
11 * was started with a return type of {@link ReturnType#direct}. If you get this
12 * message and decide that the data is for you, call
13 * {@link #getPayloadInputStream()} to get the data. If an AllData message
14 * passes through all registered {@link FcpListener}s without the payload being
15 * consumed, the payload is discarded!
17 * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
20 public class AllData extends BaseMessage {
23 private InputStream payloadInputStream;
26 * Creates an “AllData” message that wraps the received message.
28 * @param receivedMessage
29 * The received message
30 * @param payloadInputStream
33 AllData(FcpMessage receivedMessage, InputStream payloadInputStream) {
34 super(receivedMessage);
35 this.payloadInputStream = payloadInputStream;
39 * Returns the identifier of the request.
41 * @return The identifier of the request
43 public String getIdentifier() {
44 return getField("Identifier");
48 * Returns the length of the data.
50 * @return The length of the data, or <code>-1</code> if the length could
53 public long getDataLength() {
54 return FcpUtils.safeParseLong(getField("DataLength"));
58 * Returns the startup time of the request.
60 * @return The startup time of the request (in milliseconds since Jan 1,
61 * 1970 UTC), or <code>-1</code> if the time could not be parsed
63 public long getStartupTime() {
64 return FcpUtils.safeParseLong(getField("StartupTime"));
68 * Returns the completion time of the request.
70 * @return The completion time of the request (in milliseconds since Jan 1,
71 * 1970 UTC), or <code>-1</code> if the time could not be parsed
73 public long getCompletionTime() {
74 return FcpUtils.safeParseLong(getField("CompletionTime"));
78 * Returns the payload input stream.
82 public InputStream getPayloadInputStream() {
83 return payloadInputStream;