1 /*******************************************************************************
2 * Copyright (c) 2014, 2015 Ericsson
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
10 * Alexandre Montplaisir - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.core
.filter
.model
;
15 import java
.util
.regex
.Pattern
;
17 import org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
;
18 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
19 import org
.eclipse
.tracecompass
.tmf
.core
.event
.aspect
.ITmfEventAspect
;
22 * Filter node that matches on an event aspect.
24 * @author Alexandre Montplaisir
26 public final class TmfFilterMatchesAspectNode
extends TmfFilterMatchesNode
{
28 /** Name/ID of this node */
29 public static final String NODE_NAME
= "MATCHES_ASPECT"; //$NON-NLS-1$
31 private ITmfEventAspect fEventAspect
;
39 public TmfFilterMatchesAspectNode(ITmfFilterTreeNode parent
) {
44 public String
getNodeName() {
49 public boolean matches(ITmfEvent event
) {
50 Pattern pattern
= getPattern();
51 boolean isNot
= isNot();
53 if (pattern
== null || event
== null) {
56 String value
= NonNullUtils
.nullToEmptyString(fEventAspect
.resolve(event
));
57 return pattern
.matcher(value
).matches() ^ isNot
;
61 * @return The event aspect of this filter
63 public ITmfEventAspect
getEventAspect() {
69 * The event aspect to assign to this filter
71 public void setEventAspect(ITmfEventAspect aspect
) {
72 this.fEventAspect
= aspect
;
76 public ITmfFilterTreeNode
clone() {
77 TmfFilterMatchesAspectNode clone
= (TmfFilterMatchesAspectNode
) super.clone();
78 clone
.fEventAspect
= fEventAspect
;
83 public String
toString() {
84 return fEventAspect
.getName() + (isNot() ?
" not" : "") + " matches \"" + getRegex() + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
88 public int hashCode() {
90 int result
= super.hashCode();
91 result
= prime
* result
+ ((fEventAspect
== null) ?
0 : fEventAspect
.hashCode());
96 public boolean equals(Object obj
) {
100 if (!super.equals(obj
)) {
103 if (getClass() != obj
.getClass()) {
106 TmfFilterMatchesAspectNode other
= (TmfFilterMatchesAspectNode
) obj
;
107 if (fEventAspect
== null) {
108 if (other
.fEventAspect
!= null) {
111 } else if (!fEventAspect
.equals(other
.fEventAspect
)) {