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
.core
.filter
.model
;
15 import java
.util
.ArrayList
;
16 import java
.util
.List
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfEvent
;
21 public class TmfFilterNode
extends TmfFilterTreeNode
{
23 public static final String NODE_NAME
= "FILTER"; //$NON-NLS-1$
24 public static final String NAME_ATTR
= "name"; //$NON-NLS-1$
28 public TmfFilterNode(String filterName
) {
30 fFilterName
= filterName
;
33 public TmfFilterNode(ITmfFilterTreeNode parent
, String filterName
) {
35 fFilterName
= filterName
;
38 public String
getFilterName() {
42 public void setFilterName(String filterName
) {
43 fFilterName
= filterName
;
47 public String
getNodeName() {
52 public boolean matches(TmfEvent event
) {
53 // There should be at most one child
54 for (ITmfFilterTreeNode node
: getChildren()) {
55 if (node
.matches(event
)) {
63 public List
<String
> getValidChildren() {
64 if (getChildrenCount() == 0) {
65 return super.getValidChildren();
67 return new ArrayList
<String
>(0); // only one child allowed
72 public String
toString() {
73 StringBuffer buf
= new StringBuffer();
74 if (getChildrenCount() > 1) {
75 buf
.append("( "); //$NON-NLS-1$
77 for (int i
= 0; i
< getChildrenCount(); i
++) {
78 ITmfFilterTreeNode node
= getChildren()[i
];
79 buf
.append(node
.toString());
80 if (i
< getChildrenCount() - 1) {
81 buf
.append(" and "); //$NON-NLS-1$
84 if (getChildrenCount() > 1) {
85 buf
.append(" )"); //$NON-NLS-1$
87 return buf
.toString();