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 String
resolve(ITmfEvent event
) {
55 ITmfEventField field
= event
.getContent().getField(fFieldName
);
59 String fieldValue
= field
.getFormattedValue();
60 return (fieldValue
== null ? EMPTY_STRING
: fieldValue
);
63 // ------------------------------------------------------------------------
65 // Typically we want identical field aspects to be merged together.
66 // ------------------------------------------------------------------------
69 public int hashCode() {
72 result
= prime
* result
+ fAspectName
.hashCode();
73 result
= prime
* result
+ fFieldName
.hashCode();
78 public boolean equals(@Nullable Object obj
) {
82 if (!(obj
instanceof TmfEventFieldAspect
)) {
85 TmfEventFieldAspect other
= (TmfEventFieldAspect
) obj
;
86 if (!fAspectName
.equals(other
.fAspectName
)) {
89 if (!fFieldName
.equals(other
.fFieldName
)) {