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
.pcap
.core
.packet
;
15 import org
.eclipse
.jdt
.annotation
.Nullable
;
16 import org
.eclipse
.linuxtools
.pcap
.core
.packet
.Packet
;
17 import org
.eclipse
.linuxtools
.pcap
.core
.protocol
.Protocol
;
18 import org
.eclipse
.linuxtools
.pcap
.core
.protocol
.pcap
.PcapPacket
;
21 * Class that represents a Packet ID. Using the information contained in this
22 * class, it is possible to retrieve a packet. This allows to tremendously
23 * reduce memory usage of packet streams while keeping good performance.
25 * @author Vincent Perot
27 public class PacketUniqueID
{
29 private final String fPath
;
30 private final long fIndex
;
33 * Constructor. It builds the packet ID from a packet.
36 * The packet to build the ID from.
38 public PacketUniqueID(Packet packet
) {
39 fPath
= packet
.getPcapFile().getPath();
40 PcapPacket pcapPacket
= (PcapPacket
) packet
.getPacket(Protocol
.PCAP
);
41 fIndex
= (pcapPacket
== null ?
-1 : pcapPacket
.getIndex());
45 * Getter method that returns the file path of the packet.
47 * @return The file path.
49 public String
getPath() {
54 * Getter method that returns the index within the file of the packet.
56 * @return The packet index.
58 public long getIndex() {
63 public int hashCode() {
66 result
= prime
* result
+ (int) (fIndex ^
(fIndex
>>> 32));
67 result
= prime
* result
+ fPath
.hashCode();
72 public boolean equals(@Nullable Object obj
) {
79 if (getClass() != obj
.getClass()) {
83 PacketUniqueID other
= (PacketUniqueID
) obj
;
84 if (fIndex
!= other
.fIndex
) {
87 if (fPath
!= other
.fPath
) {
This page took 0.033623 seconds and 5 git commands to generate.