1 /*******************************************************************************
2 * Copyright (c) 2014 Ericsson
4 * All rights reserved. This program and the accompanying materials are made
5 * 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 * Alexandre Montplaisir - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.core
.event
.aspect
;
15 import org
.eclipse
.jdt
.annotation
.Nullable
;
16 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
17 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEventField
;
20 * Event aspect representing a single field of an event.
22 * @author Alexandre Montplaisir
24 public class TmfEventFieldAspect
implements ITmfEventAspect
{
26 private final String fAspectName
;
27 private final String fFieldName
;
33 * The name of the aspect. Should be localized.
35 * The name of the field to look for in the trace. Should *not*
38 public TmfEventFieldAspect(String aspectName
, String fieldName
) {
39 fAspectName
= aspectName
;
40 fFieldName
= fieldName
;
44 public String
getName() {
49 public String
getHelpText() {
54 public @Nullable String
resolve(ITmfEvent event
) {
55 ITmfEventField field
= event
.getContent().getField(fFieldName
);
59 return field
.getFormattedValue();
62 // ------------------------------------------------------------------------
64 // Typically we want identical field aspects to be merged together.
65 // ------------------------------------------------------------------------
68 public int hashCode() {
71 result
= prime
* result
+ fAspectName
.hashCode();
72 result
= prime
* result
+ fFieldName
.hashCode();
77 public boolean equals(@Nullable Object obj
) {
81 if (!(obj
instanceof TmfEventFieldAspect
)) {
84 TmfEventFieldAspect other
= (TmfEventFieldAspect
) obj
;
85 if (!fAspectName
.equals(other
.fAspectName
)) {
88 if (!fFieldName
.equals(other
.fFieldName
)) {