org.jnetstream.capture
Interface InputCapture<T extends CapturePacket>

All Superinterfaces:
Capture<T>, java.io.Closeable, java.lang.Iterable<T>
All Known Subinterfaces:
NapInput, PcapInput, SnoopInput

public interface InputCapture<T extends CapturePacket>
extends Capture<T>

Formatted InputStream based capture session. This object itself is not an InputStream and can not be call chained with other InputStream objects. The inputstream has to be formatted and conform to one of the supported file format standards. The stream only allows read-only iterators to accessed which will decoded the formatted stream and produce either FilePacket, Record or raw ByteBuffers read from the stream.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Nested Class Summary
static interface InputCapture.FormatTypeOtherFactory
          Factory interface used by InputCapture factories to load NPL based files who's format is FormatType.Other.
 
Field Summary
static java.lang.String DEFAULT_INPUTCAPTURE_OTHER_FACTORY
           
static java.lang.String PROPERTY_INPUTCAPTURE_OTHER_FACTORY
          Name of the system property used used in loading FormatType.Other file formats.
 
Method Summary
 void close()
          Closes the capture session and the underlying inputstream.
 long countPackets()
          Counts the number of packets in the input.
 java.lang.String getFormatName()
          Gets the name of this format.
 InputIterator<T> getPacketIterator()
          Gets an iterator that will iterate and return CapturePacket objects.
 InputIterator<T> getPacketIterator(Filter<ProtocolFilterTarget> filter)
          Gets an iterator that will iterate and return CapturePacket objects.
 InputIterator<java.nio.ByteBuffer> getRawIterator()
          Gets an iterator that will iterate and return raw ByteBuffer based record read from the inputstream.
 InputIterator<java.nio.ByteBuffer> getRawIterator(Filter<RecordFilterTarget> filter)
          Gets an iterator that will iterate and return raw ByteBuffer based record read from the inputstream.
 InputIterator<? extends Record> getRecordIterator()
          Gets an iterator that will iterate and return Record objects, just like a normal file based capture would produce except these records are read-only.
 InputIterator<? extends Record> getRecordIterator(Filter<RecordFilterTarget> filter)
          Gets an iterator that will iterate and return Record objects, just like a normal file based capture would produce except these records are read-only.
 
Methods inherited from interface org.jnetstream.capture.Capture
getFilter, getType, isMutable, iterator
 

Field Detail

PROPERTY_INPUTCAPTURE_OTHER_FACTORY

static final java.lang.String PROPERTY_INPUTCAPTURE_OTHER_FACTORY
Name of the system property used used in loading FormatType.Other file formats. You can use the system property PROPERTY_INPUTCAPTURE_OTHER_FACTORY to override its default value which is "org.jnetstream.capture.inputcapture.other".

See Also:
Constant Field Values

DEFAULT_INPUTCAPTURE_OTHER_FACTORY

static final java.lang.String DEFAULT_INPUTCAPTURE_OTHER_FACTORY
See Also:
Constant Field Values
Method Detail

countPackets

long countPackets()
                  throws java.io.IOException
Counts the number of packets in the input. All the input is consumed and can not be rewound.

Returns:
number of packets within the input
Throws:
java.io.IOException - any IO errors

getPacketIterator

InputIterator<T> getPacketIterator()
                                                         throws java.io.IOException
Gets an iterator that will iterate and return CapturePacket objects.

Specified by:
getPacketIterator in interface Capture<T extends CapturePacket>
Returns:
Iterator capable of throwing IO exceptions
Throws:
java.io.IOException - any IO errors

getPacketIterator

InputIterator<T> getPacketIterator(Filter<ProtocolFilterTarget> filter)
                                                         throws java.io.IOException
Gets an iterator that will iterate and return CapturePacket objects.

Parameters:
filter - a packet filter to apply to the interator
Throws:
java.io.IOException - any IO errors

getRecordIterator

InputIterator<? extends Record> getRecordIterator()
                                                  throws java.io.IOException
Gets an iterator that will iterate and return Record objects, just like a normal file based capture would produce except these records are read-only.

Returns:
iterator of record
Throws:
java.io.IOException - any IO errors

getRecordIterator

InputIterator<? extends Record> getRecordIterator(Filter<RecordFilterTarget> filter)
                                                  throws java.io.IOException
Gets an iterator that will iterate and return Record objects, just like a normal file based capture would produce except these records are read-only.

Parameters:
filter - filter to apply to the iterator
Returns:
iterator of record
Throws:
java.io.IOException - any IO errors

getRawIterator

InputIterator<java.nio.ByteBuffer> getRawIterator()
                                                  throws java.io.IOException
Gets an iterator that will iterate and return raw ByteBuffer based record read from the inputstream. These ByteBuffer will contents of each record. The buffer itself is readonly and can not be modified.

Returns:
iterator of raw record contents in ByteBuffers
Throws:
java.io.IOException - any IO errors

getRawIterator

InputIterator<java.nio.ByteBuffer> getRawIterator(Filter<RecordFilterTarget> filter)
                                                  throws java.io.IOException
Gets an iterator that will iterate and return raw ByteBuffer based record read from the inputstream. These ByteBuffer will contents of each record. The buffer itself is readonly and can not be modified.

Parameters:
filter - filter to apply to the iterator
Returns:
iterator of raw record contents in ByteBuffers
Throws:
java.io.IOException - any IO errors

close

void close()
           throws java.io.IOException
Closes the capture session and the underlying inputstream.

Specified by:
close in interface java.io.Closeable
Throws:
java.io.IOException

getFormatName

java.lang.String getFormatName()
Gets the name of this format. This method is especially useful for file formats of type FormatType.Other as it will give a more detailed name of the file format.

Returns:
possibly more detailed file format name