1 /*******************************************************************************
2 * Copyright (c) 2010, 2016 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 * Alexandre Montplaisir - Update for TmfEventTableColumn
12 *******************************************************************************/
14 package org
.eclipse
.tracecompass
.internal
.tmf
.core
.parsers
.custom
;
16 import org
.eclipse
.jdt
.annotation
.NonNull
;
17 import org
.eclipse
.tracecompass
.tmf
.core
.event
.aspect
.ITmfEventAspect
;
18 import org
.eclipse
.tracecompass
.tmf
.core
.event
.aspect
.TmfBaseAspects
;
19 import org
.eclipse
.tracecompass
.tmf
.core
.event
.aspect
.TmfContentFieldAspect
;
20 import org
.eclipse
.tracecompass
.tmf
.core
.parsers
.custom
.CustomTraceDefinition
;
21 import org
.eclipse
.tracecompass
.tmf
.core
.parsers
.custom
.CustomTraceDefinition
.OutputColumn
;
22 import org
.eclipse
.tracecompass
.tmf
.core
.parsers
.custom
.CustomTraceDefinition
.Tag
;
24 import com
.google
.common
.collect
.ImmutableList
;
27 * Event aspects for Custom {Text|XML} traces.
29 * Since this definition will be different for every single custom trace, we
30 * cannot define specific {@link ITmfEventAspect} in advance.
32 * Instead, one has to call {@link #generateAspects(CustomTraceDefinition)}
33 * with the CustomTraceDefinition of the the particular trace to display.
35 * @author Alexandre Montplaisir
37 public class CustomEventAspects
{
40 * Build a set of event aspects for a given trace definition
43 * The {@link CustomTraceDefinition} of the trace for which you
45 * @return The set of event aspects for the given trace
47 public static @NonNull Iterable
<ITmfEventAspect
<?
>> generateAspects(CustomTraceDefinition definition
) {
48 ImmutableList
.Builder
<ITmfEventAspect
<?
>> builder
= new ImmutableList
.Builder
<>();
49 for (OutputColumn output
: definition
.outputs
) {
50 if (output
.tag
.equals(Tag
.TIMESTAMP
) &&
51 (definition
.timeStampOutputFormat
== null || definition
.timeStampOutputFormat
.isEmpty())) {
52 builder
.add(TmfBaseAspects
.getTimestampAspect());
53 } else if (output
.tag
.equals(Tag
.EVENT_TYPE
)) {
54 builder
.add(TmfBaseAspects
.getEventTypeAspect());
56 builder
.add(new TmfContentFieldAspect(output
.name
, output
.name
));
59 return builder
.build();