Fix warnings from FindBugs
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / filter / model / TmfFilterEqualsNode.java
1 /*******************************************************************************
2 * Copyright (c) 2010 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.tmf.core.filter.model;
14
15 import java.util.ArrayList;
16 import java.util.List;
17
18 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
19
20
21 public class TmfFilterEqualsNode extends TmfFilterTreeNode {
22
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$
28
29 private boolean fNot = false;
30 private String fField;
31 private String fValue;
32 private boolean fIgnoreCase = false;
33
34 public TmfFilterEqualsNode(ITmfFilterTreeNode parent) {
35 super(parent);
36 }
37
38 public boolean isNot() {
39 return fNot;
40 }
41
42 public void setNot(boolean not) {
43 this.fNot = not;
44 }
45
46 public String getField() {
47 return fField;
48 }
49
50 public void setField(String field) {
51 this.fField = field;
52 }
53
54 public String getValue() {
55 return fValue;
56 }
57
58 public void setValue(String value) {
59 this.fValue = value;
60 }
61
62 public boolean isIgnoreCase() {
63 return fIgnoreCase;
64 }
65
66 public void setIgnoreCase(boolean ignoreCase) {
67 this.fIgnoreCase = ignoreCase;
68 }
69
70 @Override
71 public String getNodeName() {
72 return NODE_NAME;
73 }
74
75 @Override
76 public boolean matches(ITmfEvent event) {
77 Object value = getFieldValue(event, fField);
78 if (value == null) {
79 return false ^ fNot;
80 }
81 String valueString = value.toString();
82 if (valueString == null) {
83 return false ^ fNot;
84 }
85 if (fIgnoreCase) {
86 return valueString.equalsIgnoreCase(fValue) ^ fNot;
87 } else {
88 return valueString.equals(fValue) ^ fNot;
89 }
90 }
91
92 @Override
93 public List<String> getValidChildren() {
94 return new ArrayList<String>(0);
95 }
96
97 @Override
98 public String toString() {
99 return fField + (fNot ? " not" : "") + " equals \"" + fValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
100 }
101
102 @Override
103 public ITmfFilterTreeNode clone() {
104 TmfFilterEqualsNode clone = (TmfFilterEqualsNode) super.clone();
105 clone.fField = fField;
106 clone.fValue = fValue;
107 return clone;
108 }
109 }
This page took 0.032892 seconds and 5 git commands to generate.