*******************************************************************************/
package org.eclipse.linuxtools.tmf.core.ctfadaptor;
+import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
import org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader;
import org.eclipse.linuxtools.ctf.core.trace.StreamInputReader;
+import org.eclipse.linuxtools.internal.tmf.core.Activator;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
/**
* The CTF trace reader iterator.
*
- * It doesn't reserve a file handle, so many iterators can be used without worries
- * of I/O errors or resource exhaustion.
+ * It doesn't reserve a file handle, so many iterators can be used without
+ * worries of I/O errors or resource exhaustion.
*
* @version 1.0
* @author Matthew Khouzam
/**
* An invalid location
*/
- final public static CtfLocation NULL_LOCATION = new CtfLocation(CtfLocation.INVALID_LOCATION);
+ public static final CtfLocation NULL_LOCATION = new CtfLocation(CtfLocation.INVALID_LOCATION);
private CtfLocation curLocation;
private long curRank;
*
* @param trace
* the trace to iterate over
+ * @throws CTFReaderException
+ * error
*/
- public CtfIterator(final CtfTmfTrace trace) {
+ public CtfIterator(final CtfTmfTrace trace) throws CTFReaderException {
super(trace.getCTFTrace());
this.ctfTmfTrace = trace;
if (this.hasMoreEvents()) {
* long the timestamp in ns of the trace for positioning
* @param rank
* long the index of the trace for positioning
+ * @throws CTFReaderException
+ * error
* @since 2.0
*/
public CtfIterator(final CtfTmfTrace trace,
- final CtfLocationInfo ctfLocationData, final long rank) {
+ final CtfLocationInfo ctfLocationData, final long rank) throws CTFReaderException {
super(trace.getCTFTrace());
this.ctfTmfTrace = trace;
/**
* Method getCtfTmfTrace. gets a CtfTmfTrace
+ *
* @return CtfTmfTrace
*/
public CtfTmfTrace getCtfTmfTrace() {
/**
* Method getCurrentEvent. gets the current event
+ *
* @return CtfTmfEvent
*/
public CtfTmfEvent getCurrentEvent() {
*
* @param ctfLocationData
* The LocationData representing the position to seek to
- * @return boolean
+ * @return boolean True if the seek was successful, false if there was an
+ * error seeking.
* @since 2.0
*/
public synchronized boolean seek(final CtfLocationInfo ctfLocationData) {
/* Adjust the timestamp depending on the trace's offset */
long currTimestamp = ctfLocationData.getTimestamp();
final long offsetTimestamp = this.getCtfTmfTrace().getCTFTrace().timestampNanoToCycles(currTimestamp);
- if (offsetTimestamp < 0) {
- ret = super.seek(0L);
- } else {
- ret = super.seek(offsetTimestamp);
+ try {
+ if (offsetTimestamp < 0) {
+ ret = super.seek(0L);
+ } else {
+ ret = super.seek(offsetTimestamp);
+ }
+ } catch (CTFReaderException e) {
+ Activator.logError(e.getMessage(), e);
+ return false;
}
-
/*
* Check if there is already one or more events for that timestamp, and
* assign the location index correctly
/**
* Method getRank.
+ *
* @return long
* @see org.eclipse.linuxtools.tmf.core.trace.ITmfContext#getRank()
*/
/**
* Method setRank.
- * @param rank long
+ *
+ * @param rank
+ * long
* @see org.eclipse.linuxtools.tmf.core.trace.ITmfContext#setRank(long)
*/
@Override
@Override
public CtfIterator clone() {
CtfIterator clone = null;
- clone = new CtfIterator(ctfTmfTrace, this.getLocation().getLocationInfo(), curRank);
+ try {
+ clone = new CtfIterator(ctfTmfTrace, this.getLocation().getLocationInfo(), curRank);
+ } catch (CTFReaderException e) {
+ Activator.logError(e.getMessage(), e);
+ }
return clone;
}
/**
* Method dispose.
+ *
* @see org.eclipse.linuxtools.tmf.core.trace.ITmfContext#dispose()
*/
@Override
/**
* Method setLocation.
- * @param location ITmfLocation<?>
+ *
+ * @param location
+ * ITmfLocation<?>
* @since 3.0
*/
@Override
/**
* Method getLocation.
+ *
* @return CtfLocation
* @see org.eclipse.linuxtools.tmf.core.trace.ITmfContext#getLocation()
*/
/**
* Method increaseRank.
+ *
* @see org.eclipse.linuxtools.tmf.core.trace.ITmfContext#increaseRank()
*/
@Override
/**
* Method hasValidRank, if the iterator is valid
+ *
* @return boolean
* @see org.eclipse.linuxtools.tmf.core.trace.ITmfContext#hasValidRank()
*/
/**
* Method advance go to the next event
+ *
* @return boolean successful or not
*/
@Override
public synchronized boolean advance() {
long index = curLocation.getLocationInfo().getIndex();
long timestamp = curLocation.getLocationInfo().getTimestamp();
- boolean ret = super.advance();
+ boolean ret = false;
+ try {
+ ret = super.advance();
+ } catch (CTFReaderException e) {
+ Activator.logError(e.getMessage(), e);
+ }
if (ret) {
final long timestampValue = getCurrentEvent().getTimestamp().getValue();
/**
* Method compareTo.
- * @param o CtfIterator
+ *
+ * @param o
+ * CtfIterator
* @return int -1, 0, 1
*/
@Override