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 if (event
.getType().getTypeId().equals(fName
)) {
58 // There should be at most one child
59 for (ITmfFilterTreeNode node
: getChildren()) {
60 if (! node
.matches(event
)) {
70 public List
<String
> getValidChildren() {
71 if (getChildrenCount() == 0) {
72 return super.getValidChildren();
74 return new ArrayList
<String
>(0); // only one child allowed
79 public String
toString() {
80 StringBuffer buf
= new StringBuffer();
81 buf
.append("EventType is " + fName
); //$NON-NLS-1$
82 if (getChildrenCount() > 0) {
83 buf
.append(" and "); //$NON-NLS-1$
85 if (getChildrenCount() > 1) {
86 buf
.append("( "); //$NON-NLS-1$
88 for (int i
= 0; i
< getChildrenCount(); i
++) {
89 ITmfFilterTreeNode node
= getChildren()[i
];
90 buf
.append(node
.toString());
91 if (i
< getChildrenCount() - 1) {
92 buf
.append(" and "); //$NON-NLS-1$
95 if (getChildrenCount() > 1) {
96 buf
.append(" )"); //$NON-NLS-1$
98 return buf
.toString();