/* 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) * *
Location: *
* http://www.web3d.org/WorkingGroups/vrtp/mil/navy/nps/dis/EntityType.java * *
* ~/mil/navy/nps/dis/EntityType.java * *
Hierarchy Diagram: *
* *
Summary: *
This record shall specify the kind of entity, the country of design, the domain, * the specific identification of the entity, and any extra information necessary * for describing the entity.

*

Explanation: *
The type of entity in a DIS exercise shall be specified by an Entity Type record. * Fields not used shall contain the value zero.

* *

History: *
2Dec96 /Don McGregor /New *
10Mar97 /Don McGregor /Cleaned up for javadoc *
16Apr97 /Don McGregor /PrintStream passed to printValues *
8Dec97 /Ronan Fauglas /changes for documentation templates + complements in documentation
*
8Dec97 /Ronan Fauglas /changed entityKind to kind * *
References: *
DIS Data Dictionary :Entity Type Record

*

DIS specification : IEEE 1278.1, 5.3.16 * *@see PduElement */ public class EntityType extends PduElement { /** *Entity kind: munition, life form, environmental... *For now, entity kind is : 0-9 * *
*
Value: *Enumeration; see references below for information. *
References: *
DIS Data Dictionary: Entity Kind Field *
see Section 4 in EBV-DOC *
*/ protected UnsignedByte kind; // kind of entity /** *This field shall specify the domain in which the equipment operates *(for example, subsurface, surface, land, etc.) except for munition entities. *For Munition entities this field shall specify the domain of the target *(for example the munition might be surface-to-air, so the domain would be anti-air). *
*
Value: * Enumeration; see references below for information. *
References: *
DIS Data Dictionary: Entity Domain Field *
see Section 4 in EBV-DOC *
*/ protected UnsignedByte domain; // subsurface, surface, etc. /** *This field shall specify the country to which the design of the entity is *attributed. a 16 bits enumeration. * *
*
Value: * Enumeration; see references below for information. *
References: *
DIS Data Dictionary: Country Field *
See Section 4 in EBV-DOC *
*/ protected UnsignedShort country; // country to which design is attributed /** *This field shall specify the main category that describes the entity. *The enumerations of category depend upon both the Kind and Domain. * *
*
Value: * Enumeration; see references below for information. *
References: *
DIS Data Dictionary: Entity Category Field *
See Section 4 in EBV-DOC *
*/ protected UnsignedByte category; // main category that describes entityt /** *This field shall specify a particular subcategory to which the entity *belongs based on the category and the country. * *
*
Value: * Enumeration; see references below for information. *
References: *
DIS Data Dictionary: Entity Subcategory Field *
See Section 4 in EBV-DOC *
*/ protected UnsignedByte subCategory; // subcategory, based on category field /** *This field shall specify specific information about an entity based upon *the subcategory field to which it belongs. * *
*
Value: * Enumeration; see references below for information. *
References: *
DIS Data Dictionary: Entity Specific Field *
See Section 4 in EBV-DOC *
*/ protected UnsignedByte specific; // specific info, based on subCategory field /** *This field shall specify extra information required to describe a particular entity. *The contents of this field shall depend on the type of entity represented. * *
*
Value: * Enumeration. *
References: *
DIS Data Dictionary: Entity Extra Field *
*/ protected UnsignedByte extra; // extra info, depending on type of entity /** *Constant value--size of an EntityType as written out to the wire. Here: *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