1 /*******************************************************************************
2 * Copyright (c) 2010, 2012 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 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
;
15 import java
.util
.ArrayList
;
16 import java
.util
.List
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEvent
;
21 * Filter node for an event
24 * @author Patrick Tasse
26 @SuppressWarnings("javadoc")
27 public class TmfFilterEventTypeNode
extends TmfFilterTreeNode
{
29 public static final String NODE_NAME
= "EVENTTYPE"; //$NON-NLS-1$
30 public static final String TYPE_ATTR
= "type"; //$NON-NLS-1$
31 public static final String NAME_ATTR
= "name"; //$NON-NLS-1$
37 * @param parent the parent node
39 public TmfFilterEventTypeNode(ITmfFilterTreeNode parent
) {
44 public String
getNodeName() {
49 * @return the event type
51 public String
getEventType() {
56 * @param type the event type
58 public void setEventType(String type
) {
65 public String
getName() {
72 public void setName(String name
) {
77 public boolean matches(ITmfEvent event
) {
78 boolean match
= false;
79 if (fType
.contains(":")) { //$NON-NLS-1$
80 // special case for custom parsers
81 if (fType
.startsWith(event
.getClass().getCanonicalName())) {
82 if (fType
.endsWith(event
.getType().getName())) {
87 if (event
.getClass().getCanonicalName().equals(fType
)) {
92 // There should be at most one child
93 for (ITmfFilterTreeNode node
: getChildren()) {
94 if (! node
.matches(event
)) {
104 public List
<String
> getValidChildren() {
105 if (getChildrenCount() == 0) {
106 return super.getValidChildren();
108 return new ArrayList
<>(0); // only one child allowed
112 public String
toString() {
113 StringBuffer buf
= new StringBuffer();
114 buf
.append("EventType is " + fName
); //$NON-NLS-1$
115 if (getChildrenCount() > 0) {
116 buf
.append(" and "); //$NON-NLS-1$
118 if (getChildrenCount() > 1) {
119 buf
.append("( "); //$NON-NLS-1$
121 for (int i
= 0; i
< getChildrenCount(); i
++) {
122 ITmfFilterTreeNode node
= getChildren()[i
];
123 buf
.append(node
.toString());
124 if (i
< getChildrenCount() - 1) {
125 buf
.append(" and "); //$NON-NLS-1$
128 if (getChildrenCount() > 1) {
129 buf
.append(" )"); //$NON-NLS-1$
131 return buf
.toString();