org.jnetstream.capture
Interface Captures.Factory

All Superinterfaces:
Captures.LiveCaptureFactory
All Known Subinterfaces:
Captures.LocalFactory, Captures.RemoteFactory, RemoteSession
Enclosing class:
Captures

public static interface Captures.Factory
extends Captures.LiveCaptureFactory

A factory interface for interfacing with implementation of jNetStream API. Factory interfaces are made up of 3 parts. A common part and 1 remote and 1 local part. The common part is this interface, while LocalFactory provides additional methods which are only available on a local system and are not available as part of the RemoteFactory interface. RemoteFactory interface provides additional methods which may be used remotely, while it will not contain methods that should only be called locally.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Field Summary
 
Fields inherited from interface org.jnetstream.capture.Captures.LiveCaptureFactory
LIVE_CAPTURE_FACTORY_CLASS_PROPERTY
 
Method Summary
 long append(FileCapture<? extends FilePacket> dst, Capture... srcs)
          Copies all of the CapturePackets returned by the source into the already open capture file.
 long catFile(FormatType type, java.io.File dst, Capture... srcs)
          Concatenate all the files into the
 long catFile(FormatType type, java.io.File dst, java.io.File... srcs)
          Concatenate all the files into the
 long countPackets(java.io.File dst)
           
 FormatType formatType(java.io.File file)
          Determines the format type of the supplied file.
 FormatType formatType(java.nio.channels.ReadableByteChannel in)
          Determines the format type of the supplied "input".
<T extends FileCapture<? extends FilePacket>>
T
newFile(java.lang.Class<T> c, java.io.File file)
          Creates a new empty file of the user specified type.
<T extends FileCapture<? extends FilePacket>>
T
newFile(java.lang.Class<T> t, java.io.File f, Capture<? extends CapturePacket> capture)
          Creates a new file and dumps all of the packet from capture to the new file in the proper format.
 FileCapture<? extends FilePacket> newFile(FormatType type, java.io.File file)
           
<T extends FileCapture<? extends FilePacket>>
T
newFile(FormatType type, java.io.File file, Capture<? extends CapturePacket> capture)
          Creates a new file and dumps all of the packet from capture to the new file in the proper format.
<T extends FileCapture<? extends FilePacket>>
T
openFile(java.lang.Class<T> t, java.io.File file)
           
<T extends FileCapture<? extends FilePacket>>
T
openFile(java.lang.Class<T> type, java.io.File file, FileMode mode, Filter<ProtocolFilterTarget> filter)
           
 FileCapture<? extends FilePacket> openFile(java.io.File file)
           
 FileCapture<? extends FilePacket> openFile(java.io.File file, FileMode mode, Filter<ProtocolFilterTarget> protocolFilter)
          Gets a mutable FileCapture instance for the specified file.
 void registerListener(CaptureListener listener)
           
 void removeRegisteredListener(CaptureListener listener)
           
 java.util.List<java.io.File> splitFile(java.io.File file)
           Splits the file into smaller files according to default rules defined for each file format.
 java.util.List<java.io.File> splitFile(java.io.File file, long packetCount, boolean maxCompression)
           Split the specified file into smaller files containing specified number of packets each from the source file.
 boolean validateFile(java.io.File file)
          Checks if the specified file is in a proper format 100% compabile with specification.
 
Methods inherited from interface org.jnetstream.capture.Captures.LiveCaptureFactory
listCaptureDevices, newCaptureDevice, openLive, openLive, openLive, openLive, openLive, openLive, openLive, openTransmitter, openTransmitter
 

Method Detail

append

long append(FileCapture<? extends FilePacket> dst,
            Capture... srcs)
            throws java.io.IOException
Copies all of the CapturePackets returned by the source into the already open capture file.

Parameters:
dst - capture file to write the packets into
srcs - capture source to read packets from
Returns:
TODO
Throws:
java.io.IOException - any IO errors

catFile

long catFile(FormatType type,
             java.io.File dst,
             Capture... srcs)
             throws java.io.IOException
Concatenate all the files into the

Parameters:
type - TODO
dst - file to store all the concatenated data
srcs - array of source files to concatenate together
Throws:
java.io.IOException

catFile

long catFile(FormatType type,
             java.io.File dst,
             java.io.File... srcs)
             throws java.io.FileNotFoundException,
                    java.io.IOException
Concatenate all the files into the

Parameters:
type - TODO
dst - file to store all the concatenated data
srcs - array of source files to concatenate together
Returns:
TODO
Throws:
java.io.IOException
java.io.FileNotFoundException

countPackets

long countPackets(java.io.File dst)
                  throws java.io.IOException,
                         FileFormatException
Parameters:
dst -
Returns:
Throws:
java.io.IOException
FileFormatException

formatType

FormatType formatType(java.io.File file)
                      throws java.io.IOException
Determines the format type of the supplied file. Checks the format of the supplied file and expects it to be in one of the supported format types such as Pcap, etc..

Parameters:
file - file to check and return format type
Returns:
format type of the supplied input or null if format type is unknown or not supported
Throws:
java.io.IOException

