tmf: remove deprecated methods from tmf
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / tmf / core / parsers / custom / CustomXmlInputElement.java
1 /*******************************************************************************
2 * Copyright (c) 2014, 2016 Ericsson
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 * Patrick Tasse - Initial API and implementation
11 * Matthew Khouzam - Pulled out class
12 *******************************************************************************/
13
14 package org.eclipse.tracecompass.tmf.core.parsers.custom;
15
16 import java.util.ArrayList;
17 import java.util.List;
18
19 import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTraceDefinition.Tag;
20
21 /**
22 * Wrapper for input XML elements
23 */
24 public final class CustomXmlInputElement {
25
26 /** Name of the element */
27 private String fElementName;
28
29 /** Indicates if this is a log entry */
30 private boolean fLogEntry;
31
32 /** Tag of the input element */
33 private Tag fInputTag;
34
35 /** Name of the input element */
36 private String fInputName;
37
38 /** Input action */
39 private int fInputAction;
40
41 /** Input format */
42 private String fInputFormat;
43
44 /** XML attributes of this element */
45 private List<CustomXmlInputAttribute> fAttributes;
46
47 /** Parent element */
48 private CustomXmlInputElement fParentElement;
49
50 /** Following element in the file */
51 private CustomXmlInputElement fNextElement;
52
53 /** Child elements */
54 private List<CustomXmlInputElement> fChildElements;
55
56 /** Event type associated with this input element */
57 private String fEventType;
58
59 /**
60 * Default (empty) constructor
61 */
62 public CustomXmlInputElement() {
63 }
64
65 /**
66 * Constructor
67 *
68 * @param elementName
69 * Element name
70 * @param logEntry
71 * If this element is a log entry
72 * @param inputTag
73 * Tag of the input
74 * @param inputName
75 * Name of the input
76 * @param inputAction
77 * Input action
78 * @param inputFormat
79 * Input format
80 * @param attributes
81 * XML attributes of this element
82 * @since 2.1
83 */
84 public CustomXmlInputElement(String elementName, boolean logEntry, Tag inputTag,
85 String inputName, int inputAction, String inputFormat,
86 List<CustomXmlInputAttribute> attributes) {
87 fElementName = elementName;
88 fLogEntry = logEntry;
89 fInputTag = inputTag;
90 fInputName = inputName;
91 fInputAction = inputAction;
92 fInputFormat = inputFormat;
93 fAttributes = attributes;
94 }
95
96 /**
97 * Add a XML attribute to the element
98 *
99 * @param attribute
100 * The attribute to add
101 */
102 public void addAttribute(CustomXmlInputAttribute attribute) {
103 if (getAttributes() == null) {
104 fAttributes = new ArrayList<>(1);
105 }
106 getAttributes().add(attribute);
107 }
108
109 /**
110 * Add a child element to this one.
111 *
112 * @param input
113 * The input element to add as child
114 */
115 public void addChild(CustomXmlInputElement input) {
116 if (getChildElements() == null) {
117 fChildElements = new ArrayList<>(1);
118 } else if (getChildElements().size() > 0) {
119 CustomXmlInputElement last = getChildElements().get(getChildElements().size() - 1);
120 last.fNextElement = input;
121 }
122 getChildElements().add(input);
123 input.setParentElement(this);
124 }
125
126 /**
127 * Set the following input element.
128 *
129 * @param input
130 * The input element to add as next element
131 */
132 public void addNext(CustomXmlInputElement input) {
133 if (getParentElement() != null) {
134 int index = getParentElement().getChildElements().indexOf(this);
135 getParentElement().getChildElements().add(index + 1, input);
136 CustomXmlInputElement next = getNextElement();
137 fNextElement = input;
138 input.fNextElement = next;
139 }
140 input.setParentElement(getParentElement());
141 }
142
143 /**
144 * Move this element up in its parent's list of children.
145 */
146 public void moveUp() {
147 if (getParentElement() != null) {
148 int index = getParentElement().getChildElements().indexOf(this);
149 if (index > 0) {
150 getParentElement().getChildElements().add(index - 1, getParentElement().getChildElements().remove(index));
151 getParentElement().getChildElements().get(index).fNextElement = fNextElement;
152 fNextElement = getParentElement().getChildElements().get(index);
153 }
154 }
155 }
156
157 /**
158 * Move this element down in its parent's list of children.
159 */
160 public void moveDown() {
161 if (getParentElement() != null) {
162 int index = getParentElement().getChildElements().indexOf(this);
163 if (index < getParentElement().getChildElements().size() - 1) {
164 getParentElement().getChildElements().add(index + 1, getParentElement().getChildElements().remove(index));
165 fNextElement = getParentElement().getChildElements().get(index).getNextElement();
166 getParentElement().getChildElements().get(index).fNextElement = this;
167 }
168 }
169 }
170
171 /**
172 * Get the element name
173 *
174 * @return the element name
175 */
176 public String getElementName() {
177 return fElementName;
178 }
179
180 /**
181 * Set the element name
182 *
183 * @param elementName
184 * the element name
185 */
186 public void setElementName(String elementName) {
187 fElementName = elementName;
188 }
189
190 /**
191 * @return the logEntry
192 */
193 public boolean isLogEntry() {
194 return fLogEntry;
195 }
196
197 /**
198 * @param logEntry
199 * the logEntry to set
200 */
201 public void setLogEntry(boolean logEntry) {
202 fLogEntry = logEntry;
203 }
204
205 /**
206 * @return the inputTag
207 * @since 2.1
208 */
209 public Tag getInputTag() {
210 return fInputTag;
211 }
212
213 /**
214 * @param inputTag
215 * the inputTag to set
216 * @since 2.1
217 */
218 public void setInputTag(Tag inputTag) {
219 fInputTag = inputTag;
220 }
221
222 /**
223 * @return the inputName
224 */
225 public String getInputName() {
226 return fInputName;
227 }
228
229 /**
230 * @param inputName
231 * the inputName to set
232 */
233 public void setInputName(String inputName) {
234 fInputName = inputName;
235 }
236
237 /**
238 * @return the eventType, or null
239 * @since 2.1
240 */
241 public String getEventType() {
242 return fEventType;
243 }
244
245 /**
246 * @param eventType
247 * the eventType to set, or null
248 * @since 2.1
249 */
250 public void setEventType(String eventType) {
251 fEventType = eventType;
252 }
253
254 /**
255 * @return the inputAction
256 */
257 public int getInputAction() {
258 return fInputAction;
259 }
260
261 /**
262 * @param inputAction
263 * the inputAction to set
264 */
265 public void setInputAction(int inputAction) {
266 fInputAction = inputAction;
267 }
268
269 /**
270 * @return the inputFormat
271 */
272 public String getInputFormat() {
273 return fInputFormat;
274 }
275
276 /**
277 * @param inputFormat
278 * the inputFormat to set
279 */
280 public void setInputFormat(String inputFormat) {
281 fInputFormat = inputFormat;
282 }
283
284 /**
285 * @return the attributes
286 */
287 public List<CustomXmlInputAttribute> getAttributes() {
288 return fAttributes;
289 }
290
291 /**
292 * @param attributes
293 * the attributes to set
294 */
295 public void setAttributes(List<CustomXmlInputAttribute> attributes) {
296 fAttributes = attributes;
297 }
298
299 /**
300 * @return the parentElement
301 */
302 public CustomXmlInputElement getParentElement() {
303 return fParentElement;
304 }
305
306 /**
307 * @param parentElement
308 * the parentElement to set
309 */
310 public void setParentElement(CustomXmlInputElement parentElement) {
311 fParentElement = parentElement;
312 }
313
314 /**
315 * @return the nextElement
316 */
317 public CustomXmlInputElement getNextElement() {
318 return fNextElement;
319 }
320
321 /**
322 * @param nextElement
323 * the nextElement to set
324 */
325 public void setNextElement(CustomXmlInputElement nextElement) {
326 fNextElement = nextElement;
327 }
328
329 /**
330 * @return the childElements
331 */
332 public List<CustomXmlInputElement> getChildElements() {
333 return fChildElements;
334 }
335
336 /**
337 * @param childElements
338 * the childElements to set
339 */
340 public void setChildElements(List<CustomXmlInputElement> childElements) {
341 fChildElements = childElements;
342 }
343
344 }
This page took 0.039676 seconds and 5 git commands to generate.