M
mike
Hi,
I cannot get my registration of parser to work. When try to make a
call to get the registered parser:
PullParserFactory.instance().createParser(type);
I get a NullPointerException. When I debug I can see that the HashMap
is empty.
What am I missing?
br,
//mike
public class FindBugsParser implements AbstractPullParser{
// Register with Factory
static {
PullParserFactory.instance().registerParser(PluginImpl.FINDBUGS,
new FindBugsParser());
}
public AbstractPullParser createParser() {
return new FindBugsParser();
}
}
public final class PullParserFactory {
/**
* Single instance created upon class loading.
*/
private static PullParserFactory INSTANCE = new PullParserFactory();
private static final HashMap<String, AbstractPullParser>
registeredParsers = new HashMap<String, AbstractPullParser>();
//no outside access.
private PullParserFactory() {
}
public static PullParserFactory instance() {
return INSTANCE;
}
public void registerParser(String type, AbstractPullParser parser) {
registeredParsers.put(type, parser);
}
public AbstractPullParser createParser(String type) {
return (AbstractPullParser) registeredParsers.get(type);
}
}
I cannot get my registration of parser to work. When try to make a
call to get the registered parser:
PullParserFactory.instance().createParser(type);
I get a NullPointerException. When I debug I can see that the HashMap
is empty.
What am I missing?
br,
//mike
public class FindBugsParser implements AbstractPullParser{
// Register with Factory
static {
PullParserFactory.instance().registerParser(PluginImpl.FINDBUGS,
new FindBugsParser());
}
public AbstractPullParser createParser() {
return new FindBugsParser();
}
}
public final class PullParserFactory {
/**
* Single instance created upon class loading.
*/
private static PullParserFactory INSTANCE = new PullParserFactory();
private static final HashMap<String, AbstractPullParser>
registeredParsers = new HashMap<String, AbstractPullParser>();
//no outside access.
private PullParserFactory() {
}
public static PullParserFactory instance() {
return INSTANCE;
}
public void registerParser(String type, AbstractPullParser parser) {
registeredParsers.put(type, parser);
}
public AbstractPullParser createParser(String type) {
return (AbstractPullParser) registeredParsers.get(type);
}
}