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
.internal
.tmf
.core
.parsers
.custom
;
12 import java
.util
.ArrayList
;
13 import java
.util
.List
;
15 import org
.eclipse
.jdt
.annotation
.NonNull
;
16 import org
.eclipse
.jdt
.annotation
.Nullable
;
17 import org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
;
18 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
19 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEventField
;
20 import org
.eclipse
.tracecompass
.tmf
.core
.event
.aspect
.ITmfEventAspect
;
21 import org
.eclipse
.tracecompass
.tmf
.core
.parsers
.custom
.Messages
;
24 * An aspect for a custom event's extra fields
26 * @author Geneviève Bastien
28 public class CustomExtraFieldsAspect
implements ITmfEventAspect
<String
> {
33 public CustomExtraFieldsAspect() {
37 public @NonNull String
getName() {
38 return NonNullUtils
.nullToEmptyString(Messages
.CustomExtraFieldsAspect_extraFieldsAspectName
);
42 public @NonNull String
getHelpText() {
43 return NonNullUtils
.nullToEmptyString(Messages
.CustomExtraFieldsAspect_extraFieldsAspectHelp
);
47 public @Nullable String
resolve(@NonNull ITmfEvent event
) {
48 List
<String
> fields
= new ArrayList
<>();
49 for (ITmfEventField field
: event
.getContent().getFields()) {
50 // Add the fields that do not have another aspect associated
51 if (field
instanceof CustomExtraField
) {
52 fields
.add(field
.getName() + '=' + field
.getValue());
55 return String
.join(", ", fields
); //$NON-NLS-1$