tmf: Simple warning fixes in tmf.core and tests
[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 /**
22 * Filter node for the '==' operation
23 *
24 * @version 1.0
25 * @author Patrick Tasse
26 */
27 public class TmfFilterEqualsNode extends TmfFilterTreeNode {
28
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$
34
35 private boolean fNot = false;
36 private String fField;
37 private String fValue;
38 private boolean fIgnoreCase = false;
39
40 public TmfFilterEqualsNode(ITmfFilterTreeNode parent) {
41 super(parent);
42 }
43
44 public boolean isNot() {
45 return fNot;
46 }
47
48 public void setNot(boolean not) {
49 this.fNot = not;
50 }
51
52 public String getField() {
53 return fField;
54 }
55
56 public void setField(String field) {
57 this.fField = field;
58 }
59
60 public String getValue() {
61 return fValue;
62 }
63
64 public void setValue(String value) {
65 this.fValue = value;
66 }
67
68 public boolean isIgnoreCase() {
69 return fIgnoreCase;
70 }
71
72 public void setIgnoreCase(boolean ignoreCase) {
73 this.fIgnoreCase = ignoreCase;
74 }
75
76 @Override
77 public String getNodeName() {
78 return NODE_NAME;
79 }
80
81 @Override
82 public boolean matches(ITmfEvent event) {
83 Object value = getFieldValue(event, fField);
84 if (value == null) {
85 return false ^ fNot;
86 }
87 String valueString = value.toString();
88 if (valueString == null) {
89 return false ^ fNot;
90 }
91 if (fIgnoreCase) {
92 return valueString.equalsIgnoreCase(fValue) ^ fNot;
93 }
94 return valueString.equals(fValue) ^ fNot;
95 }
96
97 @Override
98 public List<String> getValidChildren() {
99 return new ArrayList<String>(0);
100 }
101
102 @Override
103 public String toString() {
104 return fField + (fNot ? " not" : "") + " equals \"" + fValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
105 }
106
107 @Override
108 public ITmfFilterTreeNode clone() {
109 TmfFilterEqualsNode clone = (TmfFilterEqualsNode) super.clone();
110 clone.fField = fField;
111 clone.fValue = fValue;
112 return clone;
113 }
114 }
This page took 0.03306 seconds and 5 git commands to generate.