Commits

petermr committed f48cc21

added TypePair and refactor ConverterRegistry

Comments (0)

Files changed (27)

jumbo-converters-chemdraw/src/main/java/org/xmlcml/cml/converters/chemdraw/ChemdrawConverters.java

 import java.util.List;
 
 import org.xmlcml.cml.converters.Converter;
-import org.xmlcml.cml.converters.registry.ConverterAndTypeLists;
+import org.xmlcml.cml.converters.registry.AbstractConverters;
 
 /**
  * @author Sam Adams
  */
-public class ChemdrawConverters extends ConverterAndTypeLists {
+public class ChemdrawConverters extends AbstractConverters {
 
 	private static List<Converter> converterList = new ArrayList<Converter>();
 	static {

jumbo-converters-cif/src/main/java/org/xmlcml/cml/converters/cif/CIFConverters.java

 import java.util.List;
 
 import org.xmlcml.cml.converters.Converter;
-import org.xmlcml.cml.converters.registry.ConverterAndTypeLists;
+import org.xmlcml.cml.converters.registry.AbstractConverters;
 
 /**
  * @author Sam Adams
  */
-public class CIFConverters extends ConverterAndTypeLists {
+public class CIFConverters extends AbstractConverters {
 
 	private static List<Converter> converterList = new ArrayList<Converter>();
 	static {

jumbo-converters-cli/src/main/java/org/xmlcml/cml/converters/cli/ConverterCli.java

 
             Converter converter = null;
             try {
-            	converter = ConverterRegistry.findConverter(intype, outtype);
+            	converter = ConverterRegistry.findSingleConverter(intype, outtype);
             } catch (Exception e) {
             	System.err.println("cannot find converter for: "+Util.concatenate(args, " "));
             	System.exit(0);

jumbo-converters-cli/src/main/java/org/xmlcml/cml/converters/cli/ConverterRegistry.java

 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
+import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.commons.io.IOUtils;
 import org.xmlcml.cml.converters.Converter;
 import org.xmlcml.cml.converters.Type;
-import org.xmlcml.cml.converters.registry.ConverterAndTypeLists;
+import org.xmlcml.cml.converters.registry.AbstractConverters;
 
 /**
  * @author Sam Adams
 
     public static final String CONVERTER_FILE = "META-INF/jumbo-converters";
 
-    private static final Map<TypePair,Converter> converterMap = new LinkedHashMap<TypePair, Converter>();
+    
+    private static final Map<TypePair, List<Converter>> converterMap = 
+    		new LinkedHashMap<TypePair, List<Converter>>();
+    private static List<Converter> converterList = new ArrayList<Converter>();
+    private static Set<Type> typeSet = new HashSet<Type>();
+    
+    static {
+        createConvertersList();
+        registerConverters();
+    }
 
-    static {
-        try {
+	private static void createConvertersList() {
+        converterList = new ArrayList<Converter>();
+		try {
         	ClassLoader ldr = ConverterRegistry.class.getClassLoader();
 
             Enumeration<URL> e = ldr.getResources(CONVERTER_FILE);
-            long time = System.currentTimeMillis();
             for (URL url : Collections.list(e)) {
-                System.err.println("reading "+url);
                 InputStream is = url.openStream();
-                
                 try {
                     for (String line : IOUtils.readLines(is)) {
-                        int comment = line.indexOf('#');
-                        if (comment >= 0) {
-                            line = line.substring(0, comment);
-                        }
+                        line = stripComments(line);
                         String convertersName = line.trim();
                         if (convertersName.length() > 0) {
                             try {
                                 Class<?> clazz = Class.forName(convertersName);
-                                ConverterAndTypeLists converterAndTypeLists = (ConverterAndTypeLists) clazz.newInstance();
-                                for (Converter converter : converterAndTypeLists.getConverterList()) {
-                                	System.out.println("reg "+converter);
-                                    register(converter);
-                                }
+                                AbstractConverters converterAndTypeLists = (AbstractConverters) clazz.newInstance();
+                                converterList.addAll(converterAndTypeLists.getConverterList());
                             } catch (Exception ex) {
-                                System.err.println("Error loading converter");
+                                System.err.println("Error loading converter: "+ex);
                                 ex.printStackTrace();
                             }
                         }
             System.err.println("Error loading converter files");
             e.printStackTrace();
         }
-    }
+	}
+	private static void registerConverters() {
+        for (Converter converter : converterList) {
+        	register(converter);
+    		register(converter.getInputType());
+    		register(converter.getOutputType());
+        }
+	}
+
+	private static String stripComments(String line) {
+		int comment = line.indexOf('#');
+		if (comment >= 0) {
+		    line = line.substring(0, comment);
+		}
+		return line.trim();
+	}
     
-    public static Map<TypePair,Converter> getMap() {
+    public static Map<TypePair, List<Converter>> getMap() {
     	return converterMap;
     }
 
 
-    public static Converter findConverter(String intype, String outtype) {
+    public static List<Converter> findConverters(String intype, String outtype) {
         TypePair t = new TypePair(intype, outtype);
-        Converter info = converterMap.get(t);
-        return info;
+        List<Converter> converterList = converterMap.get(t);
+        return converterList;
     }
 
+    public static Converter findSingleConverter(String intype, String outtype) {
+    	List<Converter> converterList = findConverters(intype, outtype);
+    	return (converterList == null || converterList.size() != 1) ? null : converterList.get(0);
+    }
+
+    public static List<Converter> findConverters(Type intype, Type outtype) {
+    	return findConverters(intype.toString(), outtype.toString());
+    }
+
 
     public static List<Converter> getConverterList() {
-        return new ArrayList<Converter>(converterMap.values());
+        return converterList;
     }
 
     private static synchronized void register(Converter converter) {
         Type outtype = converter.getOutputType();
         if (intype != null && outtype != null) {
 	        TypePair t = new TypePair(intype.toString(), outtype.toString());
-	        System.out.println("putting type: "+t);
-	        converterMap.put(t, converter);
+	        List<Converter> list = converterMap.get(t);
+	        if (list == null) {
+	        	list = new ArrayList<Converter>();
+	        	converterMap.put(t,  list);
+	        }
+	        list.add(converter);
         } else {
         	System.out.println("NULL types for "+converter.getClass()+" ("+intype+", "+outtype+")");
         }
     }
 
-
-    public static class TypePair {
-
-        private final String in, out;
-
-        TypePair(String in, String out) {
-            this.in = in;
-            this.out = out;
-        }
-
-        public String getIn() {
-            return in;
-        }
-
-        public String getOut() {
-            return out;
-        }
-
-        @Override
-        public boolean equals(Object o) {
-            if (this == o) {
-                return true;
-            }
-            if (o instanceof TypePair) {
-                TypePair t = (TypePair) o;
-                return (this.in == null || t.in == null || this.out == null || t.out == null) ? false : this.in.equals(t.in) && this.out.equals(t.out);
-            }
-            return false;
-        }
-
-        @Override
-        public int hashCode() {
-            int inhash = (in != null) ? in.hashCode()*31 : 137;
-            int outhash = (out != null) ? out.hashCode() : 0;
-            return inhash + outhash;
-        }
-
-        public String toString() {
-            return in + " >> " + out;
-        }
-
+    private static synchronized void register(Type type) {
+    	typeSet.add(type);
     }
 
 }

jumbo-converters-cli/src/main/java/org/xmlcml/cml/converters/cli/TypePair.java

+package org.xmlcml.cml.converters.cli;
+
+import org.xmlcml.cml.converters.Type;
+import org.xmlcml.euclid.Util;
+
+public class TypePair {
+
+    private String inString;
+    private String outString;
+    private Type inType;
+    private Type outType;
+
+    TypePair(String in, String out) {
+        this.inString = in;
+        this.outString = out;
+    }
+
+    TypePair(Type inType, Type outType) {
+        this.inType = inType;
+        this.outType = outType;
+    }
+
+    public String getInString() {
+        return inString;
+    }
+
+    public String getOutString() {
+        return outString;
+    }
+
+    public Type getInType() {
+        return inType;
+    }
+
+    public Type getOutType() {
+        return outType;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o instanceof TypePair) {
+            TypePair t = (TypePair) o;
+            return (this.inString == null || t.inString == null || this.outString == null || t.outString == null) ? false :
+            	this.inString.equals(t.inString) && this.outString.equals(t.outString);
+        }
+        return false;
+    }
+
+    @Override
+    public int hashCode() {
+        int inhash = (inString != null) ? inString.hashCode()*31 : 137;
+        int outhash = (outString != null) ? outString.hashCode() : 0;
+        return inhash + outhash;
+    }
+
+    public String toString() {
+        return Util.S_LSQUARE+inString + Util.S_PIPE + outString+Util.S_RSQUARE;
+    }
+
+}

jumbo-converters-cli/src/test/java/org/xmlcml/cml/converters/cli/ConverterRegistryTest.java

 
 	@Test
 	public void testFindFoo2BarConverter() {
-		Converter converter = ConverterRegistry.findConverter("foo", "bar");
-		assertNull(converter);
+		List<Converter> converterList = ConverterRegistry.findConverters("foo", "bar");
+		assertNull(converterList);
 	}
 
 }

jumbo-converters-cli/src/test/java/org/xmlcml/cml/converters/cli/TestConverterRegistry.java

 import java.util.Map;
 
 import org.junit.Assert;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.xmlcml.cml.converters.Converter;
+import org.xmlcml.cml.converters.chemdraw.CDX2CDXMLConverter;
+import org.xmlcml.cml.converters.cml.CML2CMLLiteConverter;
 import org.xmlcml.cml.converters.compchem.gaussian.log.GaussianLog2XMLConverter;
 
 public class TestConverterRegistry {
 
+	String CML = "chemical/x-cml";
+	String CDX = "chemical/x-cdx";
+	String CDXML = "chemical/x-cdxml";
+	TypePair PAIR_OK  = new TypePair(CDX, CDXML);
+	TypePair PAIR_MISSING  = new TypePair(CDXML, CDX);
+	
 	@Test
 	public void dummy() {
 	}
     @Test
 //    @Ignore
     public void testMap() {
-    	Map<ConverterRegistry.TypePair,Converter> map = ConverterRegistry.getMap();
+    	Map<TypePair, List<Converter>> map = ConverterRegistry.getMap();
     	Assert.assertNotNull(map);
     	// size will change as more are added
-    	Assert.assertTrue(map.size() > 0);
+    	Assert.assertTrue(map.size() > 10);
     }
 
     @Test
-//    @Ignore
     public void testList() {
-    	List<Converter> list = ConverterRegistry.getConverterList();
-    	Assert.assertNotNull(list);
-    	Assert.assertTrue(list.size() > 0);
-    	// size will change as more are added
-//    	Assert.assertEquals("list size", 11, list.size());
-    	for (Converter info : list) {
-    		System.out.println(info);
+    	List<Converter> converterList = ConverterRegistry.getConverterList();
+    	Assert.assertNotNull(converterList);
+    	Assert.assertTrue(converterList.size() > 10);
+    }
+
+    @Test
+    public void testList1() {
+    	List<Converter> converterList = ConverterRegistry.getConverterList();
+    	boolean found = false;
+    	for (Converter converter : converterList) {
+    		if (CML2CMLLiteConverter.class.equals(converter.getClass())) {
+    			found = true;
+    			break;
+    		}
+    	}
+    	Assert.assertTrue("converter", found);
+    }
+
+    @Test
+    public void testMap1() {
+    	Map<TypePair, List<Converter>> map = ConverterRegistry.getMap();
+    	Assert.assertTrue(map.containsKey(PAIR_OK));
+    	Assert.assertFalse(map.containsKey(PAIR_MISSING));
+    	for (TypePair typePair1 : map.keySet()) {
+    		System.out.println(typePair1);
     	}
     }
 
     @Test
-    @Ignore
     public void testFindConverter() {
-    	Converter converter = ConverterRegistry.findConverter("gaussian_log", "gaussian_log_xml");
-    	Assert.assertNotNull("gaussian", converter);
-    	Assert.assertEquals("gaussian", GaussianLog2XMLConverter.class, converter.getClass());
+    	List<Converter> converters = ConverterRegistry.findConverters(CDX, CDXML);
+    	Assert.assertNotNull("cdx", converters);
+    	Assert.assertEquals("cdx", 1, converters.size());
+    	Assert.assertEquals("cdx", CDX2CDXMLConverter.class, converters.get(0).getClass());
     }
 
     @Test
     public void testFindConverter1() {
-    	Converter converter = ConverterRegistry.findConverter("gaussian_log", "gaussian_xml_cml");
-    	Assert.assertNull("gaussian", converter);
+    	List<Converter> converters = ConverterRegistry.findConverters(CML, CML);
+    	Assert.assertNotNull("cml", converters);
+    	Assert.assertEquals("cml", 2, converters.size());
+    	for (Converter converter : converters) {
+    		System.out.println(converter);
+    	}
     }
+
 }

jumbo-converters-compchem/jumbo-converters-compchem-amber/src/main/java/org/xmlcml/cml/converters/compchem/amber/AmberConverters.java

 import org.xmlcml.cml.converters.Converter;
 import org.xmlcml.cml.converters.compchem.amber.in.AmberFF2XMLConverter;
 import org.xmlcml.cml.converters.compchem.amber.in.AmberFFXML2CMLConverter;
-import org.xmlcml.cml.converters.registry.ConverterAndTypeLists;
+import org.xmlcml.cml.converters.registry.AbstractConverters;
 
 /**
  * @author Sam Adams
  */
-public class AmberConverters extends ConverterAndTypeLists {
+public class AmberConverters extends AbstractConverters {
 
 	private static List<Converter> converterList = new ArrayList<Converter>();
 	static {

jumbo-converters-compchem/jumbo-converters-compchem-dalton/src/main/java/org/xmlcml/cml/converters/compchem/dalton/DaltonConverters.java

 
 import org.xmlcml.cml.converters.Converter;
 import org.xmlcml.cml.converters.compchem.dalton.log.DaltonLog2XMLConverter;
-import org.xmlcml.cml.converters.registry.ConverterAndTypeLists;
+import org.xmlcml.cml.converters.registry.AbstractConverters;
 
 /**
  * @author Sam Adams
  */
-public class DaltonConverters extends ConverterAndTypeLists {
+public class DaltonConverters extends AbstractConverters {
 
 	private static List<Converter> converterList = new ArrayList<Converter>();
 	static {

jumbo-converters-compchem/jumbo-converters-compchem-dlpoly/src/main/java/org/xmlcml/cml/converters/compchem/dlpoly/DLPolyConverters.java

 import org.xmlcml.cml.converters.Converter;
 import org.xmlcml.cml.converters.compchem.dlpoly.config.DLPolyConfig2CMLConverter;
 import org.xmlcml.cml.converters.compchem.dlpoly.log.DLPolyLog2XMLConverter;
-import org.xmlcml.cml.converters.registry.ConverterAndTypeLists;
+import org.xmlcml.cml.converters.registry.AbstractConverters;
 
 /**
  * @author pm286
  */
-public class DLPolyConverters extends ConverterAndTypeLists {
+public class DLPolyConverters extends AbstractConverters {
 
 	private static List<Converter> converterList = new ArrayList<Converter>();
 	static {

jumbo-converters-compchem/jumbo-converters-compchem-dummy/src/main/java/org/xmlcml/cml/converters/compchem/dummy/DummyConverters.java

 import org.xmlcml.cml.converters.Converter;
 import org.xmlcml.cml.converters.compchem.dummy.log.DummyLog2XMLConverter;
 import org.xmlcml.cml.converters.compchem.dummy.mol.DummyMol2CMLConverter;
-import org.xmlcml.cml.converters.registry.ConverterAndTypeLists;
+import org.xmlcml.cml.converters.registry.AbstractConverters;
 
 /**
  * @author pm286
  */
-public class DummyConverters extends ConverterAndTypeLists {
+public class DummyConverters extends AbstractConverters {
 
 	private static List<Converter> converterList = new ArrayList<Converter>();
 	static {

jumbo-converters-compchem/jumbo-converters-compchem-gamessuk/src/main/java/org/xmlcml/cml/converters/compchem/gamessuk/GamessUKXConverters.java

 import org.xmlcml.cml.converters.Converter;
 import org.xmlcml.cml.converters.compchem.gamessuk.log.GamessUKXLog2XMLConverter;
 import org.xmlcml.cml.converters.compchem.gamessuk.punch.GamessUKXPunchXML2CMLConverter;
-import org.xmlcml.cml.converters.registry.ConverterAndTypeLists;
+import org.xmlcml.cml.converters.registry.AbstractConverters;
 
 /**
  * @author Sam Adams
  */
-public class GamessUKXConverters extends ConverterAndTypeLists {
+public class GamessUKXConverters extends AbstractConverters {
 
 	private static List<Converter> converterList = new ArrayList<Converter>();
 	static {

jumbo-converters-compchem/jumbo-converters-compchem-gamessus/src/main/java/org/xmlcml/cml/converters/compchem/gamessus/GamessUSXConverters.java

 
 import org.xmlcml.cml.converters.Converter;
 import org.xmlcml.cml.converters.compchem.gamessus.log.GamessUSXLog2XMLConverter;
-import org.xmlcml.cml.converters.registry.ConverterAndTypeLists;
+import org.xmlcml.cml.converters.registry.AbstractConverters;
 
 /**
  * @author Sam Adams
  */
-public class GamessUSXConverters extends ConverterAndTypeLists {
+public class GamessUSXConverters extends AbstractConverters {
 
 	private static List<Converter> converterList = new ArrayList<Converter>();
 	static {

jumbo-converters-compchem/jumbo-converters-compchem-gaussian/src/main/java/org/xmlcml/cml/converters/compchem/gaussian/GaussianConverters.java

 
 import org.xmlcml.cml.converters.Converter;
 import org.xmlcml.cml.converters.compchem.gaussian.log.GaussianLog2XMLConverter;
-import org.xmlcml.cml.converters.registry.ConverterAndTypeLists;
+import org.xmlcml.cml.converters.registry.AbstractConverters;
 
 /**
  * @author Sam Adams
  */
-public class GaussianConverters extends ConverterAndTypeLists {
+public class GaussianConverters extends AbstractConverters {
 
 	private static List<Converter> converterList = new ArrayList<Converter>();
 	static {

jumbo-converters-compchem/jumbo-converters-compchem-jaguar/src/main/java/org/xmlcml/cml/converters/compchem/jaguar/JaguarConverters.java

 
 import org.xmlcml.cml.converters.Converter;
 import org.xmlcml.cml.converters.compchem.jaguar.log.JaguarLog2XMLConverter;
-import org.xmlcml.cml.converters.registry.ConverterAndTypeLists;
+import org.xmlcml.cml.converters.registry.AbstractConverters;
 
 /**
  * @author PeterMR
  */
-public class JaguarConverters extends ConverterAndTypeLists {
+public class JaguarConverters extends AbstractConverters {
 
 	private static List<Converter> converterList = new ArrayList<Converter>();
 	static {

jumbo-converters-compchem/jumbo-converters-compchem-molcas/src/main/java/org/xmlcml/cml/converters/compchem/molcas/MolcasConverters.java

 
 import org.xmlcml.cml.converters.Converter;
 import org.xmlcml.cml.converters.compchem.molcas.log.MolcasLog2XMLConverter;
-import org.xmlcml.cml.converters.registry.ConverterAndTypeLists;
+import org.xmlcml.cml.converters.registry.AbstractConverters;
 
 /**
  * @author Sam Adams
  */
-public class MolcasConverters extends ConverterAndTypeLists {
+public class MolcasConverters extends AbstractConverters {
 
 	private static List<Converter> converterList = new ArrayList<Converter>();
 	static {

jumbo-converters-compchem/jumbo-converters-compchem-mopac/src/main/java/org/xmlcml/cml/converters/compchem/mopac/MopacConverters.java

 
 import org.xmlcml.cml.converters.Converter;
 import org.xmlcml.cml.converters.compchem.mopac.auxx.MopacAux2XMLConverter;
-import org.xmlcml.cml.converters.registry.ConverterAndTypeLists;
+import org.xmlcml.cml.converters.registry.AbstractConverters;
 
 /**
  * @author Sam Adams
  */
-public class MopacConverters extends ConverterAndTypeLists {
+public class MopacConverters extends AbstractConverters {
 
 	private static List<Converter> converterList = new ArrayList<Converter>();
 	static {

jumbo-converters-compchem/jumbo-converters-compchem-nwchem/src/main/java/org/xmlcml/cml/converters/compchem/nwchem/NWChemConverters.java

 import org.xmlcml.cml.converters.Converter;
 import org.xmlcml.cml.converters.compchem.nwchem.log.NWChemLog2CompchemConverter;
 import org.xmlcml.cml.converters.compchem.nwchem.log.NWChemLog2XMLConverter;
-import org.xmlcml.cml.converters.registry.ConverterAndTypeLists;
+import org.xmlcml.cml.converters.registry.AbstractConverters;
 
 /**
  * @author Sam Adams
  */
-public class NWChemConverters extends ConverterAndTypeLists {
+public class NWChemConverters extends AbstractConverters {
 
 	private static List<Converter> converterList = new ArrayList<Converter>();
 	static {

jumbo-converters-compchem/jumbo-converters-compchem-qespresso/src/main/java/org/xmlcml/cml/converters/compchem/qespresso/QespressoConverters.java

 
 import org.xmlcml.cml.converters.Converter;
 import org.xmlcml.cml.converters.compchem.qespresso.log.QuantumEspressoLog2XMLConverter;
-import org.xmlcml.cml.converters.registry.ConverterAndTypeLists;
+import org.xmlcml.cml.converters.registry.AbstractConverters;
 
 /**
  * @author Sam Adams
  */
-public class QespressoConverters extends ConverterAndTypeLists {
+public class QespressoConverters extends AbstractConverters {
 
 	private static List<Converter> converterList = new ArrayList<Converter>();
 	static {

jumbo-converters-compchem/jumbo-converters-compchem-turbomole/src/main/java/org/xmlcml/cml/converters/compchem/turbomole/TurbomoleConverters.java

 
 import org.xmlcml.cml.converters.Converter;
 import org.xmlcml.cml.converters.compchem.turbomole.log.TurbomoleLog2XMLConverter;
-import org.xmlcml.cml.converters.registry.ConverterAndTypeLists;
+import org.xmlcml.cml.converters.registry.AbstractConverters;
 
 /**
  * @author Sam Adams
  */
-public class TurbomoleConverters extends ConverterAndTypeLists {
+public class TurbomoleConverters extends AbstractConverters {
 
 	private static List<Converter> converterList = new ArrayList<Converter>();
 	static {

jumbo-converters-core/src/main/java/org/xmlcml/cml/converters/Converters.java

 import java.util.List;
 
 import org.xmlcml.cml.converters.cml.CML2CMLLiteConverter;
-import org.xmlcml.cml.converters.registry.ConverterAndTypeLists;
+import org.xmlcml.cml.converters.registry.AbstractConverters;
 
 /**
  * @author Sam Adams
  */
-public class Converters extends ConverterAndTypeLists {
+public class Converters extends AbstractConverters {
 
 	private static List<Converter> converterList = new ArrayList<Converter>();
 	static {

jumbo-converters-core/src/main/java/org/xmlcml/cml/converters/Type.java

 		Type type = (extension == null) ? null : getTypeForExtension(extension);
 		return (type == null) ? null : type.getDefaultExtension();
 	}
+	
 }

jumbo-converters-core/src/main/java/org/xmlcml/cml/converters/registry/AbstractConverters.java

+package org.xmlcml.cml.converters.registry;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.xmlcml.cml.converters.Converter;
+import org.xmlcml.cml.converters.Type;
+
+
+public abstract class AbstractConverters {
+	
+	protected List<Converter> converterList = null;
+	protected Set<Type> typeSet = null;
+
+    public AbstractConverters() {
+	    converterList = new ArrayList<Converter>();
+	    typeSet = new HashSet<Type>();
+	    addConverterClassesAndTypes();
+    }
+
+	public List<Converter> getConverterList() {
+		return converterList;
+	}
+
+	public Set<Type> getTypeSet() {
+		return typeSet;
+	}
+	
+	public List<Converter> createConverterList() {
+		System.err.println("Should override createConverterList for "+this.getClass());
+		return new ArrayList<Converter>();
+	}
+
+	protected void addConverterClassesAndTypes() {
+		List<Converter> converters = createConverterList();
+		for (Converter converter : converters) {
+			converterList.add(converter);
+			typeSet.add(converter.getInputType());
+			typeSet.add(converter.getOutputType());
+		}
+	}
+
+}

jumbo-converters-core/src/main/java/org/xmlcml/cml/converters/registry/ConverterAndTypeLists.java

-package org.xmlcml.cml.converters.registry;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.xmlcml.cml.converters.Converter;
-import org.xmlcml.cml.converters.Type;
-
-
-public abstract class ConverterAndTypeLists {
-	
-	protected List<Converter> converterList = null;
-	protected Set<Type> typeSet = null;
-
-    public ConverterAndTypeLists() {
-	    converterList = new ArrayList<Converter>();
-	    typeSet = new HashSet<Type>();
-	    addConverterClassesAndTypes();
-    }
-
-	public List<Converter> getConverterList() {
-		return converterList;
-	}
-
-	public Set<Type> getTypeSet() {
-		return typeSet;
-	}
-	
-	public List<Converter> createConverterList() {
-		System.err.println("Should override createConverterList for "+this.getClass());
-		return new ArrayList<Converter>();
-	}
-
-	protected void addConverterClassesAndTypes() {
-		List<Converter> converters = createConverterList();
-    	long time = System.currentTimeMillis();
-		for (Converter converter : converters) {
-			converterList.add(converter);
-			typeSet.add(converter.getInputType());
-			typeSet.add(converter.getOutputType());
-		}
-	}
-
-}

jumbo-converters-molecule/src/main/java/org/xmlcml/cml/converters/molecule/MoleculeConverters.java

 import org.xmlcml.cml.converters.molecule.pubchem.PubchemXML2CMLConverter;
 import org.xmlcml.cml.converters.molecule.xyz.CML2XYZConverter;
 import org.xmlcml.cml.converters.molecule.xyz.XYZ2CMLConverter;
-import org.xmlcml.cml.converters.registry.ConverterAndTypeLists;
+import org.xmlcml.cml.converters.registry.AbstractConverters;
 
 /**
  * @author Sam Adams
  */
-public class MoleculeConverters extends ConverterAndTypeLists {
+public class MoleculeConverters extends AbstractConverters {
 
 	private static List<Converter> converterList = new ArrayList<Converter>();
 	static {

jumbo-converters-reaction/src/main/java/org/xmlcml/cml/converters/reaction/ReactionConverters.java

 import java.util.List;
 
 import org.xmlcml.cml.converters.Converter;
-import org.xmlcml.cml.converters.registry.ConverterAndTypeLists;
+import org.xmlcml.cml.converters.registry.AbstractConverters;
 
 /**
  * @author Sam Adams
  */
-public class ReactionConverters extends ConverterAndTypeLists {
+public class ReactionConverters extends AbstractConverters {
 
 	private static List<Converter> converterList = new ArrayList<Converter>();
 	static {

jumbo-converters-spectrum/src/main/java/org/xmlcml/cml/converters/spectrum/SpectrumConverters.java

 import java.util.List;
 
 import org.xmlcml.cml.converters.Converter;
-import org.xmlcml.cml.converters.registry.ConverterAndTypeLists;
+import org.xmlcml.cml.converters.registry.AbstractConverters;
 import org.xmlcml.cml.converters.spectrum.jdx.cml2jdx.CMLSpect2JDXConverter;
 import org.xmlcml.cml.converters.spectrum.jdx.jdx2cml.JDX2CMLConverter;
 import org.xmlcml.cml.converters.spectrum.oscar.OSCAR2CMLSpectConverter;
 /**
  * @author Sam Adams
  */
-public class SpectrumConverters extends ConverterAndTypeLists {
+public class SpectrumConverters extends AbstractConverters {
 
 	private static List<Converter> converterList = new ArrayList<Converter>();
 	static {