1 /*******************************************************************************
2 * Copyright (c) 2011-2012 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
;
18 * <b><u>StreamInputPacketIndexEntry</u></b>
20 * Represents an entry in the index of event packets.
22 public class StreamInputPacketIndexEntry
{
24 // ------------------------------------------------------------------------
26 // ------------------------------------------------------------------------
30 * Offset of the packet in the file, in bytes
32 final private long offsetBytes
;
35 * Offset of the data in the packet, in bits
37 private int dataOffsetBits
= 0;
40 * Packet size, in bits
42 private int packetSizeBits
= 0;
45 * Content size, in bits
47 private int contentSizeBits
= 0;
52 private long timestampBegin
= 0;
57 private long timestampEnd
= 0;
60 * How many lost events are there?
62 private long lostEvents
= 0;
65 * Which target is being traced
67 private String target
;
68 private long targetID
;
71 // ------------------------------------------------------------------------
73 // ------------------------------------------------------------------------
76 * Constructs an index entry.
79 * The offset of the packet in the file, in bytes.
82 public StreamInputPacketIndexEntry(long offset
) {
83 this.offsetBytes
= offset
;
86 // ------------------------------------------------------------------------
88 // ------------------------------------------------------------------------
91 * Returns whether the packet includes (inclusively) the given timestamp in
92 * the begin-end timestamp range.
95 * The timestamp to check.
96 * @return True if the packet includes the timestamp.
98 boolean includes(long ts
) {
99 return (ts
>= timestampBegin
) && (ts
<= timestampEnd
);
105 * @see java.lang.Object#toString()
108 public String
toString() {
109 return "StreamInputPacketIndexEntry [offsetBytes=" + offsetBytes
//$NON-NLS-1$
110 + ", timestampBegin=" + timestampBegin
+ ", timestampEnd=" //$NON-NLS-1$ //$NON-NLS-2$
111 + timestampEnd
+ "]"; //$NON-NLS-1$
114 // ------------------------------------------------------------------------
115 // Getters and Setters
116 // ------------------------------------------------------------------------
119 * @return the offsetBytes
121 public long getOffsetBytes() {
126 * @return the dataOffsetBits
128 public int getDataOffsetBits() {
129 return dataOffsetBits
;
133 * @param dataOffsetBits
134 * the dataOffsetBits to set
136 public void setDataOffsetBits(int dataOffsetBits
) {
137 this.dataOffsetBits
= dataOffsetBits
;
141 * @return the packetSizeBits
143 public int getPacketSizeBits() {
144 return packetSizeBits
;
148 * @param packetSizeBits
149 * the packetSizeBits to set
151 public void setPacketSizeBits(int packetSizeBits
) {
152 this.packetSizeBits
= packetSizeBits
;
156 * @return the contentSizeBits
158 public int getContentSizeBits() {
159 return contentSizeBits
;
163 * @param contentSizeBits
164 * the contentSizeBits to set
166 public void setContentSizeBits(int contentSizeBits
) {
167 this.contentSizeBits
= contentSizeBits
;
171 * @return the timestampBegin
173 public long getTimestampBegin() {
174 return timestampBegin
;
178 * @param timestampBegin
179 * the timestampBegin to set
181 public void setTimestampBegin(long timestampBegin
) {
182 this.timestampBegin
= timestampBegin
;
186 * @return the timestampEnd
188 public long getTimestampEnd() {
193 * @param timestampEnd
194 * the timestampEnd to set
196 public void setTimestampEnd(long timestampEnd
) {
197 this.timestampEnd
= timestampEnd
;
201 * @return the lostEvents
203 public long getLostEvents() {
208 * @param lostEvents the lostEvents to set
210 public void setLostEvents(long lostEvents
) {
211 this.lostEvents
= lostEvents
;
214 private final HashMap
<String
, Object
> attributes
= new HashMap
<String
, Object
>();
215 public void addAttribute(String field
, Object value
) {
216 attributes
.put(field
, value
);
218 public Object
lookupAttribute(String field
){
219 return attributes
.get(field
);
222 public String
getTarget() {
226 public void setTarget(String target
) {
227 this.target
= target
;
228 this.targetID
= Integer
.parseInt(target
.replaceAll("[\\D]", "")); //$NON-NLS-1$ //$NON-NLS-2$ // slow
231 public long getTargetId(){