1 /*******************************************************************************
2 * Copyright (c) 2010, 2015 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
.tracecompass
.tmf
.core
.filter
.model
;
15 import java
.util
.ArrayList
;
16 import java
.util
.List
;
18 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
19 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
22 * Filter node for an trace type
25 * @author Patrick Tasse
27 public class TmfFilterTraceTypeNode
extends TmfFilterTreeNode
{
29 /** tracetype node name */
30 public static final String NODE_NAME
= "TRACETYPE"; //$NON-NLS-1$
31 /** type attribute name */
32 public static final String TYPE_ATTR
= "type"; //$NON-NLS-1$
33 /** name attribute name */
34 public static final String NAME_ATTR
= "name"; //$NON-NLS-1$
36 private String fTraceTypeId
;
37 private Class
<?
extends ITmfTrace
> fTraceClass
;
41 * @param parent the parent node
43 public TmfFilterTraceTypeNode(ITmfFilterTreeNode parent
) {
48 public String
getNodeName() {
53 * @return the trace type id
55 public String
getTraceTypeId() {
60 * @param traceTypeId the trace type id
62 public void setTraceTypeId(String traceTypeId
) {
63 this.fTraceTypeId
= traceTypeId
;
67 * @return the trace class
69 public Class
<?
extends ITmfTrace
> getTraceClass() {
74 * @param traceClass the trace class
76 public void setTraceClass(Class
<?
extends ITmfTrace
> traceClass
) {
77 this.fTraceClass
= traceClass
;
81 * @return the category and trace type name
83 public String
getName() {
88 * @param name the category and trace type name
90 public void setName(String name
) {
95 public boolean matches(ITmfEvent event
) {
96 boolean match
= false;
97 ITmfTrace trace
= event
.getTrace();
98 if (trace
.getClass().equals(fTraceClass
)) {
99 if (fTraceTypeId
!= null) {
100 if (fTraceTypeId
.equals(trace
.getTraceTypeId())) {
108 // There should be at most one child
109 for (ITmfFilterTreeNode node
: getChildren()) {
110 if (! node
.matches(event
)) {
120 public List
<String
> getValidChildren() {
121 if (getChildrenCount() == 0) {
122 return super.getValidChildren();
124 return new ArrayList
<>(0); // only one child allowed
128 public String
toString(boolean explicit
) {
129 StringBuffer buf
= new StringBuffer();
130 buf
.append("TraceType is " + fName
); //$NON-NLS-1$
133 buf
.append(fTraceTypeId
);
136 if (getChildrenCount() > 0) {
137 buf
.append(" and "); //$NON-NLS-1$
139 if (getChildrenCount() > 1) {
140 buf
.append("( "); //$NON-NLS-1$
142 for (int i
= 0; i
< getChildrenCount(); i
++) {
143 ITmfFilterTreeNode node
= getChildren()[i
];
144 buf
.append(node
.toString(explicit
));
145 if (i
< getChildrenCount() - 1) {
146 buf
.append(" and "); //$NON-NLS-1$
149 if (getChildrenCount() > 1) {
150 buf
.append(" )"); //$NON-NLS-1$
152 return buf
.toString();