edu.nps.moves.disutil
Class PduFactory

java.lang.Object
  extended by edu.nps.moves.disutil.PduFactory

public class PduFactory
extends java.lang.Object

Simple factory for PDUs. When bytes are received on the wire, they're passed off to us and the correct constructor called to return the correct PDU type.

This should be reworked to use the separate enumerations package, which is generated from the XML EBV file. That's included with the open-dis distribution, but it's still a little new.

Author:
DMcG

Nested Class Summary
static class PduFactory.Platform
           
 
Constructor Summary
PduFactory()
          Creates a new instance of PduFactory
PduFactory(boolean useFastPdu)
          Create a new PDU factory; if true is passed in, we use "fast PDUs", which minimize the memory garbage generated at the cost of being somewhat less pleasant to work with.
 
Method Summary
 Pdu createPdu(byte[] data)
          PDU factory.
 Pdu createPdu(java.nio.ByteBuffer buff)
          PDU factory.
 boolean getUseFastPdu()
           
 void setUseFastPdu(boolean use)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PduFactory

public PduFactory()
Creates a new instance of PduFactory


PduFactory

public PduFactory(boolean useFastPdu)
Create a new PDU factory; if true is passed in, we use "fast PDUs", which minimize the memory garbage generated at the cost of being somewhat less pleasant to work with.

Parameters:
useFastPdu -
Method Detail

setUseFastPdu

public void setUseFastPdu(boolean use)

getUseFastPdu

public boolean getUseFastPdu()

createPdu

public Pdu createPdu(byte[] data)
PDU factory. Pass in an array of bytes, get the correct type of pdu back, based on the PDU type field contained in the byte array.

Parameters:
data -
Returns:
A PDU of the appropriate concrete subclass of PDU

createPdu

public Pdu createPdu(java.nio.ByteBuffer buff)
PDU factory. Pass in an array of bytes, get the correct type of pdu back, based on the PDU type field contained in the byte buffer.

Parameters:
buff -
Returns:
null if there was an error creating the Pdu