Rename xxx.lttng to xxx.lttng.core
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf / src / org / eclipse / linuxtools / tmf / filter / model / TmfFilterOrNode.java
CommitLineData
46ab8ce3
FC
1/*******************************************************************************\r
2 * Copyright (c) 2010 Ericsson\r
3 * \r
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
8 * \r
9 * Contributors:\r
10 * Patrick Tasse - Initial API and implementation\r
11 *******************************************************************************/\r
12\r
13package org.eclipse.linuxtools.tmf.filter.model;\r
14\r
15import org.eclipse.linuxtools.tmf.event.TmfEvent;\r
16\r
17\r
18public class TmfFilterOrNode extends TmfFilterTreeNode {\r
19\r
20 public static final String NODE_NAME = "OR"; //$NON-NLS-1$\r
21 public static final String NOT_ATTR = "not"; //$NON-NLS-1$\r
22 \r
23 private boolean fNot = false;\r
24 \r
25 public TmfFilterOrNode(ITmfFilterTreeNode parent) {\r
26 super(parent);\r
27 }\r
28\r
29 @Override\r
30 public String getNodeName() {\r
31 return NODE_NAME;\r
32 }\r
33\r
34 public boolean isNot() {\r
35 return fNot;\r
36 }\r
37 \r
38 public void setNot(boolean not) {\r
39 this.fNot = not;\r
40 }\r
41 \r
42 @Override\r
43 public boolean matches(TmfEvent event) {\r
44 for (ITmfFilterTreeNode node : getChildren()) {\r
45 if (node.matches(event)) {\r
46 return true ^ fNot;\r
47 }\r
48 }\r
49 return false & fNot;\r
50 }\r
51\r
52 @Override\r
53 public String toString() {\r
54 StringBuffer buf = new StringBuffer();\r
55 if (fNot) {\r
56 buf.append("not "); //$NON-NLS-1$\r
57 }\r
58 if (getParent() != null && !(getParent() instanceof TmfFilterRootNode) && !(getParent() instanceof TmfFilterNode)) {\r
59 buf.append("( "); //$NON-NLS-1$\r
60 }\r
61 for (int i = 0; i < getChildrenCount(); i++) {\r
62 ITmfFilterTreeNode node = getChildren()[i];\r
63 buf.append(node.toString());\r
64 if (i < getChildrenCount() - 1) {\r
65 buf.append(" or "); //$NON-NLS-1$\r
66 }\r
67 }\r
68 if (getParent() != null && !(getParent() instanceof TmfFilterRootNode) && !(getParent() instanceof TmfFilterNode)) {\r
69 buf.append(" )"); //$NON-NLS-1$\r
70 }\r
71 return buf.toString();\r
72 }\r
73}\r
This page took 0.041458 seconds and 5 git commands to generate.