tmf: Move timestamps to their own package
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui.tests / src / org / eclipse / linuxtools / tmf / ui / tests / views / uml2sd / loader / Uml2SDSignalValidator.java
CommitLineData
73005152 1/*******************************************************************************
df0b8ff4 2 * Copyright (c) 2011, 2012 Ericsson
abbdd66a 3 *
73005152
BH
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
abbdd66a 8 *
73005152
BH
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 *******************************************************************************/
df0b8ff4 12package org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.loader;
73005152 13
6c13869b 14import org.eclipse.linuxtools.tmf.core.component.TmfComponent;
6c13869b
FC
15import org.eclipse.linuxtools.tmf.core.signal.TmfEndSynchSignal;
16import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
17import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
18import org.eclipse.linuxtools.tmf.core.signal.TmfStartSynchSignal;
19import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
3bd46eef
AM
20import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
21import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
73005152
BH
22
23/**
abbdd66a 24 * Class to implement that certain signals are sent as well as are sent with correct content.
64636df8
BH
25 *
26 * @author Bernd Hufmann
73005152
BH
27 */
28public class Uml2SDSignalValidator extends TmfComponent implements IUml2SdSignalValidator {
abbdd66a 29
73005152
BH
30 // ------------------------------------------------------------------------
31 // Attributes
32 // ------------------------------------------------------------------------
33 private int fSignalDepth = 0;
34 private boolean fIsSignalReceived = false;
35 private boolean fIsSignalError = false;
36 private boolean fIsSourceError = false;
37 private boolean fIsCurrentTimeError = false;
38 private boolean fIsRangeError = false;
39
40 private Object fSource = null;
41 private TmfTimestamp fCurrentTimestamp = null;
42 private TmfTimeRange fCurrentTimeRange = null;
43
44 // ------------------------------------------------------------------------
45 // Constructor
46 // ------------------------------------------------------------------------
64636df8
BH
47 /**
48 * Constructor
49 */
73005152
BH
50 public Uml2SDSignalValidator() {
51 }
abbdd66a 52
73005152
BH
53 // ------------------------------------------------------------------------
54 // Operations
55 // ------------------------------------------------------------------------
64636df8
BH
56 /**
57 * Signal handler for time synch signal.
58 * @param signal the signal to handle.
59 */
73005152
BH
60 @TmfSignalHandler
61 public void synchToTime(TmfTimeSynchSignal signal) {
abbdd66a 62 // Set results so that it can be validated in the test case
73005152
BH
63 setSignalReceived(true);
64 setSourceError(getSource() != signal.getSource());
65 setCurrentTimeError(!getCurrentTime().equals(signal.getCurrentTime()));
66 }
67
64636df8
BH
68 /**
69 * Signal handler for time range synch signal.
70 * @param signal the signal to handle.
71 */
73005152
BH
72 @TmfSignalHandler
73 public void synchToTimeRange(TmfRangeSynchSignal signal) {
abbdd66a 74 // Set results so that it can be validated in the test case
73005152
BH
75 setSignalReceived(true);
76 setSourceError(getSource() != signal.getSource());
77 setCurrentTimeError(!getCurrentTime().equals(signal.getCurrentTime()));
78 setRangeError(!getCurrentRange().equals(signal.getCurrentRange()));
79 }
abbdd66a 80
64636df8
BH
81 /**
82 * Signal handler for handling start synch signal.
83 * @param signal the signal to handle.
84 */
73005152
BH
85 @TmfSignalHandler
86 public void startSynch(TmfStartSynchSignal signal) {
87 fSignalDepth++;
abbdd66a 88 // make sure that the signal which is send by the loader class is not handled by the loader class
73005152 89 // after receiving it. i.e. it must not trigger a another signal
abbdd66a 90
73005152
BH
91 // Set results so that it can be validated in the test case
92 setSignalError(fSignalDepth > 1);
93 }
94
64636df8
BH
95 /**
96 * Signal handler for handling end synch signal.
97 * @param signal the signal to handle.
98 */
73005152
BH
99 @TmfSignalHandler
100 public void endSynch(TmfEndSynchSignal signal) {
101 fSignalDepth = fSignalDepth > 0 ? fSignalDepth - 1 : 0;
102 }
abbdd66a 103
73005152
BH
104 @Override
105 public boolean isSignalReceived() {
106 return fIsSignalReceived;
107 }
108
109 @Override
110 public void setSignalReceived(boolean received) {
111 fIsSignalReceived = received;
112 }
113
114 @Override
115 public boolean isSourceError() {
116 return fIsSourceError;
117 }
118
119 @Override
120 public void setSourceError(boolean fIsSourceError) {
121 this.fIsSourceError = fIsSourceError;
122 }
123
124 @Override
125 public boolean isCurrentTimeError() {
126 return fIsCurrentTimeError;
127 }
128
129 @Override
130 public void setCurrentTimeError(boolean fIsCurrentTimeError) {
131 this.fIsCurrentTimeError = fIsCurrentTimeError;
132 }
133
134 @Override
135 public boolean isRangeError() {
136 return fIsRangeError;
137 }
138
139 @Override
140 public void setRangeError(boolean fIsRangeError) {
141 this.fIsRangeError = fIsRangeError;
142 }
143
144 @Override
145 public boolean isSignalError() {
146 return fIsSignalError;
abbdd66a
AM
147 }
148
73005152
BH
149 @Override
150 public void setSignalError(boolean fIsSignalError) {
151 this.fIsSignalError = fIsSignalError;
152 }
153
154 @Override
155 public Object getSource() {
156 return fSource;
157 }
158
159 @Override
160 public void setSource(Object source) {
161 fSource = source;
162 }
abbdd66a 163
73005152
BH
164 @Override
165 public TmfTimestamp getCurrentTime() {
166 return fCurrentTimestamp;
167 }
168
169 @Override
170 public void setCurrentTime(TmfTimestamp currentTime) {
171 fCurrentTimestamp = currentTime == null ? null : new TmfTimestamp(currentTime);
172 }
173
174 @Override
175 public TmfTimeRange getCurrentRange() {
176 return fCurrentTimeRange;
177 }
178
179 @Override
180 public void setCurrentRange(TmfTimeRange currentRange) {
181 fCurrentTimeRange = currentRange == null ? null : new TmfTimeRange(currentRange);
182 }
abbdd66a 183}
73005152 184
This page took 0.053026 seconds and 5 git commands to generate.