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
.ITmfEvent
;
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(ITmfEvent 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
71 public String
toString() {
72 StringBuffer buf
= new StringBuffer();
73 if (getChildrenCount() > 1) {
74 buf
.append("( "); //$NON-NLS-1$
76 for (int i
= 0; i
< getChildrenCount(); i
++) {
77 ITmfFilterTreeNode node
= getChildren()[i
];
78 buf
.append(node
.toString());
79 if (i
< (getChildrenCount() - 1)) {
80 buf
.append(" and "); //$NON-NLS-1$
83 if (getChildrenCount() > 1) {
84 buf
.append(" )"); //$NON-NLS-1$
86 return buf
.toString();