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
;
21 public class TmfFilterEqualsNode
extends TmfFilterTreeNode
{
23 public static final String NODE_NAME
= "EQUALS"; //$NON-NLS-1$
24 public static final String NOT_ATTR
= "not"; //$NON-NLS-1$
25 public static final String FIELD_ATTR
= "field"; //$NON-NLS-1$
26 public static final String VALUE_ATTR
= "value"; //$NON-NLS-1$
27 public static final String IGNORECASE_ATTR
= "ignorecase"; //$NON-NLS-1$
29 private boolean fNot
= false;
30 private String fField
;
31 private String fValue
;
32 private boolean fIgnoreCase
= false;
34 public TmfFilterEqualsNode(ITmfFilterTreeNode parent
) {
38 public boolean isNot() {
42 public void setNot(boolean not
) {
46 public String
getField() {
50 public void setField(String field
) {
54 public String
getValue() {
58 public void setValue(String value
) {
62 public boolean isIgnoreCase() {
66 public void setIgnoreCase(boolean ignoreCase
) {
67 this.fIgnoreCase
= ignoreCase
;
71 public String
getNodeName() {
76 public boolean matches(ITmfEvent event
) {
77 Object value
= getFieldValue(event
, fField
);
81 String valueString
= value
.toString();
82 if (valueString
== null) {
86 return valueString
.equalsIgnoreCase(fValue
) ^ fNot
;
88 return valueString
.equals(fValue
) ^ fNot
;
93 public List
<String
> getValidChildren() {
94 return new ArrayList
<String
>(0);
98 public String
toString() {
99 return fField
+ (fNot ?
" not" : "") + " equals \"" + fValue
+ "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
103 public ITmfFilterTreeNode
clone() {
104 TmfFilterEqualsNode clone
= (TmfFilterEqualsNode
) super.clone();
105 clone
.fField
= new String(fField
);
106 clone
.fValue
= new String(fValue
);