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 java
.util
.ArrayList
;
16 import java
.util
.List
;
18 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
22 * Filter node for the '==' operation
25 * @author Patrick Tasse
27 public class TmfFilterEqualsNode
extends TmfFilterAspectNode
{
29 /** equals node name */
30 public static final String NODE_NAME
= "EQUALS"; //$NON-NLS-1$
31 /** not attribute name */
32 public static final String NOT_ATTR
= "not"; //$NON-NLS-1$
33 /** value attribute name */
34 public static final String VALUE_ATTR
= "value"; //$NON-NLS-1$
35 /** ignorecase attribute name */
36 public static final String IGNORECASE_ATTR
= "ignorecase"; //$NON-NLS-1$
38 private boolean fNot
= false;
39 private String fValue
;
40 private boolean fIgnoreCase
= false;
43 * @param parent the parent node
45 public TmfFilterEqualsNode(ITmfFilterTreeNode parent
) {
50 * @return the NOT state
52 public boolean isNot() {
57 * @param not the NOT state
59 public void setNot(boolean not
) {
64 * @return the equals value
66 public String
getValue() {
71 * @param value the equals value
73 public void setValue(String value
) {
78 * @return the ignoreCase state
80 public boolean isIgnoreCase() {
85 * @param ignoreCase the ignoreCase state
87 public void setIgnoreCase(boolean ignoreCase
) {
88 this.fIgnoreCase
= ignoreCase
;
92 public String
getNodeName() {
97 public boolean matches(ITmfEvent event
) {
98 if (event
== null || fEventAspect
== null) {
101 Object value
= fEventAspect
.resolve(event
);
105 String valueString
= value
.toString();
107 return valueString
.equalsIgnoreCase(fValue
) ^ fNot
;
109 return valueString
.equals(fValue
) ^ fNot
;
113 public List
<String
> getValidChildren() {
114 return new ArrayList
<>(0);
118 public String
toString() {
119 return getAspectLabel() + (fNot ?
" not" : "") + " equals \"" + fValue
+ "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
123 public ITmfFilterTreeNode
clone() {
124 TmfFilterEqualsNode clone
= (TmfFilterEqualsNode
) super.clone();
125 clone
.setValue(fValue
);
130 public int hashCode() {
131 final int prime
= 31;
132 int result
= super.hashCode();
133 result
= prime
* result
+ (fIgnoreCase ?
1231 : 1237);
134 result
= prime
* result
+ (fNot ?
1231 : 1237);
135 result
= prime
* result
+ ((fValue
== null) ?
0 : fValue
.hashCode());
140 public boolean equals(Object obj
) {
144 if (!super.equals(obj
)) {
147 if (getClass() != obj
.getClass()) {
150 TmfFilterEqualsNode other
= (TmfFilterEqualsNode
) obj
;
151 if (fIgnoreCase
!= other
.fIgnoreCase
) {
154 if (fNot
!= other
.fNot
) {
157 if (fValue
== null) {
158 if (other
.fValue
!= null) {
161 } else if (!fValue
.equals(other
.fValue
)) {