1 /*******************************************************************************
2 * Copyright (c) 2010 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
.filter
.model
;
15 import java
.util
.ArrayList
;
16 import java
.util
.List
;
18 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEvent
;
21 public class TmfFilterEventTypeNode
extends TmfFilterTreeNode
{
23 public static final String NODE_NAME
= "EVENTTYPE"; //$NON-NLS-1$
24 public static final String TYPE_ATTR
= "type"; //$NON-NLS-1$
25 public static final String NAME_ATTR
= "name"; //$NON-NLS-1$
30 public TmfFilterEventTypeNode(ITmfFilterTreeNode parent
) {
35 public String
getNodeName() {
39 public String
getEventType() {
43 public void setEventType(String type
) {
47 public String
getName() {
51 public void setName(String name
) {
56 public boolean matches(TmfEvent event
) {
57 boolean match
= false;
58 if (fType
.contains(":")) { //$NON-NLS-1$
59 // special case for custom parsers
60 if (fType
.startsWith(event
.getClass().getCanonicalName())) {
61 if (fType
.endsWith(event
.getType().getTypeId())) {
66 if (event
.getClass().getCanonicalName().equals(fType
)) {
71 // There should be at most one child
72 for (ITmfFilterTreeNode node
: getChildren()) {
73 if (! node
.matches(event
)) {
83 public List
<String
> getValidChildren() {
84 if (getChildrenCount() == 0) {
85 return super.getValidChildren();
87 return new ArrayList
<String
>(0); // only one child allowed
92 public String
toString() {
93 StringBuffer buf
= new StringBuffer();
94 buf
.append("EventType is " + fName
); //$NON-NLS-1$
95 if (getChildrenCount() > 0) {
96 buf
.append(" and "); //$NON-NLS-1$
98 if (getChildrenCount() > 1) {
99 buf
.append("( "); //$NON-NLS-1$
101 for (int i
= 0; i
< getChildrenCount(); i
++) {
102 ITmfFilterTreeNode node
= getChildren()[i
];
103 buf
.append(node
.toString());
104 if (i
< getChildrenCount() - 1) {
105 buf
.append(" and "); //$NON-NLS-1$
108 if (getChildrenCount() > 1) {
109 buf
.append(" )"); //$NON-NLS-1$
111 return buf
.toString();