tmf: Support aspect-based filtering in FilterViewer
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / tmf / core / filter / model / TmfFilterContainsNode.java
index 5052b64eadb5649a98b01f02864576ddd0941958..f523e75d3a7eaba98dbac12dd2046c0e48ddf966 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2010, 2014 Ericsson
+ * Copyright (c) 2010, 2015 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -23,17 +23,18 @@ import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
  * @version 1.0
  * @author Patrick Tasse
  */
-@SuppressWarnings("javadoc")
-public class TmfFilterContainsNode extends TmfFilterTreeNode {
+public class TmfFilterContainsNode extends TmfFilterAspectNode {
 
+    /** contains node name */
     public static final String NODE_NAME = "CONTAINS"; //$NON-NLS-1$
+    /** not attribute name */
     public static final String NOT_ATTR = "not"; //$NON-NLS-1$
-    public static final String FIELD_ATTR = "field"; //$NON-NLS-1$
+    /** value attribute name */
     public static final String VALUE_ATTR = "value"; //$NON-NLS-1$
+    /** ignorecase attribute name */
     public static final String IGNORECASE_ATTR = "ignorecase"; //$NON-NLS-1$
 
     private boolean fNot = false;
-    private String fField;
     private String fValue;
     private transient String fValueUpperCase;
     private boolean fIgnoreCase = false;
@@ -59,20 +60,6 @@ public class TmfFilterContainsNode extends TmfFilterTreeNode {
         this.fNot = not;
     }
 
-    /**
-     * @return the field name
-     */
-    public String getField() {
-        return fField;
-    }
-
-    /**
-     * @param field the field name
-     */
-    public void setField(String field) {
-        this.fField = field;
-    }
-
     /**
      * @return the contains value
      */
@@ -84,7 +71,8 @@ public class TmfFilterContainsNode extends TmfFilterTreeNode {
      * @param value the contains value
      */
     public void setValue(String value) {
-        this.fValue = value;
+        fValue = value;
+        fValueUpperCase = null;
         if (value != null) {
             fValueUpperCase = value.toUpperCase();
         }
@@ -111,7 +99,10 @@ public class TmfFilterContainsNode extends TmfFilterTreeNode {
 
     @Override
     public boolean matches(ITmfEvent event) {
-        Object value = getFieldValue(event, fField);
+        if (event == null || fEventAspect == null) {
+            return false ^ fNot;
+        }
+        Object value = fEventAspect.resolve(event);
         if (value == null) {
             return false ^ fNot;
         }
@@ -129,13 +120,13 @@ public class TmfFilterContainsNode extends TmfFilterTreeNode {
 
     @Override
     public String toString() {
-        return fField + (fNot ? " not" : "") + " contains \"" + fValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+        String aspectName = fEventAspect != null ? fEventAspect.getName() : ""; //$NON-NLS-1$
+        return aspectName + (fNot ? " not" : "") + " contains \"" + fValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
     }
 
     @Override
     public ITmfFilterTreeNode clone() {
         TmfFilterContainsNode clone = (TmfFilterContainsNode) super.clone();
-        clone.fField = fField;
         clone.setValue(fValue);
         return clone;
     }
@@ -144,7 +135,6 @@ public class TmfFilterContainsNode extends TmfFilterTreeNode {
     public int hashCode() {
         final int prime = 31;
         int result = super.hashCode();
-        result = prime * result + ((fField == null) ? 0 : fField.hashCode());
         result = prime * result + (fIgnoreCase ? 1231 : 1237);
         result = prime * result + (fNot ? 1231 : 1237);
         result = prime * result + ((fValue == null) ? 0 : fValue.hashCode());
@@ -163,13 +153,6 @@ public class TmfFilterContainsNode extends TmfFilterTreeNode {
             return false;
         }
         TmfFilterContainsNode other = (TmfFilterContainsNode) obj;
-        if (fField == null) {
-            if (other.fField != null) {
-                return false;
-            }
-        } else if (!fField.equals(other.fField)) {
-            return false;
-        }
         if (fIgnoreCase != other.fIgnoreCase) {
             return false;
         }
This page took 0.026767 seconds and 5 git commands to generate.