/* File: ModulationType.java CVS Info: $Id: ModulationType.java,v 1.2 2000/07/03 18:44:35 laflam Exp $ Compiler: jdk 1.3 */ package mil.navy.nps.dis; import mil.navy.nps.util.*; // General-purpose utilities import mil.navy.nps.disEnumerations.*; // Enumerations for DIS import java.lang.*; import java.util.*; import java.io.*; /** * Entity location in world coordinates. * *@version 1.0 *@author Don McGregor (http://www.web3d.org/WorkingGroups/vrtp/dis-java-vrml/) * *
* *
sizeOf = 64 bytes
.
*/
public final int sizeOf = 64; // object is 64 bytes long
/**
*Constructs an new ModulationType Object, centered.
*/
public ModulationType()
{
// default constructor
//for ( int i=0; i<16; i++) {
// spreadspectrum [ i ] = false;
//} // end for
spreadSpectrum = 0 ; // 16-bit Boolean array
major = new UnsignedShort(0); // 16-bit enumeration
detail = new UnsignedShort(0); // 16-bit enumeration
system = new UnsignedShort(0); // 16-bit enumeration
return;
} // end constructor
/**
*Constructs a new ModulationType Object whose field values are passed in parameters.
*
*@param pSpreadSpectrum the first field in the ModulationType Object.
*@param pMajor the second field in the ModulationType Object.
*@param pDetail the third field in the ModulationType Object.
*@param pSystem the third field in the ModulationType Object.
*/
public ModulationType(short pSpreadSpectrum, UnsignedShort pMajor,UnsignedShort pDetail,UnsignedShort pSystem)
{
spreadSpectrum = pSpreadSpectrum;
major = pMajor;
detail = pDetail;
system = pSystem;
return;
}// end copy constructor
/**
* Make a copy of the object. This requires a deep copy, so we don't have two
* objects sharing pointers to the same data.
* @return a new ModulationType
*/
public Object clone()
{
ModulationType newModulationType = new ModulationType(spreadSpectrum, major, detail, system );
return newModulationType;
} //end Object clone() method
/**
*@exception RuntimeException when IO error occurs.
*/
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
try
{
outputStream.writeShort(spreadSpectrum); // don should this be an UnsignedShort ?
major.serialize(outputStream);
detail.serialize(outputStream);
system.serialize(outputStream);
}
catch (IOException ioError)
{
throw new
RuntimeException("Exception in ModulationType. Error writing to wire.");
}
}// end void serialize method
/**
*@exception RuntimeException when IO error occurs.
*/
public void deSerialize(DataInputStream pInputStream)
{
try
{
spreadSpectrum = pInputStream.readShort();
major = new UnsignedShort(pInputStream.readShort());
detail = new UnsignedShort(pInputStream.readUnsignedShort());
system = new UnsignedShort(pInputStream.readUnsignedShort());
}
catch (IOException ioError)
{
throw new
RuntimeException("Exception in WorldPosition. Error reading from wire.");
}
}// end void deSerialize method
public int length()
{
return sizeOf; // EntityTypes are this long, always.
} //end int length() method
public void printValues(int indentLevel, PrintStream printStream)
{
// print the values of the object out, with correct level of
// indentation on the page.
StringBuffer indent = ProtocolDataUnit.getPaddingOfLength(indentLevel);
int idx, superclassIndent = indentLevel;
printStream.println(indent + "ModulationType spreadSpectrum: " + spreadSpectrum);
printStream.println(indent + "ModulationType major: " + major);
printStream.println(indent + "ModulationType detail: " + detail);
printStream.println(indent + "ModulationType System: " + system);
return;
}
// Accessor methods (get and set methods)
/**
* Gets SpreadSpectrum
* @return spreadSpectrum
*/
public short getSpreadSpectrum()
{
return spreadSpectrum;
}
/**
* Sets SpreadSpectrum
* @param pSpreadSpectrum a SpreadSpectrum
*/
public void setSpreadSpectrum(short pSpreadSpectrum)
{
spreadSpectrum = pSpreadSpectrum;
}
/**
* Gets Major
* @return major
*/
public UnsignedShort getMajor()
{
return major;
}
/**
* Sets Major
* @param pMajor a Major
*/
public void setMajor(UnsignedShort pMajor)
{
major = pMajor;
}
/**
* Gets Detail
* @return detail
*/
public UnsignedShort getDetail()
{
return detail;
}
/**
* Sets Detail
* @param pDetail a Detail
*/
public void setDetail(UnsignedShort pDetail)
{
detail = pDetail;
}
/**
* Gets System
* @return System
*/
public UnsignedShort getSystem()
{
return system;
}
/**
* Sets System
* @param pSystem a System
*/
public void setSystem(UnsignedShort pSystem)
{
system = pSystem;
}
/**
* String toString
* Used for debuging
*/
public String toString()
{
String result ;
result = " SpreadSpectrum = " + spreadSpectrum + " Major = " + major + " Detail = " + detail + " system = " + system;
return result;
}
} // end of class ModulationType