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
.filter
.model
;
15 import java
.util
.ArrayList
;
16 import java
.util
.List
;
18 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEvent
;
19 import org
.eclipse
.linuxtools
.tmf
.event
.TmfNoSuchFieldException
;
22 public class TmfFilterEqualsNode
extends TmfFilterTreeNode
{
24 public static final String NODE_NAME
= "EQUALS"; //$NON-NLS-1$
25 public static final String NOT_ATTR
= "not"; //$NON-NLS-1$
26 public static final String FIELD_ATTR
= "field"; //$NON-NLS-1$
27 public static final String VALUE_ATTR
= "value"; //$NON-NLS-1$
28 public static final String IGNORECASE_ATTR
= "ignorecase"; //$NON-NLS-1$
30 private boolean fNot
= false;
31 private String fField
;
32 private String fValue
;
33 private boolean fIgnoreCase
= false;
35 public TmfFilterEqualsNode(ITmfFilterTreeNode parent
) {
39 public boolean isNot() {
43 public void setNot(boolean not
) {
47 public String
getField() {
51 public void setField(String field
) {
55 public String
getValue() {
59 public void setValue(String value
) {
63 public boolean isIgnoreCase() {
67 public void setIgnoreCase(boolean ignoreCase
) {
68 this.fIgnoreCase
= ignoreCase
;
72 public String
getNodeName() {
77 public boolean matches(TmfEvent event
) {
79 Object value
= event
.getContent().getField(fField
);
83 String valueString
= value
.toString();
84 if (valueString
== null) {
88 return valueString
.equalsIgnoreCase(fValue
) ^ fNot
;
90 return valueString
.equals(fValue
) ^ fNot
;
92 } catch (TmfNoSuchFieldException e
) {
98 public List
<String
> getValidChildren() {
99 return new ArrayList
<String
>(0);
103 public String
toString() {
104 return fField
+ (fNot ?
" not" : "") + " equals \"" + fValue
+ "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
108 public ITmfFilterTreeNode
clone() {
109 TmfFilterEqualsNode clone
= (TmfFilterEqualsNode
) super.clone();
110 clone
.fField
= new String(fField
);
111 clone
.fValue
= new String(fValue
);