pcap.core: making some classes final
[deliverable/tracecompass.git] / pcap / org.eclipse.tracecompass.tmf.pcap.core / src / org / eclipse / tracecompass / internal / tmf / pcap / core / event / aspect / PcapSourceAspect.java
CommitLineData
b04903a2 1/*******************************************************************************
ed902a2b 2 * Copyright (c) 2014, 2015 Ericsson
b04903a2
AM
3 *
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 *
9 * Contributors:
10 * Vincent Perot - Initial API and implementation
11 * Alexandre Montplaisir - Update to new ITmfEventAspect API
0214cc07 12 * Patrick Tasse - Make pcap aspects singletons
b04903a2
AM
13 *******************************************************************************/
14
15package org.eclipse.tracecompass.internal.tmf.pcap.core.event.aspect;
16
2a28075c 17import org.eclipse.jdt.annotation.Nullable;
b04903a2
AM
18import org.eclipse.tracecompass.internal.tmf.pcap.core.event.PcapEvent;
19import org.eclipse.tracecompass.internal.tmf.pcap.core.protocol.TmfPcapProtocol;
20import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
21import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
22
23/**
24 * The packet source aspect for pcap events.
25 *
26 * This normally represents the source address of the packet, and the format
27 * depends on the protocol (e.g. source IP address, source port, etc.)
28 *
29 * @author Alexandre Montplaisir
30 */
1ad849b8 31public final class PcapSourceAspect implements ITmfEventAspect<String> {
b04903a2 32
0214cc07
PT
33 /** Singleton instance */
34 public static final PcapSourceAspect INSTANCE = new PcapSourceAspect();
35
36 private PcapSourceAspect() {
37 }
38
b04903a2
AM
39 @Override
40 public String getName() {
41 return Messages.getMessage(Messages.PcapAspectName_Source);
42 }
43
44 @Override
45 public String getHelpText() {
46 return EMPTY_STRING;
47 }
48
49 @Override
2a28075c 50 public @Nullable String resolve(ITmfEvent event) {
b04903a2 51 if (!(event instanceof PcapEvent)) {
2a28075c 52 return null;
b04903a2
AM
53 }
54 PcapEvent pcapEvent = (PcapEvent) event;
55 TmfPcapProtocol protocol = pcapEvent.getMostEncapsulatedProtocol();
56
2a28075c 57 return pcapEvent.getSourceEndpoint(protocol);
b04903a2 58 }
c409f16b 59}
This page took 0.05426 seconds and 5 git commands to generate.