[Biojava-l] Q. change proposed in AlphabetManager

Luca.Toldo@merck.de Luca.Toldo@merck.de
Thu, 2 Aug 2001 08:06:41 +0200


Dear All,
I have just noticed that AlphabetManager requires xerces for doing
DOMParser.
I was wondering if it would be much work changing that to a more flexible
way so that one could use a DOMParser of choice.
This is for example described in
http://www.javacoffeebreak.com/books/extracts/javanutshell3rdedition/

Currently it is like that:

import org.apache.xerces.parsers.*;

instead it could be something like that

// Dynamically load a class specified by name in a config file
String classname =                     // Look up the name of the class
  config.getProperties("filterclass",  // The property name
                       "org.apache.xerces.parsers.DOMParser"); // A default

try {
  Class c = Class.forName(classname);  // Dynamically load the class
  Object o = c.newInstance();          // Dynamically instantiate it
} catch (Exception e) { /* Handle exceptions */ }

// If the class to be loaded is not in the classpath, create a custom
// class loader to load it.
// Use the config file again to specify the custom path
import java.net.URLClassLoader;
String classdir = config.getProperties("classpath");
try {
  ClassLoader loader = new URLClassLoader(new URL[] { new URL(classdir) });
  Class c = loader.loadClass(classname);
}
catch (Exception e) { /* Handle exceptions */ }


I would appreciate your line of thought ...
Regards and compliments
Luca