Identifying a class which is extending an abstract class

Posted by Simon A. Eugster on Stack Overflow See other posts from Stack Overflow or by Simon A. Eugster
Published on 2010-05-06T19:46:36Z Indexed on 2010/05/06 20:08 UTC
Read the original article Hit count: 180

Filed under:
|

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)?

© Stack Overflow or respective owner

Related posts about java

Related posts about best-practices