Identifying a class which is extending an abstract class
- by Simon A. Eugster
Good Evening,
I'm doing a major refactoring of http://wiki2xhtml.sourceforge.net/ to finally get better overview and maintainability. (I started the project when I decided to start programming, so – you get it, right? ;))
At the moment I wonder how to solve the problem I'll describe now:
Every file will be put through several parsers (like one for links, one for tables, one for images, etc.):
public class WikiLinks extends WikiTask { ... }
public class WikiTables extends WikiTask { ... }
The files will then be parsed about this way:
public void parse() {
if (!parse) return;
WikiTask task = new WikiLinks();
do {
task.parse(this);
} while ((task = task.nextTask()) != null);
}
Sometimes I may want to use no parser at all (for files that only need to be copied), or only a chosen one (e.g. for testing purposes). So before running task.parse() I need to check whether this certain parser is actually necessary/desired. (Perhaps via Blacklist or Whitelist.)
What would you suggest for comparing? An ID for each WikiTask (how to do?)? Comparing the task Object itself against a new instance of a WikiTask (overhead)?