1 /*******************************************************************************
2 * Copyright (c) 2010 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 public class TmfFilterEqualsNode
extends TmfFilterTreeNode
{
29 public static final String NODE_NAME
= "EQUALS"; //$NON-NLS-1$
30 public static final String NOT_ATTR
= "not"; //$NON-NLS-1$
31 public static final String FIELD_ATTR
= "field"; //$NON-NLS-1$
32 public static final String VALUE_ATTR
= "value"; //$NON-NLS-1$
33 public static final String IGNORECASE_ATTR
= "ignorecase"; //$NON-NLS-1$
35 private boolean fNot
= false;
36 private String fField
;
37 private String fValue
;
38 private boolean fIgnoreCase
= false;
40 public TmfFilterEqualsNode(ITmfFilterTreeNode parent
) {
44 public boolean isNot() {
48 public void setNot(boolean not
) {
52 public String
getField() {
56 public void setField(String field
) {
60 public String
getValue() {
64 public void setValue(String value
) {
68 public boolean isIgnoreCase() {
72 public void setIgnoreCase(boolean ignoreCase
) {
73 this.fIgnoreCase
= ignoreCase
;
77 public String
getNodeName() {
82 public boolean matches(ITmfEvent event
) {
83 Object value
= getFieldValue(event
, fField
);
87 String valueString
= value
.toString();
88 if (valueString
== null) {
92 return valueString
.equalsIgnoreCase(fValue
) ^ fNot
;
94 return valueString
.equals(fValue
) ^ fNot
;
99 public List
<String
> getValidChildren() {
100 return new ArrayList
<String
>(0);
104 public String
toString() {
105 return fField
+ (fNot ?
" not" : "") + " equals \"" + fValue
+ "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
109 public ITmfFilterTreeNode
clone() {
110 TmfFilterEqualsNode clone
= (TmfFilterEqualsNode
) super.clone();
111 clone
.fField
= fField
;
112 clone
.fValue
= fValue
;