All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class mil.navy.nps.dis.EntityID

java.lang.Object
   |
   +----mil.navy.nps.dis.PduElement
           |
           +----mil.navy.nps.dis.EntityID

public class EntityID
extends PduElement
EntityID EntityID is a composite of several values that are commonly found together, and that,when combined, uniquely identify an entity in a simulation.

For a web-based reference, see

Note that I've "flattened" it a bit, by combining the simulation address record together with the entity ID in one object, rather than using the simulation address as its own object. This is a questionable move.

It's used in a variety of PDUs, typically to identify a receving and a sending entity. Since it uniquely identifies an entity in a virtual world, it's a good candidate to act as a hash table key.

HISTORY

15Nov96 DMcG New
10Mar97 DMcG cleaned up for javadoc

Version:
1.0
Author:
Don McGregor ( http://www.stl.nps.navy.mil/~mcgredo)

See Also:
ProtocolDataUnit, PduElement, SerializationInterface

Constructor Index

 o EntityID()
 o EntityID(short, short, short)

Method Index

 o application()
 o clone()
 o deSerialize(DataInputStream)
 o entity()
 o equals(Object)
returns yes if the object is exactly equal to another object, ie, contains the same values.
 o hashCode()
This provides a hash code for the object, since this is a handy way to uniquely identify entities.
 o length()
 o printValues(int)
 o serialize(DataOutputStream)
 o setApplication(int)
 o setApplication(UnsignedShort)
 o setEntity(int)
 o setEntity(UnsignedShort)
 o setSite(int)
 o setSite(UnsignedShort)
 o site()

Constructors

 o EntityID
  public EntityID()
 o EntityID
  public EntityID(short pSiteID,
                  short pApplicationID,
                  short pEntityID)

Methods

 o clone
  public Object clone()
Overrides:
clone in class PduElement
 o serialize
  public void serialize(DataOutputStream outputStream)
Overrides:
serialize in class PduElement
 o deSerialize
  public void deSerialize(DataInputStream inputStream)
Overrides:
deSerialize in class PduElement
 o length
  public int length()
Overrides:
length in class PduElement
 o printValues
  public void printValues(int indentLevel)
Overrides:
printValues in class PduElement
 o hashCode
  public int hashCode()
This provides a hash code for the object, since this is a handy way to uniquely identify entities. There's a problem, since there are 48 bits of information in the object, but the hash code has only 32 bits to put things in. The solution right now is to ignore the application ID when generating the hash code. Furthermore, the entity ID is in the upper 16 bits, while the site ID is in the lower 16 bits. The idea is that this will help spread out the hash code a bit more, since there are probably many more entities than sites, and putting the part with more information in the MSB helps spread things out.

Overrides:
hashCode in class Object
 o equals
  public boolean equals(Object obj)
returns yes if the object is exactly equal to another object, ie, contains the same values.

Overrides:
equals in class Object
 o site
  public UnsignedShort site()
 o setSite
  public void setSite(UnsignedShort pSite)
 o setSite
  public void setSite(int pSite)
 o application
  public UnsignedShort application()
 o setApplication
  public void setApplication(UnsignedShort pApplication)
 o setApplication
  public void setApplication(int pApplication)
 o entity
  public UnsignedShort entity()
 o setEntity
  public void setEntity(UnsignedShort pEntity)
 o setEntity
  public void setEntity(int pEntity)

All Packages  Class Hierarchy  This Package  Previous  Next  Index