1 /*******************************************************************************
2 * Copyright (c) 2016 École Polytechnique de Montréal
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 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.tmf
.core
.event
.aspect
;
12 import java
.util
.List
;
14 import org
.eclipse
.jdt
.annotation
.Nullable
;
15 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
16 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEventField
;
17 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEventType
;
18 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.ITmfTimestamp
;
20 import com
.google
.common
.collect
.ImmutableList
;
23 * Some basic aspects that all trace types should be able to use, using methods
24 * found in {@link ITmfEvent}.
26 * @author Alexandre Montplaisir
27 * @author Geneviève Bastien
30 public final class TmfBaseAspects
{
32 private static final ITmfEventAspect
<ITmfTimestamp
> TIMESTAMP_ASPECT
= new ITmfEventAspect
<ITmfTimestamp
>() {
34 public String
getName() {
35 return Messages
.getMessage(Messages
.AspectName_Timestamp
);
39 public String
getHelpText() {
40 return ITmfEventAspect
.EMPTY_STRING
;
44 public @Nullable ITmfTimestamp
resolve(ITmfEvent event
) {
45 return event
.getTimestamp();
49 private static final ITmfEventAspect
<String
> EVENT_TYPE_ASPECT
= new ITmfEventAspect
<String
>() {
51 public String
getName() {
52 return Messages
.getMessage(Messages
.AspectName_EventType
);
56 public String
getHelpText() {
57 return Messages
.getMessage(Messages
.AspectHelpText_EventType
);
61 public @Nullable String
resolve(ITmfEvent event
) {
62 ITmfEventType type
= event
.getType();
66 return type
.getName();
70 private static final TmfEventFieldAspect CONTENTS_ASPECT
= new TmfEventFieldAspect(Messages
.getMessage(Messages
.AspectName_Contents
), null, new TmfEventFieldAspect
.IRootField() {
72 public @Nullable ITmfEventField
getRootField(ITmfEvent event
) {
73 return event
.getContent();
77 public String
getHelpText() {
78 return Messages
.getMessage(Messages
.AspectHelpText_Contents
);
82 private static final ITmfEventAspect
<String
> TRACE_NAME_ASPECT
= new ITmfEventAspect
<String
>() {
84 public String
getName() {
85 return Messages
.getMessage(Messages
.AspectName_TraceName
);
89 public String
getHelpText() {
90 return Messages
.getMessage(Messages
.AspectHelpText_TraceName
);
94 public @Nullable String
resolve(ITmfEvent event
) {
95 return event
.getTrace().getName();
99 private static final List
<ITmfEventAspect
<?
>> BASE_ASPECTS
= ImmutableList
.of(
100 getTimestampAspect(),
101 getEventTypeAspect(),
103 getTraceNameAspect());
105 private TmfBaseAspects() {
110 * Get the aspect for the event timestamp
112 * @return The timestamp aspect
114 public static ITmfEventAspect
<ITmfTimestamp
> getTimestampAspect() {
115 return TIMESTAMP_ASPECT
;
119 * Get the aspect for the event type
121 * @return The aspect for the event type
123 public static ITmfEventAspect
<String
> getEventTypeAspect() {
124 return EVENT_TYPE_ASPECT
;
128 * Get the aspect for the aggregated event contents (fields)
130 * @return The aspect for the aggregate event contents
132 public static TmfEventFieldAspect
getContentsAspect() {
133 return CONTENTS_ASPECT
;
137 * Get the aspect for the trace's name (for experiments with many traces)
139 * @return The trace name aspect
141 public static ITmfEventAspect
<String
> getTraceNameAspect() {
142 return TRACE_NAME_ASPECT
;
146 * Get the list of all common base aspects
148 * @return the list of base aspects
150 public static List
<ITmfEventAspect
<?
>> getBaseAspects() {