com.slytechs.jnetstream.file
Class PacketCounter

java.lang.Object
  extended by com.slytechs.jnetstream.file.PacketCounter
Direct Known Subclasses:
DefaultPacketCounter

public abstract class PacketCounter
extends java.lang.Object

File packet counter is used to calculate number of packets contained in a packet file.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Field Summary
static boolean DEFAULT_FORCED_COUNT_STATE
           
 
Constructor Summary
PacketCounter()
           
 
Method Summary
abstract  long getCount()
          Gets the true and accurate count of the number of packets in the file.
abstract  long getCount(long limit)
          Gets the true and accurate count of the number of packets in the file.
abstract  PacketCounterModel getModel()
          Returns the model that is being used by this packet counter.
static PacketCounter newInstance(java.io.File file)
           
static PacketCounter newInstance(java.io.File file, PacketCounterModel model)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FORCED_COUNT_STATE

public static final boolean DEFAULT_FORCED_COUNT_STATE
See Also:
Constant Field Values
Constructor Detail

PacketCounter

public PacketCounter()
Method Detail

getCount

public abstract long getCount()
                       throws java.io.IOException
Gets the true and accurate count of the number of packets in the file. This operation can be very expensive in terms of IO and time since some capture files can be very very large.

Returns:
Accurate packet count.
Throws:
java.lang.IllegalStateException - if the packet count is undeterminate this method may not be called since it may never return.
java.io.IOException

getCount

public abstract long getCount(long limit)
                       throws java.io.IOException
Gets the true and accurate count of the number of packets in the file. This operation can be very expensive in terms of IO and time since some capture files can be very very large.

Parameters:
limit - limit counting packets to maximimum set upto this limit.
Returns:
Accurate packet count.
Throws:
java.lang.IllegalStateException - if the packet count is undeterminate this method may not be called since it may never return.
java.io.IOException

getModel

public abstract PacketCounterModel getModel()
Returns the model that is being used by this packet counter. The model may differ from the model that was initialy requested by the user or from default. The packet counter switches models based on conditions and resource parameters to fulfill the request.

Returns:
Actual model used.

newInstance

public static PacketCounter newInstance(java.io.File file)
                                 throws java.io.FileNotFoundException,
                                        StreamFormatException,
                                        java.io.UnsupportedEncodingException
Throws:
java.io.FileNotFoundException
StreamFormatException
java.io.UnsupportedEncodingException

newInstance

public static PacketCounter newInstance(java.io.File file,
                                        PacketCounterModel model)
                                 throws java.io.FileNotFoundException,
                                        StreamFormatException,
                                        java.io.UnsupportedEncodingException
Throws:
java.io.FileNotFoundException
StreamFormatException
java.io.UnsupportedEncodingException