X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=tmf%2Forg.eclipse.tracecompass.tmf.core%2Fsrc%2Forg%2Feclipse%2Ftracecompass%2Ftmf%2Fcore%2Fparsers%2Fcustom%2FCustomXmlTraceDefinition.java;h=c0bf814d52ed1d759e2a5ec798e5b934417519e3;hb=a36fa387f725817df2daa740af1ce6a0a58ab50c;hp=d95783237a1d47292522d6816116190df932b28e;hpb=d1b0903fe92fabef842f26e50cf12062d398c28c;p=deliverable%2Ftracecompass.git diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTraceDefinition.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTraceDefinition.java index d95783237a..c0bf814d52 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTraceDefinition.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTraceDefinition.java @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.List; +import java.util.Map.Entry; import java.util.Set; import java.util.TreeSet; @@ -39,6 +40,7 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.eclipse.core.runtime.Platform; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.internal.tmf.core.Activator; import org.eclipse.tracecompass.tmf.core.project.model.TmfTraceType; import org.w3c.dom.Document; @@ -58,7 +60,9 @@ import org.xml.sax.SAXParseException; */ public class CustomXmlTraceDefinition extends CustomTraceDefinition { - /** "ignore" tag */ + /** Ignore tag + * @deprecated Use {@link org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTraceDefinition.Tag#IGNORE} instead. */ + @Deprecated public static final String TAG_IGNORE = Messages.CustomXmlTraceDefinition_ignoreTag; /** @@ -104,8 +108,10 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { private static final String CUSTOM_XML_TRACE_DEFINITION_ROOT_ELEMENT = Messages.CustomXmlTraceDefinition_definitionRootElement; private static final String DEFINITION_ELEMENT = Messages.CustomXmlTraceDefinition_definition; private static final String CATEGORY_ATTRIBUTE = Messages.CustomXmlTraceDefinition_category; + private static final String TAG_ATTRIBUTE = Messages.CustomXmlTraceDefinition_tag; private static final String NAME_ATTRIBUTE = Messages.CustomXmlTraceDefinition_name; private static final String LOG_ENTRY_ATTRIBUTE = Messages.CustomXmlTraceDefinition_logEntry; + private static final String EVENT_TYPE_ATTRIBUTE = Messages.CustomXmlTraceDefinition_eventType; private static final String TIME_STAMP_OUTPUT_FORMAT_ELEMENT = Messages.CustomXmlTraceDefinition_timestampOutputFormat; private static final String INPUT_ELEMENT_ELEMENT = Messages.CustomXmlTraceDefinition_inputElement; private static final String ATTRIBUTE_ELEMENT = Messages.CustomXmlTraceDefinition_attribute; @@ -189,9 +195,11 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { definitionElement.setAttribute(CATEGORY_ATTRIBUTE, categoryName); definitionElement.setAttribute(NAME_ATTRIBUTE, definitionName); - Element formatElement = doc.createElement(TIME_STAMP_OUTPUT_FORMAT_ELEMENT); - definitionElement.appendChild(formatElement); - formatElement.appendChild(doc.createTextNode(timeStampOutputFormat)); + if (timeStampOutputFormat != null && !timeStampOutputFormat.isEmpty()) { + Element formatElement = doc.createElement(TIME_STAMP_OUTPUT_FORMAT_ELEMENT); + definitionElement.appendChild(formatElement); + formatElement.appendChild(doc.createTextNode(timeStampOutputFormat)); + } if (rootInputElement != null) { definitionElement.appendChild(createInputElementElement(rootInputElement, doc)); @@ -201,6 +209,7 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { for (OutputColumn output : outputs) { Element outputColumnElement = doc.createElement(OUTPUT_COLUMN_ELEMENT); definitionElement.appendChild(outputColumnElement); + outputColumnElement.setAttribute(TAG_ATTRIBUTE, output.tag.name()); outputColumnElement.setAttribute(NAME_ATTRIBUTE, output.name); } } @@ -233,13 +242,19 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { inputElementElement.setAttribute(LOG_ENTRY_ATTRIBUTE, Boolean.toString(inputElement.isLogEntry())); } + if (inputElement.getEventType() != null) { + inputElementElement.setAttribute(EVENT_TYPE_ATTRIBUTE, inputElement.getEventType()); + } + if (inputElement.getParentElement() != null) { Element inputDataElement = doc.createElement(INPUT_DATA_ELEMENT); inputElementElement.appendChild(inputDataElement); + inputDataElement.setAttribute(TAG_ATTRIBUTE, inputElement.getInputTag().name()); inputDataElement.setAttribute(NAME_ATTRIBUTE, inputElement.getInputName()); inputDataElement.setAttribute(ACTION_ATTRIBUTE, Integer.toString(inputElement.getInputAction())); - if (inputElement.getInputFormat() != null) { - inputDataElement.setAttribute(FORMAT_ATTRIBUTE, inputElement.getInputFormat()); + String inputFormat = inputElement.getInputFormat(); + if (inputFormat != null && !inputFormat.isEmpty()) { + inputDataElement.setAttribute(FORMAT_ATTRIBUTE, inputFormat); } } @@ -250,10 +265,12 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { inputAttributeElement.setAttribute(NAME_ATTRIBUTE, attribute.getAttributeName()); Element inputDataElement = doc.createElement(INPUT_DATA_ELEMENT); inputAttributeElement.appendChild(inputDataElement); + inputDataElement.setAttribute(TAG_ATTRIBUTE, attribute.getInputTag().name()); inputDataElement.setAttribute(NAME_ATTRIBUTE, attribute.getInputName()); inputDataElement.setAttribute(ACTION_ATTRIBUTE, Integer.toString(attribute.getInputAction())); - if (attribute.getInputFormat() != null) { - inputDataElement.setAttribute(FORMAT_ATTRIBUTE, attribute.getInputFormat()); + String inputFormat = attribute.getInputFormat(); + if (inputFormat != null && !inputFormat.isEmpty()) { + inputDataElement.setAttribute(FORMAT_ATTRIBUTE, inputFormat); } } } @@ -520,8 +537,8 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { } } else if (nodeName.equals(OUTPUT_COLUMN_ELEMENT)) { Element outputColumnElement = (Element) node; - OutputColumn outputColumn = new OutputColumn(); - outputColumn.name = outputColumnElement.getAttribute(NAME_ATTRIBUTE); + Entry<@NonNull Tag, @NonNull String> entry = extractTagAndName(outputColumnElement, TAG_ATTRIBUTE, NAME_ATTRIBUTE); + OutputColumn outputColumn = new OutputColumn(entry.getKey(), entry.getValue()); def.outputs.add(outputColumn); } } @@ -532,34 +549,36 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { CustomXmlInputElement inputElement = new CustomXmlInputElement(); inputElement.setElementName(inputElementElement.getAttribute(NAME_ATTRIBUTE)); inputElement.setLogEntry((Boolean.toString(true).equals(inputElementElement.getAttribute(LOG_ENTRY_ATTRIBUTE))) ? true : false); + String eventType = inputElementElement.getAttribute(EVENT_TYPE_ATTRIBUTE); + inputElement.setEventType(eventType.isEmpty() ? null : eventType); 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.setInputName(inputDataElement.getAttribute(NAME_ATTRIBUTE)); + Entry<@NonNull Tag, @NonNull String> entry = extractTagAndName(inputDataElement, TAG_ATTRIBUTE, NAME_ATTRIBUTE); + inputElement.setInputTag(entry.getKey()); + inputElement.setInputName(entry.getValue()); inputElement.setInputAction(Integer.parseInt(inputDataElement.getAttribute(ACTION_ATTRIBUTE))); inputElement.setInputFormat(inputDataElement.getAttribute(FORMAT_ATTRIBUTE)); } else if (nodeName.equals(ATTRIBUTE_ELEMENT)) { Element attributeElement = (Element) node; 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; - inputName = inputDataElement.getAttribute(NAME_ATTRIBUTE); - inputAction = Integer.parseInt(inputDataElement.getAttribute(ACTION_ATTRIBUTE)); - inputFormat = inputDataElement.getAttribute(FORMAT_ATTRIBUTE); + Entry<@NonNull Tag, @NonNull String> entry = extractTagAndName(inputDataElement, TAG_ATTRIBUTE, NAME_ATTRIBUTE); + int action = Integer.parseInt(inputDataElement.getAttribute(ACTION_ATTRIBUTE)); + String format = inputDataElement.getAttribute(FORMAT_ATTRIBUTE); + inputElement.addAttribute(new CustomXmlInputAttribute(attributeName, entry.getKey(), entry.getValue(), action, format)); + break; } } - inputElement.addAttribute(new CustomXmlInputAttribute(attributeName, inputName, inputAction, inputFormat)); } else if (nodeName.equals(INPUT_ELEMENT_ELEMENT)) { Element childInputElementElement = (Element) node; CustomXmlInputElement childInputElement = extractInputElement(childInputElementElement);