1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 École Polytechnique de Montréal
4 * All rights reserved. This program and the accompanying materials are
5 * made 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
10 * Geneviève Bastien - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.tests
.stubs
.analysis
;
15 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
16 import org
.eclipse
.linuxtools
.tmf
.core
.analysis
.TmfAbstractAnalysisModule
;
17 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
20 * Simple analysis type for test
22 public class TestAnalysis
extends TmfAbstractAnalysisModule
{
24 private int output
= 0;
27 * Test parameter. If set, simulate cancellation
29 public static final String PARAM_TEST
= "test";
34 public TestAnalysis() {
39 public boolean canExecute(ITmfTrace trace
) {
44 protected boolean executeAnalysis(final IProgressMonitor monitor
) {
45 if (getParameter(PARAM_TEST
) == null) {
46 throw new RuntimeException("The parameter should be set");
48 /* If PARAM_TEST is set to 0, simulate cancellation */
49 if ((Integer
) getParameter(PARAM_TEST
) == 0) {
52 } else if ((Integer
) getParameter(PARAM_TEST
) == 999) {
53 /* just stay in an infinite loop until cancellation */
54 while (!monitor
.isCanceled()) {
57 return !monitor
.isCanceled();
59 output
= (Integer
) getParameter(PARAM_TEST
);
64 protected void canceling() {
69 public Object
getParameter(String name
) {
70 Object value
= super.getParameter(name
);
71 if ((value
!= null) && name
.equals(PARAM_TEST
) && (value
instanceof String
)) {
72 return Integer
.decode((String
) value
);
78 protected void parameterChanged(String name
) {
83 * Get the analysis output value
85 * @return The analysis output
87 public int getAnalysisOutput() {