1 /*******************************************************************************
2 * Copyright (c) 2014 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 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.pcap
.core
.event
;
15 import org
.eclipse
.jdt
.annotation
.Nullable
;
16 import org
.eclipse
.linuxtools
.pcap
.core
.packet
.Packet
;
17 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEventField
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfEventField
;
21 * Class that represents the root node of Pcap Event Field.
23 * @author Vincent Perot
25 public class PcapRootEventField
extends TmfEventField
{
27 private final TmfEventField fPacketSourceField
;
28 private final TmfEventField fPacketDestinationField
;
29 private final TmfEventField fProtocolField
;
30 private final String fSummaryString
;
36 * The event field value.
38 * The list of subfields.
40 * The packet from which to take the fields from.
41 * @throws IllegalArgumentException
42 * If 'name' is null, or if 'fields' has duplicate field names.
44 public PcapRootEventField(Object value
, @Nullable ITmfEventField
[] fields
, Packet packet
) {
45 super(ITmfEventField
.ROOT_FIELD_ID
, value
, fields
);
46 fPacketSourceField
= new TmfEventField(PcapEvent
.EVENT_FIELD_PACKET_SOURCE
,
47 packet
.getMostEcapsulatedPacket().getSourceEndpoint().toString(), null);
48 fPacketDestinationField
= new TmfEventField(PcapEvent
.EVENT_FIELD_PACKET_DESTINATION
,
49 packet
.getMostEcapsulatedPacket().getDestinationEndpoint().toString(), null);
50 fProtocolField
= new TmfEventField(PcapEvent
.EVENT_FIELD_PACKET_PROTOCOL
,
51 packet
.getMostEcapsulatedPacket().getProtocol().getShortName().toUpperCase(), null);
52 fSummaryString
= packet
.getGlobalSummaryString();
59 * the other event field
61 public PcapRootEventField(final PcapRootEventField field
) {
63 fPacketSourceField
= field
.fPacketSourceField
;
64 fPacketDestinationField
= field
.fPacketDestinationField
;
65 fProtocolField
= field
.fProtocolField
;
66 fSummaryString
= field
.fSummaryString
;
70 public String
toString() {
71 return fSummaryString
;
75 public @Nullable ITmfEventField
getField(@Nullable String name
) {
80 case PcapEvent
.EVENT_FIELD_PACKET_SOURCE
:
81 return fPacketSourceField
;
82 case PcapEvent
.EVENT_FIELD_PACKET_DESTINATION
:
83 return fPacketDestinationField
;
84 case PcapEvent
.EVENT_FIELD_PACKET_PROTOCOL
:
85 return fProtocolField
;
87 return super.getField(name
);