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
* Filter node for the event match operation
24
* @author Patrick Tasse
26
public class TmfFilterNode extends TmfFilterTreeNode {
28
public static final String NODE_NAME = "FILTER"; //$NON-NLS-1$
29
public static final String NAME_ATTR = "name"; //$NON-NLS-1$
33
public TmfFilterNode(String filterName) {
35
fFilterName = filterName;
38
public TmfFilterNode(ITmfFilterTreeNode parent, String filterName) {
40
fFilterName = filterName;
43
public String getFilterName() {
47
public void setFilterName(String filterName) {
48
fFilterName = filterName;
52
public String getNodeName() {
57
public boolean matches(ITmfEvent event) {
58
// There should be at most one child
59
for (ITmfFilterTreeNode node : getChildren()) {
60
if (node.matches(event)) {
68
public List<String> getValidChildren() {
69
if (getChildrenCount() == 0) {
70
return super.getValidChildren();
72
return new ArrayList<String>(0); // only one child allowed
76
public String toString() {
77
StringBuffer buf = new StringBuffer();
78
if (getChildrenCount() > 1) {
79
buf.append("( "); //$NON-NLS-1$
81
for (int i = 0; i < getChildrenCount(); i++) {
82
ITmfFilterTreeNode node = getChildren()[i];
83
buf.append(node.toString());
84
if (i < (getChildrenCount() - 1)) {
85
buf.append(" and "); //$NON-NLS-1$
88
if (getChildrenCount() > 1) {
89
buf.append(" )"); //$NON-NLS-1$
91
return buf.toString();