org.jnetstream.capture.file
Interface DataRecord

All Superinterfaces:
Record, com.slytechs.utils.collection.Validatable
All Known Subinterfaces:
NAPCaptureSystem, NAPDataRecord, NAPEvent, NAPExpert, NAPMetaRecord, NAPNoOp, NAPProperty, NAPRouting, NAPVendor, PcapPacketRecord, SnoopPacketRecord

public interface DataRecord
extends Record

Data record is a record in a capture file that belongs to one block record, a parent/child relationship, and contains some kind of data. Data records usually contain packet data but other types of data records also exist in certain file formats.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jnetstream.capture.file.Record
Record.RecordHeaderField
 
Method Summary
<C extends DataRecord>
C
asType(java.lang.Class<C> c)
          Converts java class type of a generic record into more specific record.
 BlockRecord getBlockRecord()
          Gets the parent block record this data record belongs to.
 java.nio.ByteBuffer getRecordDataBuffer()
          Gets the data buffer of this record.
 int getRecordDataLength()
          Retrieves the length of the data within the record.
 
Methods inherited from interface org.jnetstream.capture.file.Record
asType, edit, getFileCapture, getPositionGlobal, getRecordBuffer, getRecordHeaderBuffer, getRecordHeaderLength, getRecordLength, getRecordType
 
Methods inherited from interface com.slytechs.utils.collection.Validatable
isValid
 

Method Detail

getBlockRecord

BlockRecord getBlockRecord()
Gets the parent block record this data record belongs to. Data records always belong to a block record, that is block records contain a sequential list of data records.

Returns:
parent block record

getRecordDataBuffer

java.nio.ByteBuffer getRecordDataBuffer()
                                        throws java.io.IOException
Gets the data buffer of this record. The record is made up of a record header and record data. The record data field does not contain the record's header. Record's header + record's data equal the entire record.

Returns:
the data buffer which contains only the data portion of the record
Throws:
java.io.IOException

getRecordDataLength

int getRecordDataLength()
                        throws java.io.IOException
Retrieves the length of the data within the record. This length does not contain the length of the record's header. Also if this data record is a packet record for certain file formats the length may be more then as returned by Packet#getIncludedLength due to the fact that certain records may be oversized to hold the packet data and thus there is unsused record data portion.

Returns:
length in bytes of only the data portion of the record
Throws:
java.io.IOException

asType

<C extends DataRecord> C asType(java.lang.Class<C> c)
                            throws FileFormatException
Converts java class type of a generic record into more specific record. This method does not do conversion between different types of records simply allows easy way of casting a record from more generic to more specific type. Note that a normal java typecast to more specific record type may fail as this is very implementation dependent behaviour and should not be relied upon. The proper way to change a Record object into a more specific object that is matched by the Record type is to use the asType(java.lang.Class) method. Note that the actual record object may be a stub in a remote session and the actual more specific type may have to be fetched accross a network conneciton.

Type Parameters:
C - class type to convert this record to. The record type must be of the correct type inorder for the cast conversion to succeed.
Parameters:
c - class instance of specific class type of a record to be converted to
Returns:
returns an instance pointing at the more specific record type requested
Throws:
FileFormatException - if the current record is not of the correct type for the conversion to take place