gdbtrace: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.control.core / src / org / eclipse / linuxtools / internal / lttng2 / control / core / relayd / lttngviewerCommands / GetPacket.java
CommitLineData
8e15b929
MK
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
14package org.eclipse.linuxtools.internal.lttng2.control.core.relayd.lttngviewerCommands;
15
16import java.nio.ByteBuffer;
17import java.nio.ByteOrder;
18
19/**
20 * VIEWER_GET_PACKET payload.
21 *
22 * @author Matthew Khouzam
23 * @since 3.0
24 */
25public class GetPacket implements IRelayCommand {
26
27 /**
28 * Command size
8adfbb73
MAL
29 *
30 * fStreamId + fOffset + fLength
8e15b929
MK
31 */
32 public static final int SIZE = (Long.SIZE + Long.SIZE + Integer.SIZE) / 8;
33 /** the stream Id */
34 private final long fStreamId;
35 /** the offset */
36 private final long fOffset;
37 /** the length of the packet */
38 private final int fLength;
39
40 /**
41 * Get packet constructor
42 *
43 * @param streamId
44 * the stream id
45 * @param offset
46 * the offset
47 * @param length
48 * the packet length
49 */
50 public GetPacket(long streamId, long offset, int length) {
51 fStreamId = streamId;
52 fOffset = offset;
53 fLength = length;
54 }
55
56 /**
57 * Get the length of the packet
58 *
59 * @return the length of the packet in bytes
60 */
61 public int getLength() {
62 return fLength;
63 }
64
65 /**
66 * Gets the offset of the packet
67 *
68 * @return the offset
69 */
70 public long getOffset() {
71 return fOffset;
72 }
73
74 /**
75 * Gets the stream id
76 *
77 * @return the stream id
78 */
79 public long getStreamId() {
80 return fStreamId;
81 }
82
83 @Override
84 public byte[] serialize() {
85 byte data[] = new byte[SIZE];
86 ByteBuffer bb = ByteBuffer.wrap(data);
87 bb.order(ByteOrder.BIG_ENDIAN);
88 bb.putLong(getStreamId());
89 bb.putLong(getOffset());
90 bb.putInt(getLength());
91 return data;
92 }
93
94}
This page took 0.032856 seconds and 5 git commands to generate.