1 /*******************************************************************************
2 * Copyright (c) 2010, 2013 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
.linuxtools
.tmf
.core
.filter
.model
;
15 import java
.util
.ArrayList
;
16 import java
.util
.List
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEvent
;
22 * Filter node for the '==' operation
25 * @author Patrick Tasse
27 @SuppressWarnings("javadoc")
28 public class TmfFilterEqualsNode
extends TmfFilterTreeNode
{
30 public static final String NODE_NAME
= "EQUALS"; //$NON-NLS-1$
31 public static final String NOT_ATTR
= "not"; //$NON-NLS-1$
32 public static final String FIELD_ATTR
= "field"; //$NON-NLS-1$
33 public static final String VALUE_ATTR
= "value"; //$NON-NLS-1$
34 public static final String IGNORECASE_ATTR
= "ignorecase"; //$NON-NLS-1$
36 private boolean fNot
= false;
37 private String fField
;
38 private String fValue
;
39 private boolean fIgnoreCase
= false;
42 * @param parent the aprent node
44 public TmfFilterEqualsNode(ITmfFilterTreeNode parent
) {
49 * @return the NOT state
51 public boolean isNot() {
56 * @param not the NOT state
58 public void setNot(boolean not
) {
63 * @return the field name
65 public String
getField() {
70 * @param field the field name
72 public void setField(String field
) {
77 * @return the equals value
79 public String
getValue() {
84 * @param value the equals value
86 public void setValue(String value
) {
91 * @return the ignoreCase state
93 public boolean isIgnoreCase() {
98 * @param ignoreCase the ignoreCase state
100 public void setIgnoreCase(boolean ignoreCase
) {
101 this.fIgnoreCase
= ignoreCase
;
105 public String
getNodeName() {
110 public boolean matches(ITmfEvent event
) {
111 Object value
= getFieldValue(event
, fField
);
115 String valueString
= value
.toString();
116 if (valueString
== null) {
120 return valueString
.equalsIgnoreCase(fValue
) ^ fNot
;
122 return valueString
.equals(fValue
) ^ fNot
;
126 public List
<String
> getValidChildren() {
127 return new ArrayList
<>(0);
131 public String
toString() {
132 return fField
+ (fNot ?
" not" : "") + " equals \"" + fValue
+ "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
136 public ITmfFilterTreeNode
clone() {
137 TmfFilterEqualsNode clone
= (TmfFilterEqualsNode
) super.clone();
138 clone
.fField
= fField
;
139 clone
.fValue
= fValue
;
144 public int hashCode() {
145 final int prime
= 31;
146 int result
= super.hashCode();
147 result
= prime
* result
+ ((fField
== null) ?
0 : fField
.hashCode());
148 result
= prime
* result
+ (fIgnoreCase ?
1231 : 1237);
149 result
= prime
* result
+ (fNot ?
1231 : 1237);
150 result
= prime
* result
+ ((fValue
== null) ?
0 : fValue
.hashCode());
155 public boolean equals(Object obj
) {
159 if (!super.equals(obj
)) {
162 if (getClass() != obj
.getClass()) {
165 TmfFilterEqualsNode other
= (TmfFilterEqualsNode
) obj
;
166 if (fField
== null) {
167 if (other
.fField
!= null) {
170 } else if (!fField
.equals(other
.fField
)) {
173 if (fIgnoreCase
!= other
.fIgnoreCase
) {
176 if (fNot
!= other
.fNot
) {
179 if (fValue
== null) {
180 if (other
.fValue
!= null) {
183 } else if (!fValue
.equals(other
.fValue
)) {