// Getters/Setters/Predicates
// ------------------------------------------------------------------------
+ /**
+ * Gets the current event in this stream
+ *
+ * @return the current event in the stream, null if the stream is
+ * finished/empty/malformed
+ */
public EventDefinition getCurrentEvent() {
return this.currentEvent;
}
+ /**
+ * gets the current packet context
+ *
+ * @return the current packet context (size, lost events and such)
+ */
public StructDefinition getCurrentPacketContext() {
return this.packetReader.getStreamPacketContextDef();
}
+ /**
+ * Gets the byte order for a trace
+ *
+ * @return the trace byte order
+ */
public ByteOrder getByteOrder() {
return streamInput.getStream().getTrace().getByteOrder();
}
+ /**
+ * Gets the name of the stream (it's an id and a number)
+ *
+ * @return gets the stream name (it's a number)
+ */
public int getName() {
return this.name;
}
+ /**
+ * Sets the name of the stream
+ *
+ * @param name
+ * the name of the stream, (it's a number)
+ */
public void setName(int name) {
this.name = name;
}
+ /**
+ * Gets the CPU of a stream. It's the same as the one in /proc or running
+ * the asm CPUID instruction
+ *
+ * @return The CPU id (a number)
+ */
public int getCPU() {
return this.packetReader.getCPU();
}
+ /**
+ * Gets the filename of the stream being read
+ * @return The filename of the stream being read
+ */
public String getFilename() {
return streamInput.getFilename();
}
}
}
- /*
+ /*autogenerate javadoc getter setter
* If an event is available, read it.
*/
if (this.packetReader.hasMoreEvents()) {
*/
public long seek(long timestamp) {
long offset = 0;
- /*
- * Search in the index for the packet to search in.
- */
- this.packetIndex = this.streamInput.getIndex().search(timestamp)
- .previousIndex();
- /*
- * Switch to this packet.
- */
- goToNextPacket();
+ gotoPacket(timestamp);
/*
* index up to the desired timestamp.
// do nothing here
}
}
+ if (this.packetReader.getCurrentPacket() == null) {
+ gotoPacket(timestamp);
+ }
/*
* Advance until A. we reached the end of the trace file (which means
return offset;
}
+ /**
+ * @param timestamp
+ */
+ private void gotoPacket(long timestamp) {
+ this.packetIndex = this.streamInput.getIndex().search(timestamp)
+ .previousIndex();
+ /*
+ * Switch to this packet.
+ */
+ goToNextPacket();
+ }
+
+ /**
+ * Seeks the last event of a stream and returns it.
+ */
public void goToLastEvent() {
/*
* Search in the index for the packet to search in.
this.parent = parent;
}
+ /**
+ * Sets the current event in a stream input reader
+ * @param currentEvent the event to set
+ */
public void setCurrentEvent(EventDefinition currentEvent) {
this.currentEvent = currentEvent;
}