More javadoc updates
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / filter / model / TmfFilterAndNode.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
6c13869b 13package org.eclipse.linuxtools.tmf.core.filter.model;\r
46ab8ce3 14\r
a96d4804 15import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
46ab8ce3
FC
16\r
17\r
d37aaa7f
FC
18/**\r
19 * Filter node for the 'and' operation\r
20 * \r
21 * @version 1.0\r
22 * @author Patrick Tasse\r
23 */\r
46ab8ce3
FC
24public class TmfFilterAndNode extends TmfFilterTreeNode {\r
25\r
26 public static final String NODE_NAME = "AND"; //$NON-NLS-1$\r
27 public static final String NOT_ATTR = "not"; //$NON-NLS-1$\r
28 \r
29 private boolean fNot = false;\r
30 \r
31 public TmfFilterAndNode(ITmfFilterTreeNode parent) {\r
32 super(parent);\r
33 }\r
34\r
35 public boolean isNot() {\r
36 return fNot;\r
37 }\r
38 \r
39 public void setNot(boolean not) {\r
40 this.fNot = not;\r
41 }\r
42 \r
43 @Override\r
44 public String getNodeName() {\r
45 return NODE_NAME;\r
46 }\r
47\r
48 @Override\r
a96d4804 49 public boolean matches(ITmfEvent event) {\r
46ab8ce3
FC
50 for (ITmfFilterTreeNode node : getChildren()) {\r
51 if (! node.matches(event)) {\r
52 return false ^ fNot;\r
53 }\r
54 }\r
55 return true ^ fNot;\r
56 }\r
57\r
58 @Override\r
59 public String toString() {\r
60 StringBuffer buf = new StringBuffer();\r
61 if (fNot) {\r
62 buf.append("not "); //$NON-NLS-1$\r
63 }\r
64 if (getParent() != null && !(getParent() instanceof TmfFilterRootNode) && !(getParent() instanceof TmfFilterNode)) {\r
65 buf.append("( "); //$NON-NLS-1$\r
66 }\r
67 for (int i = 0; i < getChildrenCount(); i++) {\r
68 ITmfFilterTreeNode node = getChildren()[i];\r
69 buf.append(node.toString());\r
70 if (i < getChildrenCount() - 1) {\r
71 buf.append(" and "); //$NON-NLS-1$\r
72 }\r
73 }\r
74 if (getParent() != null && !(getParent() instanceof TmfFilterRootNode) && !(getParent() instanceof TmfFilterNode)) {\r
75 buf.append(" )"); //$NON-NLS-1$\r
76 }\r
77 return buf.toString();\r
78 }\r
79 \r
80}\r
This page took 0.03454 seconds and 5 git commands to generate.