ss: Move plugins to Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / filter / model / TmfFilterEventTypeNode.java
index 20de59833c42f40c74254c98f8468ed0da9d71b9..55bead9a1bfd242c0db8c195b4a8d301485e5860 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.core.filter.model;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.eclipse.linuxtools.tmf.core.event.TmfEvent;\r
-\r
-\r
-public class TmfFilterEventTypeNode extends TmfFilterTreeNode {\r
-\r
-       public static final String NODE_NAME = "EVENTTYPE"; //$NON-NLS-1$\r
-       public static final String TYPE_ATTR = "type"; //$NON-NLS-1$\r
-       public static final String NAME_ATTR = "name"; //$NON-NLS-1$\r
-       \r
-       private String fType;\r
-       private String fName;\r
-       \r
-       public TmfFilterEventTypeNode(ITmfFilterTreeNode parent) {\r
-               super(parent);\r
-       }\r
-\r
-       @Override\r
-       public String getNodeName() {\r
-               return NODE_NAME;\r
-       }\r
-\r
-       public String getEventType() {\r
-               return fType;\r
-       }\r
-\r
-       public void setEventType(String type) {\r
-               this.fType = type;\r
-       }\r
-\r
-       public String getName() {\r
-               return fName;\r
-       }\r
-\r
-       public void setName(String name) {\r
-               this.fName = name;\r
-       }\r
-\r
-    @Override\r
-    public boolean matches(TmfEvent event) {\r
-        boolean match = false;\r
-        if (fType.contains(":")) { //$NON-NLS-1$\r
-            // special case for custom parsers\r
-            if (fType.startsWith(event.getClass().getCanonicalName())) {\r
-                if (fType.endsWith(event.getType().getId())) {\r
-                    match = true;\r
-                }\r
-            }\r
-        } else {\r
-            if (event.getClass().getCanonicalName().equals(fType)) {\r
-                match = true;\r
-            }\r
-        }\r
-        if (match) {\r
-            // There should be at most one child\r
-            for (ITmfFilterTreeNode node : getChildren()) {\r
-                if (! node.matches(event)) {\r
-                    return false;\r
-                }\r
-            }\r
-            return true;\r
-        }\r
-        return false;\r
-    }\r
-\r
-       @Override\r
-       public List<String> getValidChildren() {\r
-               if (getChildrenCount() == 0) {\r
-                       return super.getValidChildren();\r
-               } else {\r
-                       return new ArrayList<String>(0); // only one child allowed\r
-               }\r
-       }\r
-\r
-       @Override\r
-       public String toString() {\r
-               StringBuffer buf = new StringBuffer();\r
-               buf.append("EventType is " + fName); //$NON-NLS-1$\r
-               if (getChildrenCount() > 0) {\r
-                       buf.append(" and "); //$NON-NLS-1$\r
-               }\r
-               if (getChildrenCount() > 1) {\r
-                       buf.append("( "); //$NON-NLS-1$\r
-               }\r
-               for (int i = 0; i < getChildrenCount(); i++) {\r
-                       ITmfFilterTreeNode node = getChildren()[i];\r
-                       buf.append(node.toString());\r
-                       if (i < getChildrenCount() - 1) {\r
-                               buf.append(" and "); //$NON-NLS-1$\r
-                       }\r
-               }\r
-               if (getChildrenCount() > 1) {\r
-                       buf.append(" )"); //$NON-NLS-1$\r
-               }\r
-               return buf.toString();\r
-       }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.filter.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+
+/**
+ * Filter node for an event
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+@SuppressWarnings("javadoc")
+public class TmfFilterEventTypeNode extends TmfFilterTreeNode {
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + ((fName == null) ? 0 : fName.hashCode());
+        result = prime * result + ((fType == null) ? 0 : fType.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (!super.equals(obj)) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        TmfFilterEventTypeNode other = (TmfFilterEventTypeNode) obj;
+        if (fName == null) {
+            if (other.fName != null) {
+                return false;
+            }
+        } else if (!fName.equals(other.fName)) {
+            return false;
+        }
+        if (fType == null) {
+            if (other.fType != null) {
+                return false;
+            }
+        } else if (!fType.equals(other.fType)) {
+            return false;
+        }
+        return true;
+    }
+
+    public static final String NODE_NAME = "EVENTTYPE"; //$NON-NLS-1$
+    public static final String TYPE_ATTR = "type"; //$NON-NLS-1$
+    public static final String NAME_ATTR = "name"; //$NON-NLS-1$
+
+    private String fType;
+    private String fName;
+
+    /**
+     * @param parent the parent node
+     */
+    public TmfFilterEventTypeNode(ITmfFilterTreeNode parent) {
+        super(parent);
+    }
+
+    @Override
+    public String getNodeName() {
+        return NODE_NAME;
+    }
+
+    /**
+     * @return the event type
+     */
+    public String getEventType() {
+        return fType;
+    }
+
+    /**
+     * @param type the event type
+     */
+    public void setEventType(String type) {
+        this.fType = type;
+    }
+
+    /**
+     * @return the category and trace type name
+     */
+    public String getName() {
+        return fName;
+    }
+
+    /**
+     * @param name the category and trace type name
+     */
+    public void setName(String name) {
+        this.fName = name;
+    }
+
+    @Override
+    public boolean matches(ITmfEvent event) {
+        boolean match = false;
+        if (fType.contains(":")) { //$NON-NLS-1$
+            // special case for custom parsers
+            if (fType.startsWith(event.getClass().getCanonicalName())) {
+                if (fType.endsWith(event.getType().getName())) {
+                    match = true;
+                }
+            }
+        } else {
+            if (event.getClass().getCanonicalName().equals(fType)) {
+                match = true;
+            }
+        }
+        if (match) {
+            // There should be at most one child
+            for (ITmfFilterTreeNode node : getChildren()) {
+                if (! node.matches(event)) {
+                    return false;
+                }
+            }
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public List<String> getValidChildren() {
+        if (getChildrenCount() == 0) {
+            return super.getValidChildren();
+        }
+        return new ArrayList<>(0); // only one child allowed
+    }
+
+    @Override
+    public String toString() {
+        StringBuffer buf = new StringBuffer();
+        buf.append("EventType is " + fName); //$NON-NLS-1$
+        if (getChildrenCount() > 0) {
+            buf.append(" and "); //$NON-NLS-1$
+        }
+        if (getChildrenCount() > 1) {
+            buf.append("( "); //$NON-NLS-1$
+        }
+        for (int i = 0; i < getChildrenCount(); i++) {
+            ITmfFilterTreeNode node = getChildren()[i];
+            buf.append(node.toString());
+            if (i < getChildrenCount() - 1) {
+                buf.append(" and "); //$NON-NLS-1$
+            }
+        }
+        if (getChildrenCount() > 1) {
+            buf.append(" )"); //$NON-NLS-1$
+        }
+        return buf.toString();
+    }
+}
This page took 0.029834 seconds and 5 git commands to generate.