tmf: Null-annotate state system API classes
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.core.tests / stubs / org / eclipse / tracecompass / tmf / tests / stubs / analysis / TestStateSystemProvider.java
1 /*******************************************************************************
2 * Copyright (c) 2013 École Polytechnique de Montréal
3 *
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
8 *
9 * Contributors:
10 * Geneviève Bastien - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.tmf.tests.stubs.analysis;
14
15 import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
16
17 import org.eclipse.jdt.annotation.NonNull;
18 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
19 import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
20 import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException;
21 import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
22 import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
23 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
24 import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
25 import org.eclipse.tracecompass.tmf.core.statesystem.AbstractTmfStateProvider;
26 import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
27 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
28
29 /**
30 * Stub test provider for test state system analysis module
31 *
32 * @author Geneviève Bastien
33 */
34 public class TestStateSystemProvider extends AbstractTmfStateProvider {
35
36 private static final int VERSION = 1;
37 private final String fString = "[]";
38 private int fCount = 0;
39
40 /**
41 * Constructor
42 *
43 * @param trace
44 * The LTTng 2.0 kernel trace directory
45 */
46 public TestStateSystemProvider(@NonNull ITmfTrace trace) {
47 super(trace, TmfEvent.class, "Stub State System");
48 }
49
50 @Override
51 public int getVersion() {
52 return VERSION;
53 }
54
55 @Override
56 public ITmfStateProvider getNewInstance() {
57 return new TestStateSystemProvider(this.getTrace());
58 }
59
60 @Override
61 protected void eventHandle(ITmfEvent event) {
62 ITmfStateSystemBuilder ss = checkNotNull(getStateSystemBuilder());
63
64 /* Just need something to fill the state system */
65 if (fString.equals(event.getContent().getValue())) {
66 try {
67 int quarkId = ss.getQuarkAbsoluteAndAdd("String");
68 int quark = ss.getQuarkRelativeAndAdd(quarkId, fString);
69 ss.modifyAttribute(event.getTimestamp().getValue(), TmfStateValue.newValueInt(fCount++), quark);
70 } catch (TimeRangeException e) {
71
72 } catch (AttributeNotFoundException e) {
73
74 } catch (StateValueTypeException e) {
75
76 }
77 }
78 }
79
80 }
This page took 0.031372 seconds and 5 git commands to generate.