* behavior to some methods of the analysis module
*
* @author Geneviève Bastien
- * @since 3.0
*/
@NonNullByDefault
public abstract class TmfAbstractAnalysisModule extends TmfComponent implements IAnalysisModule {
public String getId() {
String id = fId;
if (id == null) {
- id = new String(this.getClass().getCanonicalName());
+ id = this.getClass().getCanonicalName();
+ if (id == null) {
+ /*
+ * Some types, like anonymous classes, don't have a canonical
+ * name. Just use the default name instead.
+ */
+ id = checkNotNull(this.getClass().getName());
+ }
fId = id;
}
return id;
fAutomatic = auto;
}
+ /**
+ * @since 1.0
+ */
@Override
- public void setTrace(ITmfTrace trace) throws TmfAnalysisException {
+ public boolean setTrace(ITmfTrace trace) throws TmfAnalysisException {
if (fTrace != null) {
throw new TmfAnalysisException(NLS.bind(Messages.TmfAbstractAnalysisModule_TraceSetMoreThanOnce, getName()));
}
/* Check that analysis can be executed */
if (!canExecute(trace)) {
- throw new TmfAnalysisException(NLS.bind(Messages.TmfAbstractAnalysisModule_AnalysisCannotExecute, getName()));
+ return false;
}
fTrace = trace;
}
resetAnalysis();
fStarted = false;
+ return true;
}
/**
public final void cancel() {
synchronized (syncObj) {
TmfCoreTracer.traceAnalysis(getId(), getTrace(), "cancelled by application"); //$NON-NLS-1$
- if (fJob != null) {
- if (fJob.cancel()) {
- fAnalysisCancelled = true;
- setAnalysisCompleted();
- }
+ if (fJob != null && fJob.cancel()) {
+ fAnalysisCancelled = true;
+ setAnalysisCompleted();
}
fStarted = false;
}
*
* @param signal
* Trace selected signal
- * @since 3.1
*/
@TmfSignalHandler
public void traceSelected(TmfTraceSelectedSignal signal) {