/* File: BurstDescriptor.java CVS Info: $Id: BurstDescriptor.java,v 1.2 1998/01/27 18:43:55 mcgredo Exp $ Compiler: jdk 1.3 */ package mil.navy.nps.dis; // our package import mil.navy.nps.util.*; // General-purpose utilities import mil.navy.nps.disEnumerations.*; // Enumerations for DIS import java.io.*; import java.util.*; /** * Weapons burst (firing) description record. * *@version 1.0 *@author Don McGregor (http://www.npsnet.org/~mcgredo) * *
* Includes the EntityType record, which describes the country and assorted other geeky information.
*
sizeOf = 16 bytes
.
*/
public static final int sizeOf = 16; // 16 bytes long when written to wire
/**
*Default constructor. Initializes everything to zero, basically.
*/
public BurstDescriptor()
{
munition = new EntityType();
warhead = new UnsignedShort();
fuse = new UnsignedShort();
quantity = new UnsignedShort();
rate = new UnsignedShort();
return;
}
public Object clone()
{
// make a copy of the object. This requires a deep copy, so we don't have two
// objects sharing pointers to the same data.
BurstDescriptor newBurstDescriptor = new BurstDescriptor();
newBurstDescriptor.setMunition(this.getMunition());
newBurstDescriptor.setWarhead(this.getWarhead());
newBurstDescriptor.setFuse(this.getFuse());
newBurstDescriptor.setQuantity(this.getQuantity());
newBurstDescriptor.setRate(this.getRate());
return newBurstDescriptor;
}
/* serialize the object in DIS format to a stream.
@param outputStream stream the object is being serialized to
*/
public void serialize(DataOutputStream outputStream)
{
// write out the data to an output stream. Order is important here, since
// it needs to conform to the DIS standard.
//super.serialize(outputStream); // No need to call super, since no ivars are in our direct superclass
munition.serialize(outputStream);
warhead.serialize(outputStream);
fuse.serialize(outputStream);
quantity.serialize(outputStream);
rate.serialize(outputStream);
return;
}
public void deSerialize(DataInputStream inputStream)
{
// order is important here, since we need to read in the same order as
// specified by the DIS standard.
// no need to call super, since there are no ivars in the superclass.
munition.deSerialize(inputStream);
warhead.deSerialize(inputStream);
fuse.deSerialize(inputStream);
quantity.deSerialize(inputStream);
rate.deSerialize(inputStream);
return;
}
public int length()
{
return sizeOf; // BurstDescriptors are this long, always.
}
public void printValues(int indentLevel, PrintStream printStream)
{
// print the values of the object out, with correct level of
// indentation on the page.
StringBuffer buf = ProtocolDataUnit.getPaddingOfLength(indentLevel);
int idx, superclassIndent = indentLevel;
munition.printValues(indentLevel, printStream);
printStream.println(buf + "warhead: " + warhead.intValue());
printStream.println(buf + "fuse: " + fuse.intValue());
printStream.println(buf + "quantity: "+ quantity.intValue());
printStream.println(buf + "rate: " + rate.intValue());
return;
}
// Accessor methods
public EntityType getMunition()
{ return (EntityType)munition.clone();
}
public void setMunition(EntityType pMunition)
{ munition = pMunition;
}
public UnsignedShort getWarhead()
{ return (UnsignedShort)warhead.clone();
}
public void setWarhead(UnsignedShort pWarhead)
{warhead = pWarhead;
}
public void setWarhead(int pWarhead)
{ warhead = new UnsignedShort(pWarhead);
}
public UnsignedShort getFuse()
{ return (UnsignedShort)fuse.clone();
}
public void setFuse(UnsignedShort pFuse)
{fuse = pFuse;
}
public void setFuse(int pFuse)
{fuse = new UnsignedShort(pFuse);
}
public UnsignedShort getQuantity()
{ return (UnsignedShort)quantity.clone();
}
public void setQuantity(UnsignedShort pQuantity)
{quantity = pQuantity;
}
public void setQuantity(int pQuantity)
{ quantity = new UnsignedShort(pQuantity);
}
public UnsignedShort getRate()
{ return (UnsignedShort)rate.clone();
}
public void setRate(UnsignedShort pRate)
{rate = pRate;
}
public void setRate(int pRate)
{ rate = new UnsignedShort(pRate);
}
} // end of class BurstDescriptor