tmf: Fix most Number unboxing problems
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / filter / model / TmfFilterOrNode.java
CommitLineData
be222f56 1/*******************************************************************************
61759503 2 * Copyright (c) 2010, 2012 Ericsson
be222f56
PT
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
12
13package org.eclipse.linuxtools.tmf.core.filter.model;
14
15import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
16
17/**
18 * Filter node for the 'or' operation
19 *
20 * @version 1.0
21 * @author Patrick Tasse
22 */
23@SuppressWarnings("javadoc")
24public class TmfFilterOrNode extends TmfFilterTreeNode {
25
26 public static final String NODE_NAME = "OR"; //$NON-NLS-1$
27 public static final String NOT_ATTR = "not"; //$NON-NLS-1$
28
29 private boolean fNot = false;
30
31 /**
32 * @param parent the parent node
33 */
34 public TmfFilterOrNode(ITmfFilterTreeNode parent) {
35 super(parent);
36 }
37
38 @Override
39 public String getNodeName() {
40 return NODE_NAME;
41 }
42
43 /**
44 * @return the NOT state
45 */
46 public boolean isNot() {
47 return fNot;
48 }
49
50 /**
51 * @param not the NOT state
52 */
53 public void setNot(boolean not) {
54 this.fNot = not;
55 }
56
57 @Override
58 public boolean matches(ITmfEvent event) {
59 for (ITmfFilterTreeNode node : getChildren()) {
60 if (node.matches(event)) {
61 return true ^ fNot;
62 }
63 }
64 return false & fNot;
65 }
66
67 @Override
68 public String toString() {
69 StringBuffer buf = new StringBuffer();
70 if (fNot) {
71 buf.append("not "); //$NON-NLS-1$
72 }
73 if (getParent() != null && !(getParent() instanceof TmfFilterRootNode) && !(getParent() instanceof TmfFilterNode)) {
74 buf.append("( "); //$NON-NLS-1$
75 }
76 for (int i = 0; i < getChildrenCount(); i++) {
77 ITmfFilterTreeNode node = getChildren()[i];
78 buf.append(node.toString());
79 if (i < getChildrenCount() - 1) {
80 buf.append(" or "); //$NON-NLS-1$
81 }
82 }
83 if (getParent() != null && !(getParent() instanceof TmfFilterRootNode) && !(getParent() instanceof TmfFilterNode)) {
84 buf.append(" )"); //$NON-NLS-1$
85 }
86 return buf.toString();
87 }
88}
This page took 0.035753 seconds and 5 git commands to generate.