1 /*******************************************************************************
2 * Copyright (c) 2011, 2014 Ericsson, Ecole Polytechnique de Montreal and others
4 * All rights reserved. This program and the accompanying materials are made
5 * 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
9 * Contributors: Matthew Khouzam - Initial API and implementation
10 * Contributors: Simon Marchi - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.internal
.ctf
.core
.trace
;
15 import java
.util
.HashMap
;
19 * <b><u>StreamInputPacketIndexEntry</u></b>
21 * Represents an entry in the index of event packets.
23 public class StreamInputPacketIndexEntry
{
25 // ------------------------------------------------------------------------
27 // ------------------------------------------------------------------------
30 * Offset of the packet in the file, in bytes
32 final private long fOffsetBytes
;
35 * Offset of the data in the packet, in bits
37 private long fDataOffsetBits
= 0;
40 * Packet size, in bits
42 private long fPacketSizeBits
= 0;
45 * Content size, in bits
47 private long fContentSizeBits
= 0;
52 private long fTimestampBegin
= 0;
57 private long fTimestampEnd
= 0;
60 * How many lost events are there?
62 private long fLostEvents
= 0;
65 * Which target is being traced
67 private String fTarget
;
68 private long fTargetID
;
71 * Attributes of this index entry
73 private final Map
<String
, Object
> fAttributes
= new HashMap
<>();
76 // ------------------------------------------------------------------------
78 // ------------------------------------------------------------------------
81 * Constructs an index entry.
84 * The offset of the packet in the file, in bytes.
87 public StreamInputPacketIndexEntry(long offset
) {
88 fOffsetBytes
= offset
;
91 // ------------------------------------------------------------------------
93 // ------------------------------------------------------------------------
96 * Returns whether the packet includes (inclusively) the given timestamp in
97 * the begin-end timestamp range.
100 * The timestamp to check.
101 * @return True if the packet includes the timestamp.
103 boolean includes(long ts
) {
104 return (ts
>= fTimestampBegin
) && (ts
<= fTimestampEnd
);
108 public String
toString() {
109 return "StreamInputPacketIndexEntry [offsetBytes=" + fOffsetBytes
//$NON-NLS-1$
110 + ", timestampBegin=" + fTimestampBegin
+ ", timestampEnd=" //$NON-NLS-1$ //$NON-NLS-2$
111 + fTimestampEnd
+ "]"; //$NON-NLS-1$
114 // ------------------------------------------------------------------------
115 // Getters and Setters
116 // ------------------------------------------------------------------------
119 * @return the offsetBytes
121 public long getOffsetBytes() {
126 * @return the dataOffsetBits
128 public long getDataOffsetBits() {
129 return fDataOffsetBits
;
133 * @param dataOffsetBits
134 * the dataOffsetBits to set
136 public void setDataOffsetBits(long dataOffsetBits
) {
137 fDataOffsetBits
= dataOffsetBits
;
141 * @return the packetSizeBits
143 public long getPacketSizeBits() {
144 return fPacketSizeBits
;
148 * @param packetSizeBits
149 * the packetSizeBits to set
151 public void setPacketSizeBits(long packetSizeBits
) {
152 fPacketSizeBits
= packetSizeBits
;
156 * @return the contentSizeBits
158 public long getContentSizeBits() {
159 return fContentSizeBits
;
163 * @param contentSizeBits
164 * the contentSizeBits to set
166 public void setContentSizeBits(long contentSizeBits
) {
167 fContentSizeBits
= contentSizeBits
;
171 * @return the timestampBegin
173 public long getTimestampBegin() {
174 return fTimestampBegin
;
178 * @param timestampBegin
179 * the timestampBegin to set
181 public void setTimestampBegin(long timestampBegin
) {
182 fTimestampBegin
= timestampBegin
;
186 * @return the timestampEnd
188 public long getTimestampEnd() {
189 return fTimestampEnd
;
193 * @param timestampEnd
194 * the timestampEnd to set
196 public void setTimestampEnd(long timestampEnd
) {
197 fTimestampEnd
= timestampEnd
;
201 * @return the lostEvents in this packet
203 public long getLostEvents() {
208 * @param lostEvents the lostEvents to set
210 public void setLostEvents(long lostEvents
) {
211 fLostEvents
= lostEvents
;
215 * Add an attribute to this index entry
218 * The name of the attribute
220 * The value to insert
222 public void addAttribute(String field
, Object value
) {
223 fAttributes
.put(field
, value
);
227 * Retrieve the value of an existing attribute
230 * The name of the attribute
231 * @return The value that was stored, or null if it wasn't found
233 public Object
lookupAttribute(String field
){
234 return fAttributes
.get(field
);
238 * @return The target that is being traced
240 public String
getTarget() {
245 * Assign a target to this index entry
248 * The target to assign
250 public void setTarget(String target
) {
252 fTargetID
= Integer
.parseInt(target
.replaceAll("[\\D]", "")); //$NON-NLS-1$ //$NON-NLS-2$ // slow
256 * @return The ID of the target
258 public long getTargetId(){