|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmil.navy.nps.dis.BehaviorStreamBuffer
mil.navy.nps.dis.BehaviorStreamBufferFile
BehaviorStreamBufferFile is a class responsible for interpreting data received via a file and interpreting it as DIS PDUs.
DIS is by nature packet-oriented, while files are stream-oriented. this means that we must parse the data as it comes in, to determine how many bytes to read. This can be done via the PDU length field in the PDU header. This is always at the same point in the packet, and describes how many bytes to read. By nature, if this count is off, the stream will get scrambled.
Note that if we're reading from a file, we don't want to get TOO carried away with this whole reading thing. This might read the entire contents of a file in before anyone consumes any PDUs. This would be a disaster for big files. We do some thread synchronization with wait() and notify() in the methods that read data and consume PDUs. This regulates the number of pdus read in beforehand to DEFAULT_READAHEAD_SIZE.
The bsbf has prepended data that says something about the stream saved inside. This consists of a version number, a byte count, and a string that describes the data. this string right now contains a URL and a flag that tells whether the saved PDUs are using RTP headers.
Field Summary | |
boolean |
atEOF
Set to true if the file is at EOF. |
static boolean |
DEBUG
|
static int |
DEFAULT_READAHEAD_SIZE
|
static int |
HEADER_VERSION
|
static int |
MAX_DATAGRAM_SIZE
|
Fields inherited from class mil.navy.nps.dis.BehaviorStreamBuffer |
info, inputThreadStarted, readThreadRunning, rtpEnabled, runContinue, strategy |
Constructor Summary | |
BehaviorStreamBufferFile(java.io.File pFile,
BehaviorStreamBufferInfo pInfo,
boolean pIsReader)
All-signing, all-dancing constructor |
|
BehaviorStreamBufferFile(java.io.File pFile,
boolean pIsReader)
Constructor, takes a file. |
|
BehaviorStreamBufferFile(java.lang.String pFileName,
BehaviorStreamBufferInfo pInfo,
boolean pIsReader)
yet another constructor |
|
BehaviorStreamBufferFile(java.lang.String pFileName,
boolean pIsReader)
Constructor; takes a string filename. |
|
BehaviorStreamBufferFile(java.lang.String pFileName,
java.lang.String readerOrWriter)
Constructor, takes a fileName and a reader/writer configuration string ("reader" or "writer"). |
Method Summary | |
void |
cleanup()
Closes down input buffers, sockets, or open files nicely |
void |
debug(java.lang.String pMessage)
Debugging output |
protected void |
finalize()
Finalize method--used to clean up any files that are still open |
ProtocolDataUnit |
getNextPdu()
Get the next PDU from the input stream. |
static void |
main(java.lang.String[] args)
Used to debug/test the class |
java.util.Vector |
receivedPdus()
Returns a vector of all the PDUs received since the last time we asked. |
void |
resumeReading()
Start reading packets from the datagramStreamBuffer again. |
void |
run()
Threading method to read/write until shutdown. |
void |
sendPdu(ProtocolDataUnit pPdu)
Sends a PDU. |
void |
sendPdu(ProtocolDataUnit pPdu,
java.lang.Object pAddress1,
java.lang.Object pAddress2)
Send a PDU to an address. |
void |
setIsReader(boolean pIsReader)
sets whether we're a reader or writer. |
void |
setReadAheadSize(int pNewReadAheadSize)
Set the max readahead size. |
void |
shutdown()
Terminate the run loop and shutdown the thread. |
void |
startInputThread()
Simple method to launch thread. |
void |
suspendReading()
suspend reading in the DatagramStreamBuffer |
void |
trace(java.lang.String pMessage)
tracing output |
Methods inherited from class mil.navy.nps.dis.BehaviorStreamBuffer |
checkForThreadStart, getDEBUG, getInfo, getRtpEnabled, sendPdu, setDEBUG, setInfo, setRtpEnabled, startInputThreadWithSecurity |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int MAX_DATAGRAM_SIZE
public static final int DEFAULT_READAHEAD_SIZE
public static final int HEADER_VERSION
public static boolean DEBUG
public boolean atEOF
Constructor Detail |
public BehaviorStreamBufferFile(java.io.File pFile, boolean pIsReader)
pFile
- file object to read or write frompIsReader
- are we a reader or writer?public BehaviorStreamBufferFile(java.lang.String pFileName, boolean pIsReader)
public BehaviorStreamBufferFile(java.lang.String pFileName, BehaviorStreamBufferInfo pInfo, boolean pIsReader)
public BehaviorStreamBufferFile(java.io.File pFile, BehaviorStreamBufferInfo pInfo, boolean pIsReader)
public BehaviorStreamBufferFile(java.lang.String pFileName, java.lang.String readerOrWriter)
Method Detail |
public void setReadAheadSize(int pNewReadAheadSize)
public void setIsReader(boolean pIsReader)
public void startInputThread()
startInputThread
in class BehaviorStreamBuffer
public void shutdown()
shutdown
in class BehaviorStreamBuffer
public void suspendReading()
suspendReading
in class BehaviorStreamBuffer
public void resumeReading()
resumeReading
in class BehaviorStreamBuffer
public void run()
run
in interface java.lang.Runnable
run
in class BehaviorStreamBuffer
public java.util.Vector receivedPdus()
receivedPdus
in class BehaviorStreamBuffer
public ProtocolDataUnit getNextPdu()
getNextPdu
in class BehaviorStreamBuffer
public void sendPdu(ProtocolDataUnit pPdu)
sendPdu
in class BehaviorStreamBuffer
public void sendPdu(ProtocolDataUnit pPdu, java.lang.Object pAddress1, java.lang.Object pAddress2)
sendPdu
in class BehaviorStreamBuffer
pPdu
- protocol data unit being sentpAddress1
- ignoredpAddress2
- ignoredpublic void cleanup()
cleanup
in class BehaviorStreamBuffer
protected void finalize() throws java.lang.Throwable
finalize
in class BehaviorStreamBuffer
java.lang.Throwable
public void trace(java.lang.String pMessage)
trace
in class BehaviorStreamBuffer
public void debug(java.lang.String pMessage)
debug
in class BehaviorStreamBuffer
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |