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 public 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() {
55 return Long.valueOf(getField("DataLength"));
56 } catch (NumberFormatException nfe1) {
62 * Returns the startup time of the request.
64 * @return The startup time of the request (in milliseconds since Jan 1,
65 * 1970 UTC), or <code>-1</code> if the time could not be parsed
67 public long getStartupTime() {
69 return Long.valueOf(getField("StartupTime"));
70 } catch (NumberFormatException nfe1) {
76 * Returns the completion time of the request.
78 * @return The completion time of the request (in milliseconds since Jan 1,
79 * 1970 UTC), or <code>-1</code> if the time could not be parsed
81 public long getCompletionTime() {
83 return Long.valueOf(getField("CompletionTime"));
84 } catch (NumberFormatException nfe1) {
90 * Returns the payload input stream.
94 public InputStream getPayloadInputStream() {
95 return payloadInputStream;