--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Patrick Tasse - Initial API and implementation
+ * Matthew Khouzam - Pulled out class
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.tmf.core.parsers.custom;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Wrapper for input XML elements
+ */
+public final class CustomXmlInputElement {
+
+ /** Name of the element */
+ private String fElementName;
+
+ /** Indicates if this is a log entry */
+ private boolean fLogEntry;
+
+ /** Name of the input element */
+ private String fInputName;
+
+ /** Input action */
+ private int fInputAction;
+
+ /** Input format */
+ private String fInputFormat;
+
+ /** XML attributes of this element */
+ private List<CustomXmlInputAttribute> fAttributes;
+
+ /** Parent element */
+ private CustomXmlInputElement fParentElement;
+
+ /** Following element in the file */
+ private CustomXmlInputElement fNextElement;
+
+ /** Child elements */
+ private List<CustomXmlInputElement> fChildElements;
+
+ /**
+ * Default (empty) constructor
+ */
+ public CustomXmlInputElement() {
+ }
+
+ /**
+ * Constructor
+ *
+ * @param elementName
+ * Element name
+ * @param logEntry
+ * If this element is a log entry
+ * @param inputName
+ * Name of the the input
+ * @param inputAction
+ * Input action
+ * @param inputFormat
+ * Input format
+ * @param attributes
+ * XML attributes of this element
+ */
+ public CustomXmlInputElement(String elementName, boolean logEntry,
+ String inputName, int inputAction, String inputFormat,
+ List<CustomXmlInputAttribute> attributes) {
+ fElementName = elementName;
+ fLogEntry = logEntry;
+ fInputName = inputName;
+ fInputAction = inputAction;
+ fInputFormat = inputFormat;
+ fAttributes = attributes;
+ }
+
+ /**
+ * Add a XML attribute to the element
+ *
+ * @param attribute
+ * The attribute to add
+ */
+ public void addAttribute(CustomXmlInputAttribute attribute) {
+ if (getAttributes() == null) {
+ fAttributes = new ArrayList<>(1);
+ }
+ getAttributes().add(attribute);
+ }
+
+ /**
+ * Add a child element to this one.
+ *
+ * @param input
+ * The input element to add as child
+ */
+ public void addChild(CustomXmlInputElement input) {
+ if (getChildElements() == null) {
+ fChildElements = new ArrayList<>(1);
+ } else if (getChildElements().size() > 0) {
+ CustomXmlInputElement last = getChildElements().get(getChildElements().size() - 1);
+ last.fNextElement = input;
+ }
+ getChildElements().add(input);
+ input.setParentElement(this);
+ }
+
+ /**
+ * Set the following input element.
+ *
+ * @param input
+ * The input element to add as next element
+ */
+ public void addNext(CustomXmlInputElement input) {
+ if (getParentElement() != null) {
+ int index = getParentElement().getChildElements().indexOf(this);
+ getParentElement().getChildElements().add(index + 1, input);
+ CustomXmlInputElement next = getNextElement();
+ fNextElement = input;
+ input.fNextElement = next;
+ }
+ input.setParentElement(getParentElement());
+ }
+
+ /**
+ * Move this element up in its parent's list of children.
+ */
+ public void moveUp() {
+ if (getParentElement() != null) {
+ int index = getParentElement().getChildElements().indexOf(this);
+ if (index > 0) {
+ getParentElement().getChildElements().add(index - 1, getParentElement().getChildElements().remove(index));
+ getParentElement().getChildElements().get(index).fNextElement = fNextElement;
+ fNextElement = getParentElement().getChildElements().get(index);
+ }
+ }
+ }
+
+ /**
+ * Move this element down in its parent's list of children.
+ */
+ public void moveDown() {
+ if (getParentElement() != null) {
+ int index = getParentElement().getChildElements().indexOf(this);
+ if (index < getParentElement().getChildElements().size() - 1) {
+ getParentElement().getChildElements().add(index + 1, getParentElement().getChildElements().remove(index));
+ fNextElement = getParentElement().getChildElements().get(index).getNextElement();
+ getParentElement().getChildElements().get(index).fNextElement = this;
+ }
+ }
+ }
+
+ /**
+ * Get the element name
+ *
+ * @return the element name
+ */
+ public String getElementName() {
+ return fElementName;
+ }
+
+ /**
+ * Set the element name
+ *
+ * @param elementName
+ * the element name
+ */
+ public void setElementName(String elementName) {
+ fElementName = elementName;
+ }
+
+ /**
+ * @return the logEntry
+ */
+ public boolean isLogEntry() {
+ return fLogEntry;
+ }
+
+ /**
+ * @param logEntry
+ * the logEntry to set
+ */
+ public void setLogEntry(boolean logEntry) {
+ fLogEntry = logEntry;
+ }
+
+ /**
+ * @return the inputName
+ */
+ public String getInputName() {
+ return fInputName;
+ }
+
+ /**
+ * @param inputName
+ * the inputName to set
+ */
+ public void setInputName(String inputName) {
+ fInputName = inputName;
+ }
+
+ /**
+ * @return the inputAction
+ */
+ public int getInputAction() {
+ return fInputAction;
+ }
+
+ /**
+ * @param inputAction
+ * the inputAction to set
+ */
+ public void setInputAction(int inputAction) {
+ fInputAction = inputAction;
+ }
+
+ /**
+ * @return the inputFormat
+ */
+ public String getInputFormat() {
+ return fInputFormat;
+ }
+
+ /**
+ * @param inputFormat
+ * the inputFormat to set
+ */
+ public void setInputFormat(String inputFormat) {
+ fInputFormat = inputFormat;
+ }
+
+ /**
+ * @return the attributes
+ */
+ public List<CustomXmlInputAttribute> getAttributes() {
+ return fAttributes;
+ }
+
+ /**
+ * @param attributes
+ * the attributes to set
+ */
+ public void setAttributes(List<CustomXmlInputAttribute> attributes) {
+ fAttributes = attributes;
+ }
+
+ /**
+ * @return the parentElement
+ */
+ public CustomXmlInputElement getParentElement() {
+ return fParentElement;
+ }
+
+ /**
+ * @param parentElement
+ * the parentElement to set
+ */
+ public void setParentElement(CustomXmlInputElement parentElement) {
+ fParentElement = parentElement;
+ }
+
+ /**
+ * @return the nextElement
+ */
+ public CustomXmlInputElement getNextElement() {
+ return fNextElement;
+ }
+
+ /**
+ * @param nextElement
+ * the nextElement to set
+ */
+ public void setNextElement(CustomXmlInputElement nextElement) {
+ fNextElement = nextElement;
+ }
+
+ /**
+ * @return the childElements
+ */
+ public List<CustomXmlInputElement> getChildElements() {
+ return fChildElements;
+ }
+
+ /**
+ * @param childElements
+ * the childElements to set
+ */
+ public void setChildElements(List<CustomXmlInputElement> childElements) {
+ fChildElements = childElements;
+ }
+
+}
\ No newline at end of file
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
import org.eclipse.tracecompass.tmf.core.io.BufferedRandomAccessFile;
-import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTraceDefinition.InputAttribute;
-import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTraceDefinition.InputElement;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.core.trace.ITmfEventParser;
private final CustomXmlTraceDefinition fDefinition;
private final CustomXmlEventType fEventType;
- private final InputElement fRecordInputElement;
+ private final CustomXmlInputElement fRecordInputElement;
private BufferedRandomAccessFile fFile;
/**
long rawPos = fFile.getFilePointer();
String line = fFile.getNextLine();
while (line != null) {
- final int idx = indexOfElement(fRecordInputElement.elementName, line, 0);
+ final int idx = indexOfElement(fRecordInputElement.getElementName(), line, 0);
if (idx != -1) {
context.setLocation(new TmfLongLocation(rawPos + idx));
return context;
CustomXmlEvent event = null;
try {
- if (fFile.getFilePointer() != (Long) context.getLocation().getLocationInfo() + 1)
- {
- fFile.seek((Long) context.getLocation().getLocationInfo() + 1); // +1 is for the <
+ // Below +1 for the <
+ if (fFile.getFilePointer() != (Long) context.getLocation().getLocationInfo() + 1) {
+ fFile.seek((Long) context.getLocation().getLocationInfo() + 1);
}
final StringBuffer elementBuffer = new StringBuffer("<"); //$NON-NLS-1$
readElement(elementBuffer, fFile);
long rawPos = fFile.getFilePointer();
String line = fFile.getNextLine();
while (line != null) {
- final int idx = indexOfElement(fRecordInputElement.elementName, line, 0);
+ final int idx = indexOfElement(fRecordInputElement.getElementName(), line, 0);
if (idx != -1) {
context.setLocation(new TmfLongLocation(rawPos + idx));
return event;
// The following catches xml parsing exceptions
db.setErrorHandler(new ErrorHandler() {
@Override
- public void error(final SAXParseException saxparseexception) throws SAXException {}
+ public void error(final SAXParseException saxparseexception) throws SAXException {
+ }
@Override
- public void warning(final SAXParseException saxparseexception) throws SAXException {}
+ public void warning(final SAXParseException saxparseexception) throws SAXException {
+ }
@Override
public void fatalError(final SAXParseException saxparseexception) throws SAXException {
* The main element to check for.
* @return The record element
*/
- public InputElement getRecordInputElement(final InputElement inputElement) {
- if (inputElement.logEntry) {
+ public CustomXmlInputElement getRecordInputElement(final CustomXmlInputElement inputElement) {
+ if (inputElement.isLogEntry()) {
return inputElement;
- } else if (inputElement.childElements != null) {
- for (final InputElement childInputElement : inputElement.childElements) {
- final InputElement recordInputElement = getRecordInputElement(childInputElement);
+ } else if (inputElement.getChildElements() != null) {
+ for (final CustomXmlInputElement childInputElement : inputElement.getChildElements()) {
+ final CustomXmlInputElement recordInputElement = getRecordInputElement(childInputElement);
if (recordInputElement != null) {
return recordInputElement;
}
* The input element
* @return The extracted event
*/
- public CustomXmlEvent extractEvent(final Element element, final InputElement inputElement) {
+ public CustomXmlEvent extractEvent(final Element element, final CustomXmlInputElement inputElement) {
final CustomXmlEvent event = new CustomXmlEvent(fDefinition, this, TmfTimestamp.ZERO, fEventType);
event.setContent(new CustomEventContent(event, new StringBuffer()));
parseElement(element, event, inputElement);
return event;
}
- private void parseElement(final Element element, final CustomXmlEvent event, final InputElement inputElement) {
- if (inputElement.inputName != null && !inputElement.inputName.equals(CustomXmlTraceDefinition.TAG_IGNORE)) {
- event.parseInput(parseElement(element, new StringBuffer()).toString(), inputElement.inputName, inputElement.inputAction, inputElement.inputFormat);
+ private void parseElement(final Element element, final CustomXmlEvent event, final CustomXmlInputElement inputElement) {
+ if (inputElement.getInputName() != null && !inputElement.getInputName().equals(CustomXmlTraceDefinition.TAG_IGNORE)) {
+ event.parseInput(parseElement(element, new StringBuffer()).toString(), inputElement.getInputName(), inputElement.getInputAction(), inputElement.getInputFormat());
}
- if (inputElement.attributes != null) {
- for (final InputAttribute attribute : inputElement.attributes) {
- event.parseInput(element.getAttribute(attribute.attributeName), attribute.inputName, attribute.inputAction, attribute.inputFormat);
+ if (inputElement.getAttributes() != null) {
+ for (final CustomXmlInputAttribute attribute : inputElement.getAttributes()) {
+ event.parseInput(element.getAttribute(attribute.getAttributeName()), attribute.getInputName(), attribute.getInputAction(), attribute.getInputFormat());
}
}
final NodeList childNodes = element.getChildNodes();
- if (inputElement.childElements != null) {
+ if (inputElement.getChildElements() != null) {
for (int i = 0; i < childNodes.getLength(); i++) {
final Node node = childNodes.item(i);
if (node instanceof Element) {
- for (final InputElement child : inputElement.childElements) {
- if (node.getNodeName().equals(child.elementName)) {
+ for (final CustomXmlInputElement child : inputElement.getChildElements()) {
+ if (node.getNodeName().equals(child.getElementName())) {
parseElement((Element) node, event, child);
break;
}
long rawPos = 0;
String line = rafile.getNextLine();
while ((line != null) && (lineCount++ < MAX_LINES)) {
- final int idx = indexOfElement(fRecordInputElement.elementName, line, 0);
+ final int idx = indexOfElement(fRecordInputElement.getElementName(), line, 0);
if (idx != -1) {
rafile.seek(rawPos + idx + 1); // +1 is for the <
final StringBuffer elementBuffer = new StringBuffer("<"); //$NON-NLS-1$
private static final String OUTPUT_COLUMN_ELEMENT = Messages.CustomXmlTraceDefinition_outputColumn;
/** Top-level input element */
- public InputElement rootInputElement;
+ public CustomXmlInputElement rootInputElement;
/**
* Default constructor
* The list of output columns
* @param timeStampOutputFormat
* The timestamp format to use
- * @deprecated Use {@link #CustomXmlTraceDefinition(String, String, InputElement, List, String)}
+ * @deprecated Use
+ * {@link #CustomXmlTraceDefinition(String, String, CustomXmlInputElement, List, String)}
*/
@Deprecated
- public CustomXmlTraceDefinition(String traceType, InputElement rootElement,
+ public CustomXmlTraceDefinition(String traceType, CustomXmlInputElement rootElement,
List<OutputColumn> outputs, String timeStampOutputFormat) {
this.definitionName = traceType;
this.rootInputElement = rootElement;
* The timestamp format to use
* @since 3.2
*/
- public CustomXmlTraceDefinition(String category, String traceType, InputElement rootElement,
+ public CustomXmlTraceDefinition(String category, String traceType, CustomXmlInputElement rootElement,
List<OutputColumn> outputs, String timeStampOutputFormat) {
this.categoryName = category;
this.definitionName = traceType;
this.timeStampOutputFormat = timeStampOutputFormat;
}
- /**
- * Wrapper for input XML elements
- */
- public static class InputElement {
-
- /** Name of the element */
- public String elementName;
-
- /** Indicates if this is a log entry */
- public boolean logEntry;
-
- /** Name of the input element */
- public String inputName;
-
- /** Input action */
- public int inputAction;
-
- /** Input format */
- public String inputFormat;
-
- /** XML attributes of this element */
- public List<InputAttribute> attributes;
-
- /** Parent element */
- public InputElement parentElement;
-
- /** Following element in the file */
- public InputElement nextElement;
-
- /** Child elements */
- public List<InputElement> childElements;
-
- /**
- * Default (empty) constructor
- */
- public InputElement() {
- }
-
- /**
- * Constructor
- *
- * @param elementName
- * Element name
- * @param logEntry
- * If this element is a log entry
- * @param inputName
- * Name of the the input
- * @param inputAction
- * Input action
- * @param inputFormat
- * Input format
- * @param attributes
- * XML attributes of this element
- */
- public InputElement(String elementName, boolean logEntry,
- String inputName, int inputAction, String inputFormat,
- List<InputAttribute> attributes) {
- this.elementName = elementName;
- this.logEntry = logEntry;
- this.inputName = inputName;
- this.inputAction = inputAction;
- this.inputFormat = inputFormat;
- this.attributes = attributes;
- }
-
- /**
- * Add a XML attribute to the element
- *
- * @param attribute
- * The attribute to add
- */
- public void addAttribute(InputAttribute attribute) {
- if (attributes == null) {
- attributes = new ArrayList<>(1);
- }
- attributes.add(attribute);
- }
-
- /**
- * Add a child element to this one.
- *
- * @param input
- * The input element to add as child
- */
- public void addChild(InputElement input) {
- if (childElements == null) {
- childElements = new ArrayList<>(1);
- } else if (childElements.size() > 0) {
- InputElement last = childElements.get(childElements.size() - 1);
- last.nextElement = input;
- }
- childElements.add(input);
- input.parentElement = this;
- }
-
- /**
- * Set the following input element.
- *
- * @param input
- * The input element to add as next element
- */
- public void addNext(InputElement input) {
- if (parentElement != null) {
- int index = parentElement.childElements.indexOf(this);
- parentElement.childElements.add(index + 1, input);
- InputElement next = nextElement;
- nextElement = input;
- input.nextElement = next;
- }
- input.parentElement = this.parentElement;
- }
-
- /**
- * Move this element up in its parent's list of children.
- */
- public void moveUp() {
- if (parentElement != null) {
- int index = parentElement.childElements.indexOf(this);
- if (index > 0) {
- parentElement.childElements.add(index - 1, parentElement.childElements.remove(index));
- parentElement.childElements.get(index).nextElement = nextElement;
- nextElement = parentElement.childElements.get(index);
- }
- }
- }
-
- /**
- * Move this element down in its parent's list of children.
- */
- public void moveDown() {
- if (parentElement != null) {
- int index = parentElement.childElements.indexOf(this);
- if (index < parentElement.childElements.size() - 1) {
- parentElement.childElements.add(index + 1, parentElement.childElements.remove(index));
- nextElement = parentElement.childElements.get(index).nextElement;
- parentElement.childElements.get(index).nextElement = this;
- }
- }
- }
-
- }
-
- /**
- * Wrapper for XML element attributes
- */
- public static class InputAttribute {
-
- /** Name of the XML attribute */
- public String attributeName;
-
- /** Input name */
- public String inputName;
-
- /** Input action */
- public int inputAction;
-
- /** Input format */
- public String inputFormat;
-
- /**
- * Default (empty) constructor
- */
- public InputAttribute() {
- }
-
- /**
- * Constructor
- *
- * @param attributeName
- * Name of the XML attribute
- * @param inputName
- * Input name
- * @param inputAction
- * Input action
- * @param inputFormat
- * Input format
- */
- public InputAttribute(String attributeName, String inputName,
- int inputAction, String inputFormat) {
- this.attributeName = attributeName;
- this.inputName = inputName;
- this.inputAction = inputAction;
- this.inputFormat = inputFormat;
- }
- }
-
@Override
public void save() {
save(CUSTOM_XML_TRACE_DEFINITIONS_PATH_NAME);
}
}
- private Element createInputElementElement(InputElement inputElement, Document doc) {
+ private Element createInputElementElement(CustomXmlInputElement inputElement, Document doc) {
Element inputElementElement = doc.createElement(INPUT_ELEMENT_ELEMENT);
- inputElementElement.setAttribute(NAME_ATTRIBUTE, inputElement.elementName);
+ inputElementElement.setAttribute(NAME_ATTRIBUTE, inputElement.getElementName());
- if (inputElement.logEntry) {
- inputElementElement.setAttribute(LOG_ENTRY_ATTRIBUTE, Boolean.toString(inputElement.logEntry));
+ if (inputElement.isLogEntry()) {
+ inputElementElement.setAttribute(LOG_ENTRY_ATTRIBUTE, Boolean.toString(inputElement.isLogEntry()));
}
- if (inputElement.parentElement != null) {
+ if (inputElement.getParentElement() != null) {
Element inputDataElement = doc.createElement(INPUT_DATA_ELEMENT);
inputElementElement.appendChild(inputDataElement);
- inputDataElement.setAttribute(NAME_ATTRIBUTE, inputElement.inputName);
- inputDataElement.setAttribute(ACTION_ATTRIBUTE, Integer.toString(inputElement.inputAction));
- if (inputElement.inputFormat != null) {
- inputDataElement.setAttribute(FORMAT_ATTRIBUTE, inputElement.inputFormat);
+ inputDataElement.setAttribute(NAME_ATTRIBUTE, inputElement.getInputName());
+ inputDataElement.setAttribute(ACTION_ATTRIBUTE, Integer.toString(inputElement.getInputAction()));
+ if (inputElement.getInputFormat() != null) {
+ inputDataElement.setAttribute(FORMAT_ATTRIBUTE, inputElement.getInputFormat());
}
}
- if (inputElement.attributes != null) {
- for (InputAttribute attribute : inputElement.attributes) {
+ if (inputElement.getAttributes() != null) {
+ for (CustomXmlInputAttribute attribute : inputElement.getAttributes()) {
Element inputAttributeElement = doc.createElement(ATTRIBUTE_ELEMENT);
inputElementElement.appendChild(inputAttributeElement);
- inputAttributeElement.setAttribute(NAME_ATTRIBUTE, attribute.attributeName);
+ inputAttributeElement.setAttribute(NAME_ATTRIBUTE, attribute.getAttributeName());
Element inputDataElement = doc.createElement(INPUT_DATA_ELEMENT);
inputAttributeElement.appendChild(inputDataElement);
- inputDataElement.setAttribute(NAME_ATTRIBUTE, attribute.inputName);
- inputDataElement.setAttribute(ACTION_ATTRIBUTE, Integer.toString(attribute.inputAction));
- if (attribute.inputFormat != null) {
- inputDataElement.setAttribute(FORMAT_ATTRIBUTE, attribute.inputFormat);
+ inputDataElement.setAttribute(NAME_ATTRIBUTE, attribute.getInputName());
+ inputDataElement.setAttribute(ACTION_ATTRIBUTE, Integer.toString(attribute.getInputAction()));
+ if (attribute.getInputFormat() != null) {
+ inputDataElement.setAttribute(FORMAT_ATTRIBUTE, attribute.getInputFormat());
}
}
}
- if (inputElement.childElements != null) {
- for (InputElement childInputElement : inputElement.childElements) {
+ if (inputElement.getChildElements() != null) {
+ for (CustomXmlInputElement childInputElement : inputElement.getChildElements()) {
inputElementElement.appendChild(createInputElementElement(childInputElement, doc));
}
}
Element formatElement = (Element) node;
def.timeStampOutputFormat = formatElement.getTextContent();
} else if (nodeName.equals(INPUT_ELEMENT_ELEMENT)) {
- InputElement inputElement = extractInputElement((Element) node);
+ CustomXmlInputElement inputElement = extractInputElement((Element) node);
if (inputElement != null) {
if (def.rootInputElement == null) {
def.rootInputElement = inputElement;
return def;
}
- private static InputElement extractInputElement(Element inputElementElement) {
- InputElement inputElement = new InputElement();
- inputElement.elementName = inputElementElement.getAttribute(NAME_ATTRIBUTE);
- inputElement.logEntry = (Boolean.toString(true).equals(inputElementElement.getAttribute(LOG_ENTRY_ATTRIBUTE))) ? true : false;
+ private static CustomXmlInputElement extractInputElement(Element inputElementElement) {
+ CustomXmlInputElement inputElement = new CustomXmlInputElement();
+ inputElement.setElementName(inputElementElement.getAttribute(NAME_ATTRIBUTE));
+ inputElement.setLogEntry((Boolean.toString(true).equals(inputElementElement.getAttribute(LOG_ENTRY_ATTRIBUTE))) ? true : false);
NodeList nodeList = inputElementElement.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
String nodeName = node.getNodeName();
if (nodeName.equals(INPUT_DATA_ELEMENT)) {
Element inputDataElement = (Element) node;
- inputElement.inputName = inputDataElement.getAttribute(NAME_ATTRIBUTE);
- inputElement.inputAction = Integer.parseInt(inputDataElement.getAttribute(ACTION_ATTRIBUTE));
- inputElement.inputFormat = inputDataElement.getAttribute(FORMAT_ATTRIBUTE);
+ inputElement.setInputName(inputDataElement.getAttribute(NAME_ATTRIBUTE));
+ inputElement.setInputAction(Integer.parseInt(inputDataElement.getAttribute(ACTION_ATTRIBUTE)));
+ inputElement.setInputFormat(inputDataElement.getAttribute(FORMAT_ATTRIBUTE));
} else if (nodeName.equals(ATTRIBUTE_ELEMENT)) {
Element attributeElement = (Element) node;
- InputAttribute attribute = new InputAttribute();
- attribute.attributeName = attributeElement.getAttribute(NAME_ATTRIBUTE);
+
+ String attributeName = attributeElement.getAttribute(NAME_ATTRIBUTE);
+ String inputName = null;
+ int inputAction = 0;
+ String inputFormat = null;
NodeList attributeNodeList = attributeElement.getChildNodes();
for (int j = 0; j < attributeNodeList.getLength(); j++) {
Node attributeNode = attributeNodeList.item(j);
String attributeNodeName = attributeNode.getNodeName();
if (attributeNodeName.equals(INPUT_DATA_ELEMENT)) {
Element inputDataElement = (Element) attributeNode;
- attribute.inputName = inputDataElement.getAttribute(NAME_ATTRIBUTE);
- attribute.inputAction = Integer.parseInt(inputDataElement.getAttribute(ACTION_ATTRIBUTE));
- attribute.inputFormat = inputDataElement.getAttribute(FORMAT_ATTRIBUTE);
+ inputName = inputDataElement.getAttribute(NAME_ATTRIBUTE);
+ inputAction = Integer.parseInt(inputDataElement.getAttribute(ACTION_ATTRIBUTE));
+ inputFormat = inputDataElement.getAttribute(FORMAT_ATTRIBUTE);
}
}
- inputElement.addAttribute(attribute);
+ inputElement.addAttribute(new CustomXmlInputAttribute(attributeName, inputName, inputAction, inputFormat));
} else if (nodeName.equals(INPUT_ELEMENT_ELEMENT)) {
Element childInputElementElement = (Element) node;
- InputElement childInputElement = extractInputElement(childInputElementElement);
+ CustomXmlInputElement childInputElement = extractInputElement(childInputElementElement);
if (childInputElement != null) {
inputElement.addChild(childInputElement);
}
import org.eclipse.tracecompass.internal.tmf.ui.Activator;
import org.eclipse.tracecompass.internal.tmf.ui.Messages;
import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTraceDefinition;
+import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlInputElement;
import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTrace;
import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTraceDefinition;
-import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTraceDefinition.InputAttribute;
-import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTraceDefinition.InputElement;
+import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlInputAttribute;
import org.eclipse.tracecompass.tmf.core.project.model.TmfTraceType;
import org.eclipse.tracecompass.tmf.core.project.model.TraceTypeHelper;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat;
return;
}
removeElement();
- InputElement inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
+ CustomXmlInputElement inputElement = (CustomXmlInputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
if (inputElement == definition.rootInputElement) {
definition.rootInputElement = null;
} else {
- inputElement.parentElement.childElements.remove(inputElement);
+ inputElement.getParentElement().getChildElements().remove(inputElement);
}
treeViewer.refresh();
validate();
addChildButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- InputElement inputElement = new InputElement("", false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$ //$NON-NLS-2$
+ CustomXmlInputElement inputElement = new CustomXmlInputElement("", false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$ //$NON-NLS-2$
if (definition.rootInputElement == null) {
definition.rootInputElement = inputElement;
- inputElement.elementName = getChildNameSuggestion(null);
+ inputElement.setElementName(getChildNameSuggestion(null));
} else if (treeViewer.getSelection().isEmpty()) {
return;
} else {
- InputElement parentInputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
+ CustomXmlInputElement parentInputElement = (CustomXmlInputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
parentInputElement.addChild(inputElement);
- inputElement.elementName = getChildNameSuggestion(parentInputElement);
+ inputElement.setElementName(getChildNameSuggestion(parentInputElement));
}
treeViewer.refresh();
treeViewer.setSelection(new StructuredSelection(inputElement), true);
addNextButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- InputElement inputElement = new InputElement("", false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$ //$NON-NLS-2$
+ CustomXmlInputElement inputElement = new CustomXmlInputElement("", false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$ //$NON-NLS-2$
if (definition.rootInputElement == null) {
definition.rootInputElement = inputElement;
- inputElement.elementName = getChildNameSuggestion(null);
+ inputElement.setElementName(getChildNameSuggestion(null));
} else if (treeViewer.getSelection().isEmpty()) {
return;
} else {
- InputElement previousInputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
+ CustomXmlInputElement previousInputElement = (CustomXmlInputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
if (previousInputElement == definition.rootInputElement) {
return;
}
previousInputElement.addNext(inputElement);
- inputElement.elementName = getChildNameSuggestion(inputElement.parentElement);
+ inputElement.setElementName(getChildNameSuggestion(inputElement.getParentElement()));
}
treeViewer.refresh();
treeViewer.setSelection(new StructuredSelection(inputElement), true);
feelingLuckyButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- InputElement inputElement = null;
+ CustomXmlInputElement inputElement = null;
if (definition.rootInputElement == null) {
if (getChildNameSuggestion(null).length() != 0) {
- inputElement = new InputElement(getChildNameSuggestion(null), false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$
+ inputElement = new CustomXmlInputElement(getChildNameSuggestion(null), false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$
definition.rootInputElement = inputElement;
feelingLucky(inputElement);
} else {
} else if (treeViewer.getSelection().isEmpty()) {
return;
} else {
- inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
+ inputElement = (CustomXmlInputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
feelingLucky(inputElement);
}
treeViewer.refresh();
if (treeViewer.getSelection().isEmpty()) {
return;
}
- InputElement inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
+ CustomXmlInputElement inputElement = (CustomXmlInputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
if (inputElement == definition.rootInputElement) {
return;
}
if (treeViewer.getSelection().isEmpty()) {
return;
}
- InputElement inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
+ CustomXmlInputElement inputElement = (CustomXmlInputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
if (inputElement == definition.rootInputElement) {
return;
}
});
}
- private void feelingLucky(InputElement inputElement) {
+ private void feelingLucky(CustomXmlInputElement inputElement) {
while (true) {
String attributeName = getAttributeNameSuggestion(inputElement);
if (attributeName.length() == 0) {
break;
}
- InputAttribute attribute = new InputAttribute(attributeName, attributeName, 0, ""); //$NON-NLS-1$
+ CustomXmlInputAttribute attribute = new CustomXmlInputAttribute(attributeName, attributeName, 0, ""); //$NON-NLS-1$
inputElement.addAttribute(attribute);
}
while (true) {
if (childName.length() == 0) {
break;
}
- InputElement childElement = new InputElement(childName, false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$
+ CustomXmlInputElement childElement = new CustomXmlInputElement(childName, false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$
inputElement.addChild(childElement);
feelingLucky(childElement);
}
@Override
public Object[] getChildren(Object parentElement) {
- InputElement inputElement = (InputElement) parentElement;
- if (inputElement.childElements == null) {
- return new InputElement[0];
+ CustomXmlInputElement inputElement = (CustomXmlInputElement) parentElement;
+ if (inputElement.getChildElements() == null) {
+ return new CustomXmlInputElement[0];
}
- return inputElement.childElements.toArray();
+ return inputElement.getChildElements().toArray();
}
@Override
public boolean hasChildren(Object element) {
- InputElement inputElement = (InputElement) element;
- return (inputElement.childElements != null && inputElement.childElements.size() > 0);
+ CustomXmlInputElement inputElement = (CustomXmlInputElement) element;
+ return (inputElement.getChildElements() != null && inputElement.getChildElements().size() > 0);
}
@Override
@Override
public Object getParent(Object element) {
- InputElement inputElement = (InputElement) element;
- return inputElement.parentElement;
+ CustomXmlInputElement inputElement = (CustomXmlInputElement) element;
+ return inputElement.getParentElement();
}
}
@Override
public String getText(Object element) {
- InputElement inputElement = (InputElement) element;
- return (inputElement.elementName.trim().length() == 0) ? "?" : inputElement.elementName; //$NON-NLS-1$
+ CustomXmlInputElement inputElement = (CustomXmlInputElement) element;
+ return (inputElement.getElementName().trim().length() == 0) ? "?" : inputElement.getElementName(); //$NON-NLS-1$
}
}
}
if (!(event.getSelection().isEmpty()) && event.getSelection() instanceof IStructuredSelection) {
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
- InputElement inputElement = (InputElement) sel.getFirstElement();
+ CustomXmlInputElement inputElement = (CustomXmlInputElement) sel.getFirstElement();
selectedElement = new ElementNode(elementContainer, inputElement);
elementContainer.layout();
elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,
}
}
- private String getName(InputElement inputElement) {
- String name = (inputElement.elementName.trim().length() == 0) ? "?" : inputElement.elementName.trim(); //$NON-NLS-1$
- if (inputElement.parentElement == null) {
+ private String getName(CustomXmlInputElement inputElement) {
+ String name = (inputElement.getElementName().trim().length() == 0) ? "?" : inputElement.getElementName().trim(); //$NON-NLS-1$
+ if (inputElement.getParentElement() == null) {
return name;
}
- return getName(inputElement.parentElement) + " : " + name; //$NON-NLS-1$
+ return getName(inputElement.getParentElement()) + " : " + name; //$NON-NLS-1$
}
- private String getName(InputAttribute inputAttribute, InputElement inputElement) {
- String name = (inputAttribute.attributeName.trim().length() == 0) ? "?" : inputAttribute.attributeName.trim(); //$NON-NLS-1$
+ private String getName(CustomXmlInputAttribute inputAttribute, CustomXmlInputElement inputElement) {
+ String name = (inputAttribute.getAttributeName().trim().length() == 0) ? "?" : inputAttribute.getAttributeName().trim(); //$NON-NLS-1$
return getName(inputElement) + " : " + name; //$NON-NLS-1$
}
* The element
* @return The input names for this element
*/
- public List<String> getInputNames(InputElement inputElement) {
+ public List<String> getInputNames(CustomXmlInputElement inputElement) {
List<String> inputs = new ArrayList<>();
- if (inputElement.inputName != null && !inputElement.inputName.equals(CustomXmlTraceDefinition.TAG_IGNORE)) {
- String inputName = inputElement.inputName;
+ if (inputElement.getInputName() != null && !inputElement.getInputName().equals(CustomXmlTraceDefinition.TAG_IGNORE)) {
+ String inputName = inputElement.getInputName();
if (!inputs.contains(inputName)) {
inputs.add(inputName);
}
}
- if (inputElement.attributes != null) {
- for (InputAttribute attribute : inputElement.attributes) {
- String inputName = attribute.inputName;
+ if (inputElement.getAttributes() != null) {
+ for (CustomXmlInputAttribute attribute : inputElement.getAttributes()) {
+ String inputName = attribute.getInputName();
if (!inputs.contains(inputName)) {
inputs.add(inputName);
}
}
}
- if (inputElement.childElements != null) {
- for (InputElement childInputElement : inputElement.childElements) {
+ if (inputElement.getChildElements() != null) {
+ for (CustomXmlInputElement childInputElement : inputElement.getChildElements()) {
for (String inputName : getInputNames(childInputElement)) {
if (!inputs.contains(inputName)) {
inputs.add(inputName);
}
private class ElementNode {
- private final InputElement inputElement;
+ private final CustomXmlInputElement inputElement;
private final Group group;
private List<Attribute> attributes = new ArrayList<>();
private List<ElementNode> childElements = new ArrayList<>();
private Button addAttributeButton;
private Label addAttributeLabel;
- public ElementNode(Composite parent, InputElement inputElement) {
+ public ElementNode(Composite parent, CustomXmlInputElement inputElement) {
this.inputElement = inputElement;
group = new Group(parent, SWT.NONE);
elementNameText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
- ElementNode.this.inputElement.elementName = elementNameText.getText().trim();
+ ElementNode.this.inputElement.setElementName(elementNameText.getText().trim());
group.setText(getName(ElementNode.this.inputElement));
}
});
- elementNameText.setText(inputElement.elementName);
+ elementNameText.setText(inputElement.getElementName());
elementNameText.addModifyListener(updateListener);
- if (inputElement.parentElement != null) {
+ if (inputElement.getParentElement() != null) {
previewLabel = new Label(group, SWT.NULL);
previewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
previewLabel.setText(Messages.CustomXmlParserInputWizardPage_preview);
logEntryButton = new Button(group, SWT.CHECK);
logEntryButton.setText(Messages.CustomXmlParserInputWizardPage_logEntry);
- logEntryButton.setSelection(inputElement.logEntry);
+ logEntryButton.setSelection(inputElement.isLogEntry());
logEntryButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
@Override
public void widgetSelected(SelectionEvent e) {
- InputElement parentElem = ElementNode.this.inputElement.parentElement;
+ CustomXmlInputElement parentElem = ElementNode.this.inputElement.getParentElement();
while (parentElem != null) {
- parentElem.logEntry = false;
- parentElem = parentElem.parentElement;
+ parentElem.setLogEntry(false);
+ parentElem = parentElem.getParentElement();
}
}
});
actionCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
actionCombo.setItems(new String[] { Messages.CustomXmlParserInputWizardPage_set, Messages.CustomXmlParserInputWizardPage_append,
Messages.CustomXmlParserInputWizardPage_appendWith });
- actionCombo.select(inputElement.inputAction);
+ actionCombo.select(inputElement.getInputAction());
actionCombo.addSelectionListener(updateListener);
- if (inputElement.inputName.equals(CustomXmlTraceDefinition.TAG_IGNORE)) {
+ if (inputElement.getInputName().equals(CustomXmlTraceDefinition.TAG_IGNORE)) {
tagCombo.select(0);
tagLabel.setVisible(false);
tagText.setVisible(false);
actionCombo.setVisible(false);
- } else if (inputElement.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+ } else if (inputElement.getInputName().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
tagCombo.select(1);
tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);
- tagText.setText(inputElement.inputFormat);
+ tagText.setText(inputElement.getInputFormat());
tagText.addModifyListener(updateListener);
- } else if (inputElement.inputName.equals(CustomTraceDefinition.TAG_MESSAGE)) {
+ } else if (inputElement.getInputName().equals(CustomTraceDefinition.TAG_MESSAGE)) {
tagCombo.select(2);
tagLabel.setVisible(false);
tagText.setVisible(false);
} else {
tagCombo.select(3);
tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);
- tagText.setText(inputElement.inputName);
+ tagText.setText(inputElement.getInputName());
tagText.addModifyListener(updateListener);
}
}
- if (inputElement.attributes != null) {
- for (InputAttribute inputAttribute : inputElement.attributes) {
+ if (inputElement.getAttributes() != null) {
+ for (CustomXmlInputAttribute inputAttribute : inputElement.getAttributes()) {
Attribute attribute = new Attribute(group, this, inputAttribute, attributes.size() + 1);
attributes.add(attribute);
}
private void updatePreview() {
Element element = getPreviewElement(inputElement);
- if (inputElement.parentElement != null) { // no preview text for
+ if (inputElement.getParentElement() != null) { // no preview text for
// document element
previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatchingElement);
if (element != null) {
public void widgetSelected(SelectionEvent e) {
removeAddButton();
String attributeName = getAttributeNameSuggestion(inputElement);
- InputAttribute inputAttribute = new InputAttribute(attributeName, attributeName, 0, ""); //$NON-NLS-1$
+ CustomXmlInputAttribute inputAttribute = new CustomXmlInputAttribute(attributeName, attributeName, 0, ""); //$NON-NLS-1$
attributes.add(new Attribute(group, ElementNode.this, inputAttribute, attributes.size() + 1));
createAddButton();
elementContainer.layout();
}
private void extractInputs() {
- inputElement.elementName = elementNameText.getText().trim();
- if (inputElement.parentElement != null) {
- inputElement.logEntry = logEntryButton.getSelection();
+ inputElement.setElementName(elementNameText.getText().trim());
+ if (inputElement.getParentElement() != null) {
+ inputElement.setLogEntry(logEntryButton.getSelection());
if (tagCombo.getText().equals(CustomTraceDefinition.TAG_OTHER)) {
- inputElement.inputName = tagText.getText().trim();
+ inputElement.setInputName(tagText.getText().trim());
} else {
- inputElement.inputName = tagCombo.getText();
+ inputElement.setInputName(tagCombo.getText());
if (tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
- inputElement.inputFormat = tagText.getText().trim();
+ inputElement.setInputFormat(tagText.getText().trim());
}
}
- inputElement.inputAction = actionCombo.getSelectionIndex();
+ inputElement.setInputAction(actionCombo.getSelectionIndex());
}
- inputElement.attributes = new ArrayList<>(attributes.size());
+ inputElement.setAttributes(new ArrayList<CustomXmlInputAttribute>(attributes.size()));
for (int i = 0; i < attributes.size(); i++) {
+ String inputName = null;
+ String inputFormat = null;
Attribute attribute = attributes.get(i);
- InputAttribute inputAttribute = new InputAttribute();
- inputAttribute.attributeName = attribute.attributeNameText.getText().trim();
+ String attributeName = attribute.attributeNameText.getText().trim();
if (attribute.tagCombo.getText().equals(CustomTraceDefinition.TAG_OTHER)) {
- inputAttribute.inputName = attribute.tagText.getText().trim();
+ inputName = attribute.tagText.getText().trim();
} else {
- inputAttribute.inputName = attribute.tagCombo.getText();
+ inputName = attribute.tagCombo.getText();
if (attribute.tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
- inputAttribute.inputFormat = attribute.tagText.getText().trim();
+ inputFormat = attribute.tagText.getText().trim();
}
}
- inputAttribute.inputAction = attribute.actionCombo.getSelectionIndex();
- inputElement.addAttribute(inputAttribute);
+ int inputAction = attribute.actionCombo.getSelectionIndex();
+ inputElement.addAttribute(new CustomXmlInputAttribute(attributeName, inputName, inputAction, inputFormat));
}
}
}
private Text tagText;
private Combo actionCombo;
- public Attribute(Composite parent, ElementNode element, InputAttribute inputAttribute, int attributeNumber) {
+ public Attribute(Composite parent, ElementNode element, CustomXmlInputAttribute inputAttribute, int attributeNumber) {
this.element = element;
this.attributeNumber = attributeNumber;
attributeNameText = new Text(attributeComposite, SWT.BORDER | SWT.SINGLE);
attributeNameText.setLayoutData(new GridData(120, SWT.DEFAULT));
- attributeNameText.setText(inputAttribute.attributeName);
+ attributeNameText.setText(inputAttribute.getAttributeName());
attributeNameText.addModifyListener(updateListener);
Label previewLabel = new Label(attributeComposite, SWT.NONE);
actionCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
actionCombo.setItems(new String[] { Messages.CustomXmlParserInputWizardPage_set, Messages.CustomXmlParserInputWizardPage_append,
Messages.CustomXmlParserInputWizardPage_appendWith });
- actionCombo.select(inputAttribute.inputAction);
+ actionCombo.select(inputAttribute.getInputAction());
actionCombo.addSelectionListener(updateListener);
- if (inputAttribute.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+ if (inputAttribute.getInputName().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
tagCombo.select(0);
tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);
- tagText.setText(inputAttribute.inputFormat);
+ tagText.setText(inputAttribute.getInputFormat());
tagText.addModifyListener(updateListener);
- } else if (inputAttribute.inputName.equals(CustomTraceDefinition.TAG_MESSAGE)) {
+ } else if (inputAttribute.getInputName().equals(CustomTraceDefinition.TAG_MESSAGE)) {
tagCombo.select(1);
tagLabel.setVisible(false);
tagText.setVisible(false);
} else {
tagCombo.select(2);
tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);
- tagText.setText(inputAttribute.inputName);
+ tagText.setText(inputAttribute.getInputName());
tagText.addModifyListener(updateListener);
}
}
}
}
- private Element getPreviewElement(InputElement inputElement) {
- InputElement currentElement = inputElement;
+ private Element getPreviewElement(CustomXmlInputElement inputElement) {
+ CustomXmlInputElement currentElement = inputElement;
Element element = documentElement;
if (element != null) {
- if (!documentElement.getNodeName().equals(definition.rootInputElement.elementName)) {
+ if (!documentElement.getNodeName().equals(definition.rootInputElement.getElementName())) {
return null;
}
ArrayList<String> elementNames = new ArrayList<>();
while (currentElement != null) {
- elementNames.add(currentElement.elementName);
- currentElement = currentElement.parentElement;
+ elementNames.add(currentElement.getElementName());
+ currentElement = currentElement.getParentElement();
}
for (int i = elementNames.size() - 1; --i >= 0;) {
NodeList childList = element.getChildNodes();
return null;
}
- private String getChildNameSuggestion(InputElement inputElement) {
+ private String getChildNameSuggestion(CustomXmlInputElement inputElement) {
if (inputElement == null) {
if (documentElement != null) {
return documentElement.getNodeName();
Node node = childNodes.item(i);
if (node instanceof Element) {
boolean unused = true;
- if (inputElement.childElements != null) {
- for (InputElement child : inputElement.childElements) {
- if (child.elementName.equals(node.getNodeName())) {
+ if (inputElement.getChildElements() != null) {
+ for (CustomXmlInputElement child : inputElement.getChildElements()) {
+ if (child.getElementName().equals(node.getNodeName())) {
unused = false;
break;
}
return ""; //$NON-NLS-1$
}
- private String getAttributeNameSuggestion(InputElement inputElement) {
+ private String getAttributeNameSuggestion(CustomXmlInputElement inputElement) {
Element element = getPreviewElement(inputElement);
if (element != null) {
NamedNodeMap attributeMap = element.getAttributes();
for (int i = 0; i < attributeMap.getLength(); i++) {
Node node = attributeMap.item(i);
boolean unused = true;
- if (inputElement.attributes != null) {
- for (InputAttribute attribute : inputElement.attributes) {
- if (attribute.attributeName.equals(node.getNodeName())) {
+ if (inputElement.getAttributes() != null) {
+ for (CustomXmlInputAttribute attribute : inputElement.getAttributes()) {
+ if (attribute.getAttributeName().equals(node.getNodeName())) {
unused = false;
break;
}
errors.addAll(validateElement(definition.rootInputElement));
- if ((definition.rootInputElement.attributes != null && definition.rootInputElement.attributes.size() != 0)
- || (definition.rootInputElement.childElements != null && definition.rootInputElement.childElements.size() != 0)
+ if ((definition.rootInputElement.getAttributes() != null && definition.rootInputElement.getAttributes().size() != 0)
+ || (definition.rootInputElement.getChildElements() != null && definition.rootInputElement.getChildElements().size() != 0)
|| errors.size() == 0) {
if (!logEntryFound) {
errors.add(Messages.CustomXmlParserInputWizardPage_missingLogEntryError);
* The element to clean up
* @return The validated element
*/
- public List<String> validateElement(InputElement inputElement) {
+ public List<String> validateElement(CustomXmlInputElement inputElement) {
List<String> errors = new ArrayList<>();
ElementNode elementNode = null;
if (selectedElement != null && selectedElement.inputElement.equals(inputElement)) {
elementNode = selectedElement;
}
if (inputElement == definition.rootInputElement) {
- if (inputElement.elementName.length() == 0) {
+ if (inputElement.getElementName().length() == 0) {
errors.add(Messages.CustomXmlParserInputWizardPage_missingDocumentElementError);
if (elementNode != null) {
elementNode.elementNameText.setBackground(COLOR_LIGHT_RED);
}
}
if (inputElement != definition.rootInputElement) {
- if (inputElement.logEntry) {
+ if (inputElement.isLogEntry()) {
logEntryFound = true;
}
- if (inputElement.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+ if (inputElement.getInputName().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
timeStampFound = true;
- if (inputElement.inputFormat.length() == 0) {
+ if (inputElement.getInputFormat().length() == 0) {
errors.add(NLS.bind(Messages.CustomXmlParserInputWizardPage_elementMissingTimestampFmtError, getName(inputElement)));
if (elementNode != null) {
elementNode.tagText.setBackground(COLOR_LIGHT_RED);
}
} else {
try {
- new TmfTimestampFormat(inputElement.inputFormat);
+ new TmfTimestampFormat(inputElement.getInputFormat());
if (elementNode != null) {
elementNode.tagText.setBackground(COLOR_TEXT_BACKGROUND);
}
}
}
}
- } else if (inputElement.inputName.length() == 0) {
+ } else if (inputElement.getInputName().length() == 0) {
errors.add(NLS.bind(Messages.CustomXmlParserInputWizardPage_elementMissingInputNameError, getName(inputElement)));
if (elementNode != null) {
elementNode.tagText.setBackground(COLOR_LIGHT_RED);
}
}
}
- if (inputElement.attributes != null) {
+ if (inputElement.getAttributes() != null) {
if (elementNode != null) {
for (Attribute attribute : elementNode.attributes) {
attribute.attributeNameText.setBackground(COLOR_TEXT_BACKGROUND);
}
}
- for (int i = 0; i < inputElement.attributes.size(); i++) {
- InputAttribute attribute = inputElement.attributes.get(i);
+ for (int i = 0; i < inputElement.getAttributes().size(); i++) {
+ CustomXmlInputAttribute attribute = inputElement.getAttributes().get(i);
boolean duplicate = false;
- for (int j = i + 1; j < inputElement.attributes.size(); j++) {
- InputAttribute otherAttribute = inputElement.attributes.get(j);
- if (otherAttribute.attributeName.equals(attribute.attributeName)) {
+ for (int j = i + 1; j < inputElement.getAttributes().size(); j++) {
+ CustomXmlInputAttribute otherAttribute = inputElement.getAttributes().get(j);
+ if (otherAttribute.getAttributeName().equals(attribute.getAttributeName())) {
duplicate = true;
if (elementNode != null) {
elementNode.attributes.get(j).attributeNameText.setBackground(COLOR_LIGHT_RED);
}
}
}
- if (attribute.attributeName.length() == 0) {
+ if (attribute.getAttributeName().length() == 0) {
errors.add(NLS.bind(Messages.CustomXmlParserInputWizardPage_attributeMissingNameError, getName(inputElement)));
if (elementNode != null) {
elementNode.attributes.get(i).attributeNameText.setBackground(COLOR_LIGHT_RED);
elementNode.attributes.get(i).attributeNameText.setBackground(COLOR_LIGHT_RED);
}
}
- if (attribute.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+ if (attribute.getInputName().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
timeStampFound = true;
- if (attribute.inputFormat.length() == 0) {
+ if (attribute.getInputFormat().length() == 0) {
errors.add(NLS.bind(Messages.CustomXmlParserInputWizardPage_attributeMissingTimestampFmtError, getName(attribute, inputElement)));
if (elementNode != null) {
elementNode.attributes.get(i).tagText.setBackground(COLOR_LIGHT_RED);
}
} else {
try {
- new TmfTimestampFormat(attribute.inputFormat);
+ new TmfTimestampFormat(attribute.getInputFormat());
if (elementNode != null) {
elementNode.attributes.get(i).tagText.setBackground(COLOR_TEXT_BACKGROUND);
}
}
}
}
- } else if (attribute.inputName.length() == 0) {
+ } else if (attribute.getInputName().length() == 0) {
errors.add(NLS.bind(Messages.CustomXmlParserInputWizardPage_attributeMissingInputNameError, getName(attribute, inputElement)));
if (elementNode != null) {
elementNode.attributes.get(i).tagText.setBackground(COLOR_LIGHT_RED);
}
}
}
- if (inputElement.childElements != null) {
- for (InputElement child : inputElement.childElements) {
+ if (inputElement.getChildElements() != null) {
+ for (CustomXmlInputElement child : inputElement.getChildElements()) {
ElementNode childElementNode = null;
if (selectedElement != null && selectedElement.inputElement.equals(child)) {
childElementNode = selectedElement;
childElementNode.elementNameText.setBackground(COLOR_TEXT_BACKGROUND);
}
}
- for (int i = 0; i < inputElement.childElements.size(); i++) {
- InputElement child = inputElement.childElements.get(i);
+ for (int i = 0; i < inputElement.getChildElements().size(); i++) {
+ CustomXmlInputElement child = inputElement.getChildElements().get(i);
ElementNode childElementNode = null;
if (selectedElement != null && selectedElement.inputElement.equals(child)) {
childElementNode = selectedElement;
}
- if (child.elementName.length() == 0) {
+ if (child.getElementName().length() == 0) {
errors.add(NLS.bind(Messages.CustomXmlParserInputWizardPage_elementMissingNameError, getName(child)));
if (childElementNode != null) {
childElementNode.elementNameText.setBackground(COLOR_LIGHT_RED);
}
} else {
boolean duplicate = false;
- for (int j = i + 1; j < inputElement.childElements.size(); j++) {
- InputElement otherChild = inputElement.childElements.get(j);
- if (otherChild.elementName.equals(child.elementName)) {
+ for (int j = i + 1; j < inputElement.getChildElements().size(); j++) {
+ CustomXmlInputElement otherChild = inputElement.getChildElements().get(j);
+ if (otherChild.getElementName().equals(child.getElementName())) {
duplicate = true;
ElementNode otherChildElementNode = null;
if (selectedElement != null && selectedElement.inputElement.equals(otherChild)) {