1 /*******************************************************************************
2 * Copyright (c) 2014, 2015 Ericsson
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
10 * Vincent Perot - Initial API and implementation
11 * Patrick Tasse - Remove getSubField
12 *******************************************************************************/
14 package org
.eclipse
.tracecompass
.internal
.tmf
.pcap
.core
.event
;
16 import org
.eclipse
.jdt
.annotation
.Nullable
;
17 import org
.eclipse
.tracecompass
.internal
.pcap
.core
.packet
.Packet
;
18 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEventField
;
19 import org
.eclipse
.tracecompass
.tmf
.core
.event
.TmfEventField
;
22 * Class that represents the root node of Pcap Event Field.
24 * @author Vincent Perot
26 public class PcapRootEventField
extends TmfEventField
{
28 private final TmfEventField fPacketSourceField
;
29 private final TmfEventField fPacketDestinationField
;
30 private final TmfEventField fProtocolField
;
31 private final String fSummaryString
;
37 * The list of subfields.
39 * The packet from which to take the fields from.
40 * @throws IllegalArgumentException
41 * If 'name' is null, or if 'fields' has duplicate field names.
43 public PcapRootEventField(ITmfEventField
[] fields
, Packet packet
) {
44 super(ITmfEventField
.ROOT_FIELD_ID
, null, fields
);
45 fPacketSourceField
= new TmfEventField(PcapEvent
.EVENT_FIELD_PACKET_SOURCE
,
46 packet
.getMostEcapsulatedPacket().getSourceEndpoint().toString(), null);
47 fPacketDestinationField
= new TmfEventField(PcapEvent
.EVENT_FIELD_PACKET_DESTINATION
,
48 packet
.getMostEcapsulatedPacket().getDestinationEndpoint().toString(), null);
49 fProtocolField
= new TmfEventField(PcapEvent
.EVENT_FIELD_PACKET_PROTOCOL
,
50 packet
.getMostEcapsulatedPacket().getProtocol().getShortName().toUpperCase(), null);
51 fSummaryString
= packet
.getGlobalSummaryString();
58 * the other event field
60 public PcapRootEventField(final PcapRootEventField field
) {
62 fPacketSourceField
= field
.fPacketSourceField
;
63 fPacketDestinationField
= field
.fPacketDestinationField
;
64 fProtocolField
= field
.fProtocolField
;
65 fSummaryString
= field
.fSummaryString
;
69 public String
toString() {
70 return fSummaryString
;
74 public @Nullable ITmfEventField
getField(String
... path
) {
75 if (path
.length
!= 1) {
76 return super.getField(path
);
79 case PcapEvent
.EVENT_FIELD_PACKET_SOURCE
:
80 return fPacketSourceField
;
81 case PcapEvent
.EVENT_FIELD_PACKET_DESTINATION
:
82 return fPacketDestinationField
;
83 case PcapEvent
.EVENT_FIELD_PACKET_PROTOCOL
:
84 return fProtocolField
;
86 return super.getField(path
);