|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmanager.ClassLookup
public class ClassLookup
Translates class names and class.attribute names to integer handles
as defined by the RTI for this federation execution.
This could be done by calling the RTI every time, but since handles
never change through a federation, the result is cached instead..
The datastructure must be loaded with classes, each one of which
must be associated with a name and a list of variable names which
match the info in the .fed file used for this simulation.
Once #resolveNames(RTIambassador)
is called the ClassLookup
is now useable.
Constructor Summary | |
---|---|
ClassLookup()
Construct an emtpy, un-resolved ClassLookup |
|
ClassLookup(java.lang.Class[] classes)
|
Method Summary | |
---|---|
void |
addClass(java.lang.Class c)
This is a convenience method which associates the given class with the class and variable names derived from reflection. |
void |
addClass(java.lang.Class c,
java.lang.String HLAName,
java.lang.String[] varNames)
Adds a Class to the Lookup along with the HLAName for the Class as it is recorded in a .fed file which will be used to run the federation for which this ClassLookup is valid |
java.util.Collection<java.lang.Class> |
getClasses()
Get all classes registered with this lookup |
java.lang.Class |
getClassFor(int handle)
Get the Class object corresponding to the given handle
assigned to it by the RTI. |
int |
getClassHandle(java.lang.Class c)
Gets the handle of this class as it is recorded by the RTI |
int |
getVariableHandle(int classHandle,
java.lang.String varName)
Get the handle assigned to the given public variable of the given class. |
java.lang.String |
getVariableName(int classHandle,
int varHandle)
Get the local String name associated with the given variable. |
java.lang.String[] |
getVarNames(java.lang.Class c)
Get the variables associated with this class as registered with this lookup. |
boolean |
hasClass(java.lang.Class c)
True if the given class has been locally registered with this lookup. |
boolean |
isResolved()
Tells whether or not the .fed names have been resolved to RTI class handles in this ClassLookup |
void |
resolveNames()
Resolves the .fed recorded names to HLA class handle integers. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ClassLookup()
public ClassLookup(java.lang.Class[] classes) throws hla.rti13.java1.RTIexception
hla.rti13.java1.RTIexception
Method Detail |
---|
public void addClass(java.lang.Class c, java.lang.String HLAName, java.lang.String[] varNames)
c
- the Class to addHLAName
- the name of the class in the .fed filepublic void addClass(java.lang.Class c)
PublicObject.getPublicVariables()
on
a new instance of the given class. If the class has no default constructor,
then this method will crash and the addClass(Class, String, String[])
version of this method should be used instead.
c
- The class to add to this ClassLookup, using the actual name of this
class and the result of PublicObject.getPublicVariables()
as the
information in the .fed file for this federation.public void resolveNames() throws hla.rti13.java1.RTIexception
hla.rti13.java1.RTIexception
- if an error occurs with the RTI. In almost all cases
the exception will be a result of one of the HLANames not having been
recorded in the ClassLookup correctlypublic boolean isResolved()
public int getClassHandle(java.lang.Class c)
c
- the Class to find out about
resolveNames()
java.lang.NullPointerException
- if c is null or if c has not been recorded
in this ClassLookup
java.lang.ClassCastException
- if this ClassLookup has not been resolved
(i.e. if isResolved()
returns false)public boolean hasClass(java.lang.Class c)
c
- the class to query
addClass(Class)
public java.util.Collection<java.lang.Class> getClasses()
public java.lang.String[] getVarNames(java.lang.Class c)
c
- the class to query
public java.lang.Class getClassFor(int handle)
Class
object corresponding to the given handle
assigned to it by the RTI.
handle
- the RTI-assigned handle
public int getVariableHandle(int classHandle, java.lang.String varName)
classHandle
- the RTI-assinged class handle (see
getClassHandle(Class)
)varName
- the String name of the variable in question (see
PublicObject.getPublicVariables()
)
public java.lang.String getVariableName(int classHandle, int varHandle)
classHandle
- the RTI-assinged class handle (see
getClassHandle(Class)
)varHandle
- the RTI-assigned handle for the given variable (see
getVariableHandle(int, String)
)
PublicObject.getPublicVariables()
)public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |