org.sandev.TaskHeap.util
Class AppInstanceClassEnumerator

java.lang.Object
  extended byorg.sandev.TaskHeap.util.AppInstanceClassEnumerator
All Implemented Interfaces:
org.sandev.basics.util.InstanceClassEnumerator

public class AppInstanceClassEnumerator
extends java.lang.Object
implements org.sandev.basics.util.InstanceClassEnumerator

A utility to translate from a base class or interface into possible class instances. AUTOGENERATED FILE, DO NOT EDIT DIRECTLY.
source: declared in build
generator: org.sandev.generator.InstClassEnumGenerator
time: Dec 2, 2005 6:38:50 PM

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 this class, and the methods traverse the lookup structure to return their results.

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.

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.


Field Summary
static java.lang.String[] lnClassNames
           
static java.lang.String[] nodeDecls
           
static java.lang.String[] persistMessages
           
static java.lang.String[] shClassNames
           
static java.lang.String[] structMessages
           
static java.lang.String[][] subClasses
           
 
Constructor Summary
AppInstanceClassEnumerator()
           
 
Method Summary
 java.lang.String getClassLongName(java.lang.String shortClassName)
          Return the long name of the class, given the short name.
 java.lang.String[] getShortNames(java.lang.String classname)
          Given the short name of a class or interface, return the possible matching classes which could be instantiated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

shClassNames

public static final java.lang.String[] shClassNames

lnClassNames

public static final java.lang.String[] lnClassNames

structMessages

public static final java.lang.String[] structMessages

subClasses

public static final java.lang.String[][] subClasses

persistMessages

public static final java.lang.String[] persistMessages

nodeDecls

public static final java.lang.String[] nodeDecls
Constructor Detail

AppInstanceClassEnumerator

public AppInstanceClassEnumerator()
Method Detail

getClassLongName

public java.lang.String getClassLongName(java.lang.String shortClassName)
Return the long name of the class, given the short name. At compile time, we build an array of short class names sorted alphabetically. We also create another array with the same ordering as the first, but with the long (fully qualified) names. By looking up the index of the short name, we can return long name by referencing that same index in the long names array.

Note that this only does StructMessages for now, since that is all that is curently required. This is based on the data in the static arrays.

Specified by:
getClassLongName in interface org.sandev.basics.util.InstanceClassEnumerator

getShortNames

public java.lang.String[] getShortNames(java.lang.String classname)
Given the short name of a class or interface, return the possible matching classes which could be instantiated. At compile time, we build an array of class/interface names sorted alphabetically. We also create another array containing arrays of possible classes indexed in the same order. By searching the first array we find the index for the return value lookup in the second array.

Notes:

Specified by:
getShortNames in interface org.sandev.basics.util.InstanceClassEnumerator