1 /*******************************************************************************
2 * Copyright (c) 2010, 2015 Ericsson
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
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
;
15 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
18 * Filter node for the 'or' operation
21 * @author Patrick Tasse
23 public class TmfFilterOrNode
extends TmfFilterTreeNode
{
26 public static final String NODE_NAME
= "OR"; //$NON-NLS-1$
27 /** not attribute name */
28 public static final String NOT_ATTR
= "not"; //$NON-NLS-1$
30 private boolean fNot
= false;
33 * @param parent the parent node
35 public TmfFilterOrNode(ITmfFilterTreeNode parent
) {
40 public String
getNodeName() {
45 * @return the NOT state
47 public boolean isNot() {
52 * @param not the NOT state
54 public void setNot(boolean not
) {
59 public boolean matches(ITmfEvent event
) {
60 for (ITmfFilterTreeNode node
: getChildren()) {
61 if (node
.matches(event
)) {
69 public String
toString(boolean explicit
) {
70 StringBuffer buf
= new StringBuffer();
72 buf
.append("not "); //$NON-NLS-1$
74 if (getParent() != null && !(getParent() instanceof TmfFilterRootNode
) && !(getParent() instanceof TmfFilterNode
)) {
75 buf
.append("( "); //$NON-NLS-1$
77 for (int i
= 0; i
< getChildrenCount(); i
++) {
78 ITmfFilterTreeNode node
= getChildren()[i
];
79 buf
.append(node
.toString(explicit
));
80 if (i
< getChildrenCount() - 1) {
81 buf
.append(" or "); //$NON-NLS-1$
84 if (getParent() != null && !(getParent() instanceof TmfFilterRootNode
) && !(getParent() instanceof TmfFilterNode
)) {
85 buf
.append(" )"); //$NON-NLS-1$
87 return buf
.toString();