/*******************************************************************************
- * Copyright (c) 2014 Ericsson
+ * Copyright (c) 2014, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0 which
*
* Contributors:
* Alexandre Montplaisir - Initial API and implementation
+ * Patrick Tasse - Added base aspect list
*******************************************************************************/
package org.eclipse.tracecompass.tmf.core.event.aspect;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
+import java.util.List;
+
+import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
import org.eclipse.tracecompass.tmf.core.event.ITmfEventType;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
+
+import com.google.common.collect.ImmutableList;
/**
* An aspect is a piece of information that can be extracted, directly or
*/
String EMPTY_STRING = ""; //$NON-NLS-1$
+ /**
+ * List of all common base aspects
+ */
+ public static final List<ITmfEventAspect> BASE_ASPECTS =
+ checkNotNull(ImmutableList.of(
+ BaseAspects.TIMESTAMP,
+ BaseAspects.EVENT_TYPE,
+ BaseAspects.CONTENTS,
+ BaseAspects.TRACE_NAME
+ ));
/**
* Some basic aspects that all trace types should be able to use, using
* methods found in {@link ITmfEvent}.
}
@Override
- public String resolve(ITmfEvent event) {
- String ret = event.getTimestamp().toString();
- return (ret == null ? EMPTY_STRING : ret);
+ public @Nullable ITmfTimestamp resolve(ITmfEvent event) {
+ return event.getTimestamp();
}
};
}
@Override
- public String resolve(ITmfEvent event) {
+ public @Nullable String resolve(ITmfEvent event) {
ITmfEventType type = event.getType();
if (type == null) {
- return EMPTY_STRING;
+ return null;
}
- String typeName = type.getName();
- return (typeName == null ? EMPTY_STRING : typeName);
+ return type.getName();
}
};
/**
* Aspect for the aggregated event contents (fields)
*/
- ITmfEventAspect CONTENTS = new ITmfEventAspect() {
+ TmfEventFieldAspect CONTENTS = new TmfEventFieldAspect(Messages.getMessage(Messages.AspectName_Contents), null, new TmfEventFieldAspect.IRootField() {
@Override
- public String getName() {
- return Messages.getMessage(Messages.AspectName_Contents);
+ public @Nullable ITmfEventField getRootField(ITmfEvent event) {
+ return event.getContent();
}
-
+ }) {
@Override
public String getHelpText() {
return Messages.getMessage(Messages.AspectHelpText_Contents);
}
- @Override
- public String resolve(ITmfEvent event) {
- String ret = event.getContent().toString();
- return (ret == null ? EMPTY_STRING : ret);
- }
};
/**
}
@Override
- public String resolve(ITmfEvent event) {
- String ret = event.getTrace().getName();
- return (ret == null ? EMPTY_STRING : ret);
+ public @Nullable String resolve(ITmfEvent event) {
+ return event.getTrace().getName();
}
};
}
* The event to process
* @return The resulting tidbit of information for this event.
*/
- Object resolve(ITmfEvent event);
+ @Nullable Object resolve(ITmfEvent event);
}