org.sandev.basics.util
Interface InstanceClassEnumerator


public interface InstanceClassEnumerator

Provide a mapping between short names of messages or interfaces, and derived or implementing classes.

This class is primarily intended to support user interfaces, where it is not necessarily clear from the context which class is being referred to. A typical case would be a adding an element to an array that is declared as a superclass or interface. In this case we would need to ask the user what actual instance they want to create.

At build time, we have all the classes for the deployment we are currently building. So it is possible to build a lookup structure for every declared class and/or interface, which provides all subinterfaces, implementing classes, and/or subclasses. This lookup structure is captured statically in an implementing class, and the methods traverse the lookup structure to return their results.

Because the primary focus of this class is UI disambiguation, only the short names of the classes/interfaces are used. This means that there is a potential for conflict if two interfaces or classes with the same name are being used within the deployment being built. If this happens, the two class/interfaces would be treated as the same, which may or may not be the desired result. It is recommended that deployments avoid using two classes/interfaces with the same basic name in their struct declarations.


Method Summary
 java.lang.String getClassLongName(java.lang.String shortClassName)
          Return the fully qualified name of the given short message class name, or the empty string if it can't be found.
 java.lang.String[] getShortNames(java.lang.String classname)
          Given the short name of a class or interface, return the possible matching classes that could be instantiated.
 

Method Detail

getClassLongName

public java.lang.String getClassLongName(java.lang.String shortClassName)
Return the fully qualified name of the given short message class name, or the empty string if it can't be found. If there are two classes with the same short name, then this method may return either long name.


getShortNames

public java.lang.String[] getShortNames(java.lang.String classname)
Given the short name of a class or interface, return the possible matching classes that could be instantiated. If classname is null, or no matching information is available, then return null.

This method is used to resolve what possible messages a reference could refer to. So for example a "SandStructMessage" reference could hold any class that implements SandStructMessage, and a "NodeInstance" reference could hold any class that implements NodeInstance. A reference to a superclass like BaseUser could hold any classes built from structs that extend from BaseUser.