Remove all existing @since annotations
[deliverable/tracecompass.git] / org.eclipse.tracecompass.lttng2.control.core / src / org / eclipse / tracecompass / internal / lttng2 / control / core / relayd / lttngviewerCommands / TracePacketResponse.java
1 /**********************************************************************
2 * Copyright (c) 2014 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Matthew Khouzam - Initial implementation and API
11 * Marc-Andre Laperle - Initial implementation and API
12 **********************************************************************/
13
14 package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
15
16 import java.io.DataInputStream;
17 import java.io.IOException;
18 import java.nio.ByteBuffer;
19 import java.nio.ByteOrder;
20
21 /**
22 * Response to getpacket command
23 *
24 * @author Matthew Khouzam
25 */
26 public class TracePacketResponse implements IRelayResponse {
27
28 /**
29 * Command size
30 *
31 * fStatus + fData.length + fFlags
32 */
33 private static final int SIZE = (Integer.SIZE + Integer.SIZE + Integer.SIZE) / 8;
34 /** Enum lttng_viewer_get_packet_return_code */
35 private final GetPacketReturnCode fStatus;
36 /** flags: is there new metadata or new streams? */
37 private final int fFlags;
38 /** the packet */
39 private final byte[] fData;
40
41 /**
42 * Trace packet response network constructor
43 *
44 * @param inNet
45 * network input stream
46 * @throws IOException
47 * network error
48 */
49 public TracePacketResponse(DataInputStream inNet) throws IOException {
50 byte[] data = new byte[SIZE];
51 inNet.readFully(data);
52 ByteBuffer bb = ByteBuffer.wrap(data);
53 bb.order(ByteOrder.BIG_ENDIAN);
54 fStatus = GetPacketReturnCode.values()[bb.getInt() - 1];
55 int length = bb.getInt();
56 fFlags = bb.getInt();
57 if (fStatus.equals(GetPacketReturnCode.VIEWER_GET_PACKET_OK)) {
58 fData = new byte[length];
59 inNet.readFully(fData);
60 } else {
61 fData = new byte[0];
62 }
63 }
64
65 /**
66 * Get the status
67 *
68 * @return the Status
69 */
70 public GetPacketReturnCode getStatus() {
71 return fStatus;
72 }
73
74 /**
75 * Get the flags
76 *
77 * @return the Flags
78 */
79 public int getFlags() {
80 return fFlags;
81 }
82
83 /**
84 * Get the packet data, please do not modify the data
85 *
86 * @return the Data
87 */
88 public byte[] getData() {
89 return fData;
90 }
91
92 }
This page took 0.031677 seconds and 5 git commands to generate.