rcs.nml
Class PackedFileReader

java.lang.Object
  extended by rcs.nml.PackedFileReader

public class PackedFileReader
extends java.lang.Object

Class that allows the reading of packed files directly without using an NMLConnection.


Constructor Summary
PackedFileReader(NMLMessageDictionary _dict, boolean _l64_mode)
          Create a PackedFileReader for reading log files of a given set of types.
 
Method Summary
 java.lang.String convertMsgToString(NMLmsg inMsg)
          Use FormatConverter to get a string representation of the message.
 java.util.List<LogTimeEntry> createLogTimeEntryList(java.io.File combinedFile, java.io.File indexFile, boolean indexIsLittleEndian, int maxlen, MsgToTimeStamp mtts)
          Create a list to use as an index into a large ".COMBINED" file with multiple messages in it using the ".index" file created by the logRecorder at the same time
static void main(java.lang.String[] args)
           
 NMLmsg ReadFile(java.io.File f)
          Read the entire message in the pointed to file and convert it to an NMLmsg.
 NMLmsg ReadFile(java.io.File f, int max_len)
          Read the first max_len bytes from a file and convert it to an NML message.
 NMLmsg ReadFile(java.lang.String fileName)
          Read the entire file or URL and parse it into an NMLmsg of the appropriate type.
 NMLmsg ReadFile(java.lang.String fileName, int maxlen)
          Read the first maxlen bytes out of a file and convert it to an NMLmsg.
 NMLmsg ReadFileSection(java.io.File f, int offset, int max_len)
          Read a message from a large ".COMBINED" file that contains multiple messages.
 NMLmsg ReadFileSection(java.lang.String fileName, int offset, int maxlen)
          Read a section of a large file containing many messages.
static int[] ReadIndexes(java.io.File indexFile, boolean littleEndian)
          Read an indexFile as created by the logRecorder into an integer array.
static int[] ReadIndexes(java.lang.String indexFileName, boolean littleEndian)
          Read an indexFile as created by the logRecorder into an integer array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PackedFileReader

public PackedFileReader(NMLMessageDictionary _dict,
                        boolean _l64_mode)
Create a PackedFileReader for reading log files of a given set of types.

Parameters:
_dict - MessageDictionary with auto-generated format functions to parse this specific file types.
_l64_mode - should longs be stored or expected to be 64-bit instead of 32-bit
Method Detail

ReadFile

public NMLmsg ReadFile(java.lang.String fileName)
Read the entire file or URL and parse it into an NMLmsg of the appropriate type.

Parameters:
fileName - the path to a file, or a filename in the current directory or a URL beginning with "http://"
Returns:
message from given file.

ReadFile

public NMLmsg ReadFile(java.lang.String fileName,
                       int maxlen)
Read the first maxlen bytes out of a file and convert it to an NMLmsg. It is typically used to extract just a timestamp in one of the first variables of a large message.

Parameters:
fileName - fileName or path or URL to read.
maxlen - number of bytes to actually read.
Returns:
message from file. (variables stored after maxlen will be all zero.)

ReadFileSection

public NMLmsg ReadFileSection(java.lang.String fileName,
                              int offset,
                              int maxlen)
                       throws java.lang.Exception
Read a section of a large file containing many messages.

Parameters:
fileName - filename or path to file or URL starting with "http://"
offset - number of bytes from beginning of file to location of the desired message
maxlen - maximum number of bytes in the message
Returns:
message from the file.
Throws:
java.lang.Exception - throws exception of offset or max_len exceeds the size of file or

ReadFile

public NMLmsg ReadFile(java.io.File f)
Read the entire message in the pointed to file and convert it to an NMLmsg.

Parameters:
f - the file to read.
Returns:
message from File.

ReadFile

public NMLmsg ReadFile(java.io.File f,
                       int max_len)
Read the first max_len bytes from a file and convert it to an NML message. It is typically used to get a timestamp which is one of the first few variables in a large message. Variables from more than max_len bytes into the file will be left zero.

Parameters:
f - file to read
max_len - maximum number of bytes to read.
Returns:
the message for the given file with variables after max_len left zero.

ReadIndexes

public static int[] ReadIndexes(java.lang.String indexFileName,
                                boolean littleEndian)
                         throws java.lang.Exception
Read an indexFile as created by the logRecorder into an integer array.

Parameters:
indexFileName - name of the index file.
littleEndian - was the log recorder run on a littleEndian platform (probably true)
Returns:
integer array with the indexes
Throws:
java.lang.Exception - occurs if the file does not exist or can not be read.

ReadIndexes

public static int[] ReadIndexes(java.io.File indexFile,
                                boolean littleEndian)
                         throws java.lang.Exception
Read an indexFile as created by the logRecorder into an integer array.

Parameters:
indexFile - file to read
littleEndian - was the log recorder run on a littleEndian platform (probably true)
Returns:
integer array with the indexes
Throws:
java.lang.Exception - occurs if the file does not exist or can not be read.

createLogTimeEntryList

public java.util.List<LogTimeEntry> createLogTimeEntryList(java.io.File combinedFile,
                                                           java.io.File indexFile,
                                                           boolean indexIsLittleEndian,
                                                           int maxlen,
                                                           MsgToTimeStamp mtts)
                                                    throws java.lang.Exception
Create a list to use as an index into a large ".COMBINED" file with multiple messages in it using the ".index" file created by the logRecorder at the same time

Parameters:
combinedFile - large file with multiple messages to read
indexFile - index file with list of position offsets only
indexIsLittleEndian - true if the logRecorder was run on a little-endian platform
maxlen - number of bytes of each message that needs to be read to get the time stamp.
mtts - class to get timestamp out of custom message types.
Returns:
list of LogTimeEntry objects useful for finding a message at a given time.
Throws:
java.lang.Exception - are thrown if one of files does not exist or is not readable.

main

public static void main(java.lang.String[] args)

ReadFileSection

public NMLmsg ReadFileSection(java.io.File f,
                              int offset,
                              int max_len)
                       throws java.lang.Exception
Read a message from a large ".COMBINED" file that contains multiple messages.

Parameters:
f - file to read
offset - offset in bytes to the desired message
max_len - number of bytes to read from desired message
Returns:
message read from that part of the file.
Throws:
java.lang.Exception - throws exception of offset or max_len exceeds the size of file or file is not readable.

convertMsgToString

public java.lang.String convertMsgToString(NMLmsg inMsg)
Use FormatConverter to get a string representation of the message.

Parameters:
inMsg -
Returns: