From 0c124ba807b8a16f4119df64cb11734ed8e4ac1b Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Fri, 16 Apr 2010 17:38:31 +0200 Subject: Use static initializers correctly (I had forgotten the "static" keyword!). --- org/madore/damlengine/TodoAttr.java | 5 +---- org/madore/damlengine/TodoElement.java | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) (limited to 'org') diff --git a/org/madore/damlengine/TodoAttr.java b/org/madore/damlengine/TodoAttr.java index b9cb800..2b3df23 100644 --- a/org/madore/damlengine/TodoAttr.java +++ b/org/madore/damlengine/TodoAttr.java @@ -11,8 +11,7 @@ public abstract class TodoAttr extends TodoItem { protected static Map> damlAttrConstructors; - protected static void initializeDamlAttrConstructors() { - // FIXME: this should be a static initializer, but for some reason does not work... + static { damlAttrConstructors = new HashMap>(); Class[] argTypes = new Class[]{ Attr.class, Element.class, Map.class, Map.class }; try { @@ -40,8 +39,6 @@ public abstract class TodoAttr extends TodoItem { Map options) { Constructor constructor = null; String nsuri = attr.getNamespaceURI(); - if ( damlAttrConstructors == null ) - initializeDamlAttrConstructors(); // FIXME: see above if ( nsuri != null && nsuri.equals(DamlEngine.DAML_NS) ) constructor = damlAttrConstructors.get(attr.getLocalName()); if ( constructor != null ) diff --git a/org/madore/damlengine/TodoElement.java b/org/madore/damlengine/TodoElement.java index f8dcca1..a069b36 100644 --- a/org/madore/damlengine/TodoElement.java +++ b/org/madore/damlengine/TodoElement.java @@ -10,8 +10,7 @@ public abstract class TodoElement extends TodoItem { protected static Map> damlConstructors; - protected static void initializeDamlConstructors() { - // FIXME: this should be a static initializer, but for some reason does not work... + static { damlConstructors = new HashMap>(); } @@ -30,8 +29,6 @@ public abstract class TodoElement extends TodoItem { Map options) { Constructor constructor = null; String nsuri = node.getNamespaceURI(); - if ( damlConstructors == null ) - initializeDamlConstructors(); // FIXME: see above if ( nsuri != null && nsuri.equals(DamlEngine.DAML_NS) ) constructor = damlConstructors.get(node.getLocalName()); if ( constructor != null ) -- cgit v1.2.3