[Biojava-l] proposal: application subclassing of biosql objects

David Scott david at autohandle.com
Wed Jun 21 15:50:35 UTC 2006


install a static Map in RichObjectFactory that the application can use 
to map application subclasses of the biosql classes contained in the 
RichObjectFactory code - applications would set up the map via:

public final static void setApplicationClass(final Class 
theBioJavaClass, final Class theApplicationClass)

RichObjectFactory would retrieve the Map via:

private final static class getApplicationClass(final Class 
theBioJavaClass);

RichObjectFactory would substitute the application class for the biojava 
class in getObject:

public static synchronized Object getObject(final Class clazz, Object[] 
params) {
   List paramsList = Arrays.asList(params);
   final Class applicationClass = getApplicationClass(clazz);
   ....
   .... builder.buildObject(applicationClass, paramsList);

BioSqlRichObjectBuilder would recognize the subclass in buildObject by 
changing the if statements from identity:

public Object buildObject(Clazz clazz, List paramsList) {
   if (clazz == SimpleNamespace.class) {
   ...

to assignable:

public Object buildObject(Clazz clazz, List paramsList) {
   if (SimpleNamespace.class.isAssignableFrom(clazz)) {
   ...

the map size will be short - a linear search might be faster than a hash.




More information about the Biojava-l mailing list