net.sourceforge.jpcap.client
Class CaptureHistory

java.lang.Object
  extended bynet.sourceforge.jpcap.client.CaptureHistory

public class CaptureHistory
extends java.lang.Object

Captured packet history.

If a size is specified, the history acts as a FIFO.


Constructor Summary
CaptureHistory()
          Create a new unbounded capture history buffer.
CaptureHistory(int maxSize)
          Create a new bounded capture history buffer.
 
Method Summary
 boolean add(Packet packet)
          Add the most recent packet to the history collection.
 void clear()
          Clear all the packets in the history collection.
 int dump(boolean colored)
          Dump the history buffer contents to stdout.
 Packet get(int index)
          Fetch a packet from a specific location in the history.
 java.util.Collection getCollection()
          Fetch the full history as a packet collection.
 int getMaxSize()
           
 void setMaxSize(int maxSize)
          Set the size of the history.
 int size()
          Fetch the number of packets in the history collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CaptureHistory

public CaptureHistory(int maxSize)
Create a new bounded capture history buffer. The history will not grow beyond the number of packets specified.

Parameters:
maxSize - the maximum number of packets to remember. Oldest packets are discarded first.

CaptureHistory

public CaptureHistory()
Create a new unbounded capture history buffer. The history buffer will grow indefinitely (read until the memory of the host is exhausted.) Oldest packets are discarded first.

Method Detail

setMaxSize

public void setMaxSize(int maxSize)
Set the size of the history. If the history buffer is already larger than the specified size, old packets will be discarded until it shrinks to the specified size.


getMaxSize

public int getMaxSize()

add

public boolean add(Packet packet)
Add the most recent packet to the history collection.


get

public Packet get(int index)
Fetch a packet from a specific location in the history.


getCollection

public java.util.Collection getCollection()
Fetch the full history as a packet collection.


clear

public void clear()
Clear all the packets in the history collection.


size

public int size()
Fetch the number of packets in the history collection.


dump

public int dump(boolean colored)
Dump the history buffer contents to stdout.