tmf: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / tmf / core / filter / model / TmfFilterEqualsNode.java
1 /*******************************************************************************
2 * Copyright (c) 2010, 2015 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.tracecompass.tmf.core.filter.model;
14
15 import java.util.ArrayList;
16 import java.util.List;
17
18 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
19
20 /**
21 * Filter node for the '==' operation
22 *
23 * @version 1.0
24 * @author Patrick Tasse
25 */
26 public class TmfFilterEqualsNode extends TmfFilterAspectNode {
27
28 /** equals node name */
29 public static final String NODE_NAME = "EQUALS"; //$NON-NLS-1$
30 /** not attribute name */
31 public static final String NOT_ATTR = "not"; //$NON-NLS-1$
32 /** value attribute name */
33 public static final String VALUE_ATTR = "value"; //$NON-NLS-1$
34 /** ignorecase attribute name */
35 public static final String IGNORECASE_ATTR = "ignorecase"; //$NON-NLS-1$
36
37 private boolean fNot = false;
38 private String fValue;
39 private boolean fIgnoreCase = false;
40
41 /**
42 * @param parent the parent node
43 */
44 public TmfFilterEqualsNode(ITmfFilterTreeNode parent) {
45 super(parent);
46 }
47
48 /**
49 * @return the NOT state
50 */
51 public boolean isNot() {
52 return fNot;
53 }
54
55 /**
56 * @param not the NOT state
57 */
58 public void setNot(boolean not) {
59 this.fNot = not;
60 }
61
62 /**
63 * @return the equals value
64 */
65 public String getValue() {
66 return fValue;
67 }
68
69 /**
70 * @param value the equals value
71 */
72 public void setValue(String value) {
73 this.fValue = value;
74 }
75
76 /**
77 * @return the ignoreCase state
78 */
79 public boolean isIgnoreCase() {
80 return fIgnoreCase;
81 }
82
83 /**
84 * @param ignoreCase the ignoreCase state
85 */
86 public void setIgnoreCase(boolean ignoreCase) {
87 this.fIgnoreCase = ignoreCase;
88 }
89
90 @Override
91 public String getNodeName() {
92 return NODE_NAME;
93 }
94
95 @Override
96 public boolean matches(ITmfEvent event) {
97 if (event == null || fEventAspect == null) {
98 return false ^ fNot;
99 }
100 Object value = fEventAspect.resolve(event);
101 if (value == null) {
102 return false ^ fNot;
103 }
104 String valueString = value.toString();
105 if (fIgnoreCase) {
106 return valueString.equalsIgnoreCase(fValue) ^ fNot;
107 }
108 return valueString.equals(fValue) ^ fNot;
109 }
110
111 @Override
112 public List<String> getValidChildren() {
113 return new ArrayList<>(0);
114 }
115
116 @Override
117 public String toString(boolean explicit) {
118 return getAspectLabel(explicit) + (fNot ? " not equals " : " equals ") + (fIgnoreCase ? "ignorecase \"" : "\"") + fValue + '\"'; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
119 }
120
121 @Override
122 public ITmfFilterTreeNode clone() {
123 TmfFilterEqualsNode clone = (TmfFilterEqualsNode) super.clone();
124 clone.setValue(fValue);
125 return clone;
126 }
127 }
This page took 0.037326 seconds and 5 git commands to generate.