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 java
.util
.ArrayList
;
17 import java
.util
.List
;
19 import org
.eclipse
.jdt
.annotation
.NonNull
;
20 import org
.eclipse
.tracecompass
.tmf
.core
.event
.aspect
.ITmfEventAspect
;
21 import org
.eclipse
.tracecompass
.tmf
.core
.event
.aspect
.TmfBaseAspects
;
22 import org
.eclipse
.tracecompass
.tmf
.core
.event
.aspect
.TmfContentFieldAspect
;
23 import org
.eclipse
.tracecompass
.tmf
.core
.parsers
.custom
.CustomTraceDefinition
;
24 import org
.eclipse
.tracecompass
.tmf
.core
.parsers
.custom
.CustomTraceDefinition
.OutputColumn
;
25 import org
.eclipse
.tracecompass
.tmf
.core
.parsers
.custom
.CustomTraceDefinition
.Tag
;
27 import com
.google
.common
.collect
.ImmutableList
;
30 * Event aspects for Custom {Text|XML} traces.
32 * Since this definition will be different for every single custom trace, we
33 * cannot define specific {@link ITmfEventAspect} in advance.
35 * Instead, one has to call {@link #generateAspects(CustomTraceDefinition)}
36 * with the CustomTraceDefinition of the the particular trace to display.
38 * @author Alexandre Montplaisir
40 public class CustomEventAspects
{
43 * Build a set of event aspects for a given trace definition
46 * The {@link CustomTraceDefinition} of the trace for which you
48 * @return The set of event aspects for the given trace
50 public static @NonNull Iterable
<ITmfEventAspect
<?
>> generateAspects(CustomTraceDefinition definition
) {
51 List
<String
> fieldNames
= new ArrayList
<>();
52 ImmutableList
.Builder
<ITmfEventAspect
<?
>> builder
= new ImmutableList
.Builder
<>();
53 for (OutputColumn output
: definition
.outputs
) {
55 if (output
.tag
.equals(Tag
.TIMESTAMP
) &&
56 (definition
.timeStampOutputFormat
== null || definition
.timeStampOutputFormat
.isEmpty())) {
57 builder
.add(TmfBaseAspects
.getTimestampAspect());
58 fieldNames
.add(output
.name
);
59 } else if (output
.tag
.equals(Tag
.EVENT_TYPE
)) {
60 builder
.add(TmfBaseAspects
.getEventTypeAspect());
61 fieldNames
.add(output
.name
);
62 } else if (output
.tag
.equals(Tag
.EXTRA_FIELD_NAME
) || output
.tag
.equals(Tag
.EXTRA_FIELD_VALUE
)) {
63 // These tags should have been substituted with Tag.EXTRA_FIELDS
65 } else if (output
.tag
.equals(Tag
.EXTRA_FIELDS
)) {
66 builder
.add(new CustomExtraFieldsAspect());
68 builder
.add(new TmfContentFieldAspect(output
.name
, output
.name
));
69 fieldNames
.add(output
.name
);
72 return builder
.build();