import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.annotation.DefaultLocation;
+import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.internal.pcap.core.packet.BadPacketException;
import org.eclipse.tracecompass.internal.pcap.core.protocol.pcap.PcapPacket;
import org.eclipse.tracecompass.internal.tmf.pcap.core.event.aspect.PcapSourceAspect;
import org.eclipse.tracecompass.internal.tmf.pcap.core.util.PcapEventFactory;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.aspect.TmfBaseAspects;
import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.tracecompass.tmf.core.project.model.ITmfPropertiesProvider;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
-import org.eclipse.tracecompass.tmf.core.trace.ITmfTraceProperties;
import org.eclipse.tracecompass.tmf.core.trace.TmfContext;
import org.eclipse.tracecompass.tmf.core.trace.TmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TraceValidationStatus;
*
* @author Vincent Perot
*/
-public class PcapTrace extends TmfTrace implements ITmfTraceProperties {
+public class PcapTrace extends TmfTrace implements ITmfPropertiesProvider {
/** pcap trace type id as defined in plugin.xml */
public static final String TRACE_TYPE_ID = "org.eclipse.linuxtools.tmf.pcap.core.pcaptrace"; //$NON-NLS-1$
- private static final Collection<ITmfEventAspect> PCAP_ASPECTS =
- checkNotNull(ImmutableList.of(
- ITmfEventAspect.BaseAspects.TIMESTAMP,
+ private static final Collection<ITmfEventAspect<?>> PCAP_ASPECTS =
+ ImmutableList.of(
+ TmfBaseAspects.getTimestampAspect(),
PcapSourceAspect.INSTANCE,
PcapDestinationAspect.INSTANCE,
PcapReferenceAspect.INSTANCE,
PcapProtocolAspect.INSTANCE,
- ITmfEventAspect.BaseAspects.CONTENTS
- ));
+ TmfBaseAspects.getContentsAspect()
+ );
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
private static final int CONFIDENCE = 50;
}
@Override
+ @NonNullByDefault({DefaultLocation.TYPE_ARGUMENT})
public synchronized void initTrace(@Nullable IResource resource, @Nullable String path, @Nullable Class<? extends ITmfEvent> type) throws TmfTraceException {
super.initTrace(resource, path, type);
if (path == null) {
}
@Override
- public Iterable<ITmfEventAspect> getEventAspects() {
+ public Iterable<ITmfEventAspect<?>> getEventAspects() {
return PCAP_ASPECTS;
}
}
@Override
- public synchronized Map<String, String> getTraceProperties() {
+ public synchronized Map<String, String> getProperties() {
PcapFile pcap = fPcapFile;
if (pcap == null) {
return Collections.emptyMap();
}
- Map<String, String> properties = fTraceProperties;
- if (properties == null) {
- ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
- builder.put(nullToEmptyString(Messages.PcapTrace_Version), String.format("%d%c%d", pcap.getMajorVersion(), '.', pcap.getMinorVersion())); //$NON-NLS-1$
- builder.put(nullToEmptyString(Messages.PcapTrace_TimeZoneCorrection), pcap.getTimeZoneCorrection() + " s"); //$NON-NLS-1$
- builder.put(nullToEmptyString(Messages.PcapTrace_TimestampAccuracy), String.valueOf(pcap.getTimeAccuracy()));
- builder.put(nullToEmptyString(Messages.PcapTrace_MaxSnapLength), pcap.getSnapLength() + " bytes"); //$NON-NLS-1$
- builder.put(nullToEmptyString(Messages.PcapTrace_LinkLayerHeaderType), LinkTypeHelper.toString((int) pcap.getDataLinkType()) + " (" + pcap.getDataLinkType() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- builder.put(nullToEmptyString(Messages.PcapTrace_FileEndianness), nullToEmptyString(pcap.getByteOrder().toString()));
+ if (fTraceProperties != null) {
+ return fTraceProperties;
+ }
- return checkNotNull(builder.build());
+ ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
+ builder.put(nullToEmptyString(Messages.PcapTrace_Version), String.format("%d%c%d", pcap.getMajorVersion(), '.', pcap.getMinorVersion())); //$NON-NLS-1$
+ builder.put(nullToEmptyString(Messages.PcapTrace_TimeZoneCorrection), pcap.getTimeZoneCorrection() + " s"); //$NON-NLS-1$
+ builder.put(nullToEmptyString(Messages.PcapTrace_TimestampAccuracy), String.valueOf(pcap.getTimeAccuracy()));
+ builder.put(nullToEmptyString(Messages.PcapTrace_MaxSnapLength), pcap.getSnapLength() + " bytes"); //$NON-NLS-1$
+ builder.put(nullToEmptyString(Messages.PcapTrace_LinkLayerHeaderType), LinkTypeHelper.toString((int) pcap.getDataLinkType()) + " (" + pcap.getDataLinkType() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ builder.put(nullToEmptyString(Messages.PcapTrace_FileEndianness), nullToEmptyString(pcap.getByteOrder().toString()));
- }
+ fTraceProperties = builder.build();
- return properties;
+ return fTraceProperties;
}
}