/* File: EntityType.java CVS Info: $Id: EntityType.java,v 1.2 1998/01/27 18:44:11 mcgredo Exp $ Compiler: jdk 1.3 */ package mil.navy.nps.dis; // package to which we belong import mil.navy.nps.util.*; // General-purpose utilities import mil.navy.nps.disEnumerations.*; // Enumerations for DIS import java.util.*; // utility stuff we need import java.io.*; // input/output for serialization /** * Record providing full identification of entity type. * *@version 1.0 *@author Don McGregor (http://www.npsnet.org/~mcgredo) * *
*
* *
*
sizeOf = 8 bytes
*/
public final static int sizeOf = 8; // size of default object AS WRITTEN TO WIRE
/**
*Default constructor--fills with zeros for all values.
*/
public EntityType() // default constructor
{
kind = new UnsignedByte(0);
domain = new UnsignedByte(0);
country = new UnsignedShort(0);
category = new UnsignedByte(0);
subCategory = new UnsignedByte(0);
specific = new UnsignedByte(0);
extra = new UnsignedByte(0);
return;
}
public Object clone()
{
EntityType newEntityType = new EntityType();
newEntityType.setKind(this.getKind());
newEntityType.setDomain(this.getDomain());
newEntityType.setCountry(this.getCountry());
newEntityType.setCategory(this.getCategory());
newEntityType.setSubCategory(this.getSubCategory());
newEntityType.setSpecific(this.getSpecific());
newEntityType.setExtra(this.getExtra());
return newEntityType;
}
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
kind.serialize(outputStream);
domain.serialize(outputStream);
country.serialize(outputStream);
category.serialize(outputStream);
subCategory.serialize(outputStream);
specific.serialize(outputStream);
extra.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.
kind.deSerialize(inputStream);
domain.deSerialize(inputStream);
country.deSerialize(inputStream);
category.deSerialize(inputStream);
subCategory.deSerialize(inputStream);
specific.deSerialize(inputStream);
extra.deSerialize(inputStream);
return;
}
public int length()
{
return sizeOf; // EntityTypes 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 indent = ProtocolDataUnit.getPaddingOfLength(indentLevel);
int idx, superclassIndent = indentLevel;
printStream.println(indent + "kind: " + kind.intValue());
printStream.println(indent + "domain: " + domain.intValue());
printStream.println(indent + "country: " + country.intValue());
printStream.println(indent + "category: " + category.intValue());
printStream.println(indent + "subCategory: " + subCategory.intValue());
printStream.println(indent + "specific: " + specific.intValue());
printStream.println(indent + "extra: " + extra.intValue());
return;
}
//Accessor methods
public UnsignedByte getKind()
{ return (UnsignedByte)kind.clone();
}
public void setKind(UnsignedByte pKind)
{kind = pKind;
}
public void setKind(int pKind)
{ kind = new UnsignedByte(pKind);
}
public UnsignedByte getDomain()
{ return (UnsignedByte)domain.clone();
}
public void setDomain(UnsignedByte pDomain)
{domain = pDomain;
}
public void setDomain(int pDomain)
{ domain = new UnsignedByte(pDomain);
}
public UnsignedShort getCountry()
{ return (UnsignedShort)country.clone();
}
public void setCountry(UnsignedShort pCountry)
{country = pCountry;
}
public void setCountry(int pCountry)
{ country = new UnsignedShort(pCountry);
}
public UnsignedByte getCategory()
{ return (UnsignedByte)category.clone();
}
public void setCategory(UnsignedByte pCategory)
{category = pCategory;
}
public void setCategory(int pCategory)
{ category = new UnsignedByte(pCategory);
}
public UnsignedByte getSubCategory()
{ return (UnsignedByte)subCategory.clone();
}
public void setSubCategory(UnsignedByte pSubCategory)
{subCategory = pSubCategory;
}
public void setSubCategory(int pSubCategory)
{ subCategory = new UnsignedByte(pSubCategory);
}
public UnsignedByte getSpecific()
{ return (UnsignedByte)specific.clone();
}
public void setSpecific(UnsignedByte pSpecific)
{specific = pSpecific;
}
public void setSpecific(int pSpecific)
{ specific = new UnsignedByte(pSpecific);
}
public UnsignedByte getExtra()
{ return (UnsignedByte)extra.clone();
}
public void setExtra(UnsignedByte pExtra)
{extra = pExtra;
}
public void setExtra(int pExtra)
{ extra = new UnsignedByte(pExtra);
}
} // end of class EntityType