1 /*******************************************************************************
2 * Copyright (c) 2010, 2012 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 @SuppressWarnings("javadoc")
24 public class TmfFilterOrNode
extends TmfFilterTreeNode
{
26 public static final String NODE_NAME
= "OR"; //$NON-NLS-1$
27 public static final String NOT_ATTR
= "not"; //$NON-NLS-1$
29 private boolean fNot
= false;
32 * @param parent the parent node
34 public TmfFilterOrNode(ITmfFilterTreeNode parent
) {
39 public String
getNodeName() {
44 * @return the NOT state
46 public boolean isNot() {
51 * @param not the NOT state
53 public void setNot(boolean not
) {
58 public boolean matches(ITmfEvent event
) {
59 for (ITmfFilterTreeNode node
: getChildren()) {
60 if (node
.matches(event
)) {
68 public String
toString() {
69 StringBuffer buf
= new StringBuffer();
71 buf
.append("not "); //$NON-NLS-1$
73 if (getParent() != null && !(getParent() instanceof TmfFilterRootNode
) && !(getParent() instanceof TmfFilterNode
)) {
74 buf
.append("( "); //$NON-NLS-1$
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$
83 if (getParent() != null && !(getParent() instanceof TmfFilterRootNode
) && !(getParent() instanceof TmfFilterNode
)) {
84 buf
.append(" )"); //$NON-NLS-1$
86 return buf
.toString();
90 public int hashCode() {
92 int result
= super.hashCode();
93 result
= prime
* result
+ (fNot ?
1231 : 1237);
98 public boolean equals(Object obj
) {
102 if (!super.equals(obj
)) {
105 if (getClass() != obj
.getClass()) {
108 TmfFilterOrNode other
= (TmfFilterOrNode
) obj
;
109 if (fNot
!= other
.fNot
) {