Commit | Line | Data |
---|---|---|
be222f56 | 1 | /******************************************************************************* |
ec34bf48 | 2 | * Copyright (c) 2010, 2015 Ericsson |
be222f56 PT |
3 | * |
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 | |
8 | * | |
9 | * Contributors: | |
10 | * Patrick Tasse - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
2bdf0193 | 13 | package org.eclipse.tracecompass.tmf.core.filter.model; |
be222f56 | 14 | |
e883975e | 15 | import java.util.ArrayList; |
be222f56 PT |
16 | import java.util.Arrays; |
17 | import java.util.List; | |
18 | ||
2bdf0193 | 19 | import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; |
be222f56 PT |
20 | |
21 | /** | |
22 | * The Filter tree root node | |
23 | * | |
24 | * @version 1.0 | |
25 | * @author Patrick Tasse | |
26 | */ | |
27 | public class TmfFilterRootNode extends TmfFilterTreeNode { | |
28 | ||
ec34bf48 | 29 | /** root node name */ |
be222f56 PT |
30 | public static final String NODE_NAME = "ROOT"; //$NON-NLS-1$ |
31 | ||
d5efe032 AF |
32 | private static final String[] VALID_CHILDREN = { |
33 | TmfFilterNode.NODE_NAME | |
34 | }; | |
35 | ||
36 | /** | |
37 | * Default constructor | |
38 | */ | |
39 | public TmfFilterRootNode() { | |
40 | super(null); | |
41 | } | |
42 | ||
43 | @Override | |
44 | public String getNodeName() { | |
45 | return NODE_NAME; | |
46 | } | |
47 | ||
48 | @Override | |
49 | public boolean matches(ITmfEvent event) { | |
50 | for (ITmfFilterTreeNode node : getChildren()) { | |
51 | if (! node.matches(event)) { | |
52 | return false; | |
53 | } | |
54 | } | |
55 | return true; | |
56 | } | |
57 | ||
58 | @Override | |
59 | public List<String> getValidChildren() { | |
60 | return Arrays.asList(VALID_CHILDREN); | |
61 | } | |
be222f56 | 62 | |
ec4e56da | 63 | @Override |
e883975e | 64 | public String toString(boolean explicit) { |
ec4e56da PT |
65 | StringBuffer buf = new StringBuffer("root"); //$NON-NLS-1$ |
66 | if (getChildrenCount() > 0) { | |
67 | buf.append(' '); | |
e883975e PT |
68 | List<String> strings = new ArrayList<>(); |
69 | for (ITmfFilterTreeNode child : getChildren()) { | |
70 | strings.add(child.toString(explicit)); | |
71 | } | |
72 | buf.append(strings.toString()); | |
ec4e56da PT |
73 | } |
74 | return buf.toString(); | |
75 | } | |
be222f56 | 76 | } |