|
1 /* |
|
2 * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 * Variable Tracing Item |
|
17 * |
|
18 */ |
|
19 package com.nokia.traceviewer.engine.dataprocessor; |
|
20 |
|
21 import java.util.LinkedList; |
|
22 |
|
23 /** |
|
24 * Varible tracing item showed in the variableTracingTable |
|
25 */ |
|
26 public class VariableTracingItem { |
|
27 |
|
28 /** |
|
29 * Name of the item |
|
30 */ |
|
31 private final String name; |
|
32 |
|
33 /** |
|
34 * Text to be compared |
|
35 */ |
|
36 private final String textToCompare; |
|
37 |
|
38 /** |
|
39 * Indicates if item needs matching case |
|
40 */ |
|
41 private final boolean matchCase; |
|
42 |
|
43 /** |
|
44 * Number of history items to save in this item |
|
45 */ |
|
46 private final int saveHistory; |
|
47 |
|
48 /** |
|
49 * Linked list containing variable tracing events |
|
50 */ |
|
51 private final LinkedList<VariableTracingEvent> events; |
|
52 |
|
53 /** |
|
54 * Indicates if item has changed since last update |
|
55 */ |
|
56 private boolean changed; |
|
57 |
|
58 /** |
|
59 * Constructor |
|
60 * |
|
61 * @param name |
|
62 * name of the item |
|
63 * @param text |
|
64 * text of the item |
|
65 * @param matchCase |
|
66 * matchcase indicator |
|
67 * @param saveHistory |
|
68 * number of history steps to save |
|
69 */ |
|
70 public VariableTracingItem(String name, String text, boolean matchCase, |
|
71 int saveHistory) { |
|
72 // Create the linked list |
|
73 events = new LinkedList<VariableTracingEvent>(); |
|
74 this.name = name; |
|
75 this.matchCase = matchCase; |
|
76 |
|
77 // Always save at least 1 |
|
78 if (saveHistory < 1) { |
|
79 this.saveHistory = 1; |
|
80 } else { |
|
81 this.saveHistory = saveHistory; |
|
82 } |
|
83 |
|
84 // Save text to compare |
|
85 if (matchCase || text == null) { |
|
86 textToCompare = text; |
|
87 } else { |
|
88 textToCompare = text.toLowerCase(); |
|
89 } |
|
90 } |
|
91 |
|
92 /** |
|
93 * Tells the status of changed attribute |
|
94 * |
|
95 * @return the changed |
|
96 */ |
|
97 public boolean isChanged() { |
|
98 return changed; |
|
99 } |
|
100 |
|
101 /** |
|
102 * Sets changed attribute |
|
103 * |
|
104 * @param changed |
|
105 * the changed to set |
|
106 */ |
|
107 public void setChanged(boolean changed) { |
|
108 this.changed = changed; |
|
109 } |
|
110 |
|
111 /** |
|
112 * Tells the status of match case attribute |
|
113 * |
|
114 * @return the matchCase |
|
115 */ |
|
116 public boolean isMatchCase() { |
|
117 return matchCase; |
|
118 } |
|
119 |
|
120 /** |
|
121 * Gets the name |
|
122 * |
|
123 * @return the name |
|
124 */ |
|
125 public String getName() { |
|
126 return name; |
|
127 } |
|
128 |
|
129 /** |
|
130 * Gets text to compare |
|
131 * |
|
132 * @return the text to compare |
|
133 */ |
|
134 public String getTextToCompare() { |
|
135 return textToCompare; |
|
136 } |
|
137 |
|
138 /** |
|
139 * Adds new variable tracing event to the list |
|
140 * |
|
141 * @param event |
|
142 * the event |
|
143 */ |
|
144 public void addEvent(VariableTracingEvent event) { |
|
145 if (events.size() >= saveHistory) { |
|
146 events.removeLast(); |
|
147 } |
|
148 events.addFirst(event); |
|
149 } |
|
150 |
|
151 /** |
|
152 * Gets list of events from this item |
|
153 * |
|
154 * @return list of events |
|
155 */ |
|
156 public LinkedList<VariableTracingEvent> getEventList() { |
|
157 return events; |
|
158 } |
|
159 |
|
160 /** |
|
161 * Adds new variable tracing event to the list |
|
162 */ |
|
163 public void clear() { |
|
164 events.clear(); |
|
165 } |
|
166 |
|
167 /** |
|
168 * Gets value of the latest item |
|
169 * |
|
170 * @return value of the latest item |
|
171 */ |
|
172 public String getValue() { |
|
173 String value = ""; //$NON-NLS-1$ |
|
174 if (!events.isEmpty()) { |
|
175 value = events.get(0).getValue(); |
|
176 } |
|
177 return value; |
|
178 } |
|
179 } |