This looks like some kind of Abstract Factory Pattern.
You first need to define the 'contract' for your handler via some interface such as
public interface Handler {
void handle(final File file);
}
You then need to define the different handlers; XMLHandler
, PropertiesHandler
, etc..
Now you need a Factory to give you a handler instance from a file extension (say), its interface may look like
public interface HandlerFactory {
Handler newHandler(final String fileName);
}
Now you just need implementations for all that - for example the HandlerFactory
could read extension->Class associations from a properties file or some such.