import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
+import org.eclipse.linuxtools.internal.tmf.core.Activator;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
*/
public class CtfTmfTrace extends TmfTrace implements ITmfEventParser {
-
- //-------------------------------------------
- // Constants
- //-------------------------------------------
+ // -------------------------------------------
+ // Constants
+ // -------------------------------------------
/**
* Default cache size for CTF traces
*/
protected static final int DEFAULT_CACHE_SIZE = 50000;
- //-------------------------------------------
- // Fields
- //-------------------------------------------
+ // -------------------------------------------
+ // Fields
+ // -------------------------------------------
/* Reference to the CTF Trace */
private CTFTrace fTrace;
-
-
- //-------------------------------------------
- // TmfTrace Overrides
- //-------------------------------------------
+ // -------------------------------------------
+ // TmfTrace Overrides
+ // -------------------------------------------
/**
* Method initTrace.
*
/* Set the start and (current) end times for this trace */
ctx = (CtfTmfContext) seekEvent(0L);
CtfTmfEvent event = getNext(ctx);
- if((ctx.getLocation().equals(CtfIterator.NULL_LOCATION)) || (ctx.getCurrentEvent() == null)) {
+ if ((ctx.getLocation().equals(CtfIterator.NULL_LOCATION)) || (ctx.getCurrentEvent() == null)) {
/* Handle the case where the trace is empty */
this.setStartTime(TmfTimestamp.BIG_BANG);
} else {
}
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.linuxtools.tmf.core.trace.TmfTrace#dispose()
*/
@Override
/**
* Method validate.
- * @param project IProject
- * @param path String
- * @return boolean
+ *
+ * @param project
+ * IProject
+ * @param path
+ * String
+ * @return IStatus IStatus.error or Status.OK_STATUS
* @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#validate(IProject, String)
+ * @since 2.0
*/
@Override
- public boolean validate(final IProject project, final String path) {
+ public IStatus validate(final IProject project, final String path) {
+ IStatus validTrace = Status.OK_STATUS;
try {
final CTFTrace temp = new CTFTrace(path);
boolean valid = temp.majortIsSet(); // random test
temp.dispose();
- return valid;
+ if (!valid) {
+ validTrace = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.CtfTmfTrace_MajorNotSet);
+ }
} catch (final CTFReaderException e) {
- /* Nope, not a CTF trace we can read */
- return false;
+ validTrace = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.CtfTmfTrace_ReadingError +": " + e.toString()); //$NON-NLS-1$
}
+ return validTrace;
}
/**
* Method getCurrentLocation. This is not applicable in CTF
+ *
* @return null, since the trace has no knowledge of the current location
* @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getCurrentLocation()
*/
final CtfTmfContext context = new CtfTmfContext(this);
context.setLocation(curLocation);
context.seek(curLocation.getLocationInfo());
- final CtfLocationInfo currentTime = ((CtfLocationInfo)context.getLocation().getLocationInfo());
+ final CtfLocationInfo currentTime = ((CtfLocationInfo) context.getLocation().getLocationInfo());
final long startTime = getIterator(this, context).getStartTime();
final long endTime = getIterator(this, context).getEndTime();
return ((double) currentTime.getTimestamp() - startTime)
/**
* Method seekEvent.
- * @param location ITmfLocation<?>
+ *
+ * @param location
+ * ITmfLocation<?>
* @return ITmfContext
*/
@Override
currentLocation = new CtfLocation(event.getTimestamp().getValue(), 0);
}
}
- if(context.getRank() != 0) {
+ if (context.getRank() != 0) {
context.setRank(ITmfContext.UNKNOWN_RANK);
}
return context;
}
-
@Override
public synchronized ITmfContext seekEvent(double ratio) {
CtfTmfContext context = new CtfTmfContext(this);
/**
* Method readNextEvent.
- * @param context ITmfContext
+ *
+ * @param context
+ * ITmfContext
* @return CtfTmfEvent
* @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getNext(ITmfContext)
*/
/**
* gets the CTFtrace that this is wrapping
+ *
* @return the CTF trace
*/
public CTFTrace getCTFTrace() {
return fTrace;
}
-
- //-------------------------------------------
- // Environment Parameters
- //-------------------------------------------
+ // -------------------------------------------
+ // Environment Parameters
+ // -------------------------------------------
/**
* Method getNbEnvVars.
*
return this.fTrace.getEnvironment().get(key);
}
- //-------------------------------------------
- // Clocks
- //-------------------------------------------
+ // -------------------------------------------
+ // Clocks
+ // -------------------------------------------
/**
* gets the clock offset
+ *
* @return the clock offset in ns
*/
- public long getOffset(){
- if( fTrace != null ) {
+ public long getOffset() {
+ if (fTrace != null) {
return fTrace.getOffset();
}
return 0;
}
- //-------------------------------------------
- // Parser
- //-------------------------------------------
+ // -------------------------------------------
+ // Parser
+ // -------------------------------------------
@Override
public CtfTmfEvent parseEvent(ITmfContext context) {
setCacheSize(DEFAULT_CACHE_SIZE);
}
- //-------------------------------------------
- // Helpers
- //-------------------------------------------
+ // -------------------------------------------
+ // Helpers
+ // -------------------------------------------
- private static CtfIterator getIterator(CtfTmfTrace trace, CtfTmfContext context) {
+ private static CtfIterator getIterator(CtfTmfTrace trace, CtfTmfContext context) {
return CtfIteratorManager.getIterator(trace, context);
}
* @return an iterator to the trace
* @since 2.0
*/
- public CtfIterator createIterator(){
+ public CtfIterator createIterator() {
return new CtfIterator(this);
}
}