formatType

FormatType formatType(java.nio.channels.ReadableByteChannel in)
                      throws java.io.IOException
Determines the format type of the supplied "input". Checks the format of the supplied input and expects it to be in one of the supported format types such as Pcap, etc..

Parameters:
in - input to check and return format type
Returns:
format type of the supplied input or null if format type is unknown or not supported
Throws:
java.io.IOException

newFile

<T extends FileCapture<? extends FilePacket>> T newFile(java.lang.Class<T> c,
                                                        java.io.File file)
                                                    throws java.io.IOException,
                                                           FileFormatException
Creates a new empty file of the user specified type.

Parameters:
file - file to create
type - type of file to create
Returns:
mutable instance of the empty file just created
Throws:
java.io.IOException - any IO errors
FileFormatException

newFile

<T extends FileCapture<? extends FilePacket>> T newFile(java.lang.Class<T> t,
                                                        java.io.File f,
                                                        Capture<? extends CapturePacket> capture)
                                                    throws java.io.IOException
Creates a new file and dumps all of the packet from capture to the new file in the proper format.

Parameters:
f - file to create
capture - source of CapturePackets which will be dumped into the new file
type - the type of file to create
Returns:
open instance of this new file
Throws:
java.io.IOException - any IO errors

newFile

FileCapture<? extends FilePacket> newFile(FormatType type,
                                          java.io.File file)
                                          throws java.io.IOException
Parameters:
type -
file -
Returns:
Throws:
java.io.IOException

newFile

<T extends FileCapture<? extends FilePacket>> T newFile(FormatType type,
                                                        java.io.File file,
                                                        Capture<? extends CapturePacket> capture)
                                                    throws java.io.IOException
Creates a new file and dumps all of the packet from capture to the new file in the proper format.

Parameters:
type - the type of file to create
file - file to create
capture - source of CapturePackets which will be dumped into the new file
Returns:
open instance of this new file
Throws:
java.io.IOException - any IO errors

openFile

<T extends FileCapture<? extends FilePacket>> T openFile(java.lang.Class<T> t,
                                                         java.io.File file)
                                                     throws java.io.IOException,
                                                            FileFormatException
Throws:
java.io.IOException
FileFormatException

openFile

<T extends FileCapture<? extends FilePacket>> T openFile(java.lang.Class<T> type,
                                                         java.io.File file,
                                                         FileMode mode,
                                                         Filter<ProtocolFilterTarget> filter)
                                                     throws java.io.IOException,
                                                            FileFormatException
Throws:
java.io.IOException
FileFormatException

openFile

FileCapture<? extends FilePacket> openFile(java.io.File file)
                                           throws java.io.IOException
Throws:
java.io.IOException

openFile

FileCapture<? extends FilePacket> openFile(java.io.File file,
                                           FileMode mode,
                                           Filter<ProtocolFilterTarget> protocolFilter)
                                           throws java.io.IOException
Gets a mutable FileCapture instance for the specified file. The MutableFileCapture is ready to read or modify records within the specified file. The supplied filter is applied to packet record data and only records matching the filter are returned by the MutableFileCapture instance.

Parameters:
file - filename to open for reading and writting
mode - TODO
Returns:
Mutable instance of FileCapture
Throws:
java.io.IOException - any IO or format errors

registerListener

void registerListener(CaptureListener listener)

removeRegisteredListener

void removeRegisteredListener(CaptureListener listener)

splitFile

java.util.List<java.io.File> splitFile(java.io.File file)
                                       throws java.io.IOException

Splits the file into smaller files according to default rules defined for each file format. For NAP the file will be split with each Block Record being split into its own seperate file. For other files, the defaults are to split the files into byte files.

The base filename supplied is used as the base filename for all newly created files with the -XXXX appended to them.

The source file is unmodified

Parameters:
file - file to be split
Returns:
list of newly created files
Throws:
java.io.IOException

splitFile

java.util.List<java.io.File> splitFile(java.io.File file,
                                       long packetCount,
                                       boolean maxCompression)
                                       throws java.io.IOException

Split the specified file into smaller files containing specified number of packets each from the source file. New files are created to hold only the specified number of packets and associated meta records. The supplied filename is used as a base filename for all newly created files with the post fix of -XXXX appended to them.

The source file is unmodified

Parameters:
file - source file to split
packetCount - split using this many packets from the source file copied into the newly created files
maxCompression - true means produce the smallest possible file, while false means leave it upto the default algorithm for each spcific file type. For example NAP files pad their files to 512Kb by default which means that files containing even only a single packet are of minimum size 512 Kb, but this can be overriden by setting maxCompression to true. Notice that it will be harder to split the NAP file with regular unix commands if default padding is not used.
Returns:
list of all the new files created
Throws:
java.io.IOException

validateFile

boolean validateFile(java.io.File file)
                     throws java.io.IOException
Checks if the specified file is in a proper format 100% compabile with specification.

Parameters:
file - file to validate
Returns:
true if file is valid with the specification, otherwise false, even if minor infringements are found
Throws:
java.io.IOException