ctf: Handle traces with unknown event attributes
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / filter / model / TmfFilterNode.java
CommitLineData
46ab8ce3
FC
1/*******************************************************************************\r
2 * Copyright (c) 2010 Ericsson\r
ce2388e0 3 *\r
46ab8ce3
FC
4 * All rights reserved. This program and the accompanying materials are\r
5 * made available under the terms of the Eclipse Public License v1.0 which\r
6 * accompanies this distribution, and is available at\r
7 * http://www.eclipse.org/legal/epl-v10.html\r
ce2388e0 8 *\r
46ab8ce3
FC
9 * Contributors:\r
10 * Patrick Tasse - Initial API and implementation\r
11 *******************************************************************************/\r
12\r
6c13869b 13package org.eclipse.linuxtools.tmf.core.filter.model;\r
46ab8ce3
FC
14\r
15import java.util.ArrayList;\r
16import java.util.List;\r
17\r
a96d4804 18import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
46ab8ce3 19\r
d37aaa7f
FC
20/**\r
21 * Filter node for the event match operation\r
0283f7ff 22 *\r
d37aaa7f
FC
23 * @version 1.0\r
24 * @author Patrick Tasse\r
25 */\r
0283f7ff 26@SuppressWarnings("javadoc")\r
46ab8ce3 27public class TmfFilterNode extends TmfFilterTreeNode {\r
ce2388e0 28\r
0283f7ff 29 public static final String NODE_NAME = "FILTER"; //$NON-NLS-1$\r
46ab8ce3 30 public static final String NAME_ATTR = "name"; //$NON-NLS-1$\r
ce2388e0 31\r
46ab8ce3 32 String fFilterName;\r
ce2388e0 33\r
0283f7ff
FC
34 /**\r
35 * @param filterName the filter name\r
36 */\r
46ab8ce3
FC
37 public TmfFilterNode(String filterName) {\r
38 super(null);\r
39 fFilterName = filterName;\r
40 }\r
41\r
0283f7ff
FC
42 /**\r
43 * @param parent the parent node\r
44 * @param filterName the filter name\r
45 */\r
46ab8ce3
FC
46 public TmfFilterNode(ITmfFilterTreeNode parent, String filterName) {\r
47 super(parent);\r
48 fFilterName = filterName;\r
49 }\r
50\r
0283f7ff
FC
51 /**\r
52 * @return the filer name\r
53 */\r
46ab8ce3
FC
54 public String getFilterName() {\r
55 return fFilterName;\r
56 }\r
57\r
0283f7ff
FC
58 /**\r
59 * @param filterName the filer name\r
60 */\r
46ab8ce3
FC
61 public void setFilterName(String filterName) {\r
62 fFilterName = filterName;\r
63 }\r
64\r
65 @Override\r
66 public String getNodeName() {\r
67 return NODE_NAME;\r
68 }\r
69\r
70 @Override\r
a96d4804 71 public boolean matches(ITmfEvent event) {\r
46ab8ce3
FC
72 // There should be at most one child\r
73 for (ITmfFilterTreeNode node : getChildren()) {\r
74 if (node.matches(event)) {\r
75 return true;\r
76 }\r
77 }\r
78 return false;\r
79 }\r
80\r
81 @Override\r
82 public List<String> getValidChildren() {\r
83 if (getChildrenCount() == 0) {\r
84 return super.getValidChildren();\r
46ab8ce3 85 }\r
ce2388e0 86 return new ArrayList<String>(0); // only one child allowed\r
46ab8ce3
FC
87 }\r
88\r
89 @Override\r
90 public String toString() {\r
91 StringBuffer buf = new StringBuffer();\r
92 if (getChildrenCount() > 1) {\r
93 buf.append("( "); //$NON-NLS-1$\r
94 }\r
95 for (int i = 0; i < getChildrenCount(); i++) {\r
96 ITmfFilterTreeNode node = getChildren()[i];\r
97 buf.append(node.toString());\r
ce2388e0 98 if (i < (getChildrenCount() - 1)) {\r
46ab8ce3
FC
99 buf.append(" and "); //$NON-NLS-1$\r
100 }\r
101 }\r
102 if (getChildrenCount() > 1) {\r
103 buf.append(" )"); //$NON-NLS-1$\r
104 }\r
105 return buf.toString();\r
106 }\r
107}\r
This page took 0.038678 seconds and 5 git commands to generate.