Commits

petermr committed 8dcf26d

more tidying

Comments (0)

Files changed (14)

jc-top-core/src/main/java/org/xmlcml/cml/converters/AbstractConverter.java

 import org.xmlcml.cml.base.CMLElement;
 import org.xmlcml.cml.base.CMLUtil;
 import org.xmlcml.cml.converters.MimeType.ObjectType;
-import org.xmlcml.cml.converters.registry.AbstractConverterModule;
 
 /**
  * Plumbing and IO wrangling for {@link Converter} classes - allows converter

jc-top-core/src/main/java/org/xmlcml/cml/converters/AbstractConverterModule.java

+package org.xmlcml.cml.converters;
+
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import nu.xom.Nodes;
+
+import org.apache.log4j.Logger;
+import org.xmlcml.cml.attribute.DictRefAttribute;
+import org.xmlcml.cml.base.CMLElement;
+import org.xmlcml.cml.base.CMLUtil;
+import org.xmlcml.cml.converters.registry.ConverterRegistry;
+import org.xmlcml.cml.element.CMLDictionary;
+import org.xmlcml.cml.tools.DictionaryTool;
+import org.xmlcml.euclid.Util;
+
+
+
+public abstract class AbstractConverterModule {
+
+	private static final Logger LOG = Logger.getLogger(AbstractConverterModule.class);
+	
+	private static String DICT_XML = "Dict.xml";
+	private static String NAMESPACE_ROOT = "http://www.xml-cml.org/dict/";
+	
+	protected List<Converter> converterList = null;
+	
+	protected Set<MimeType> typeSet = null;
+	protected List<MimeType> mimeTypeList = null;
+	ModuleResourceOLD moduleResource = null;
+
+	/** 
+	 * DONT by default register modules with ConverterRegistry.CONVERTER_REGISTRY
+	 * 
+	 */
+	public AbstractConverterModule() {
+//		this(ConverterRegistry.getDefaultConverterRegistry());
+	}
+	
+	private CMLDictionary dictionary;
+
+	public DictionaryTool getDictionaryTool() {
+		getDictionary();
+		return DictionaryTool.getOrCreateTool(dictionary);
+	}
+	
+	public CMLDictionary getDictionary() {
+		if (dictionary == null) {
+			String dictionaryResource = getDictionaryResource();
+			try {
+				InputStream inputStream = org.xmlcml.euclid.Util.getInputStreamFromResource(dictionaryResource);
+				CMLElement cmlElement = (CMLElement) CMLUtil.parseQuietlyIntoCML(inputStream);
+				Nodes dictionaryNodes = cmlElement.query(".//*[local-name()='dictionary']");
+				dictionary = (dictionaryNodes.size() == 1) ?
+						(CMLDictionary) dictionaryNodes.get(0) : null;
+			} catch (Exception e) {
+				throw new RuntimeException("cannot read dictionary: "+dictionaryResource, e);
+			}
+		}
+		return dictionary;
+		
+	}
+	
+	protected String getDictionaryResource() {
+		return getLocalDictionaryName();
+	}
+
+	public void addNamespaceDeclaration(CMLElement cml) {
+		cml.addNamespaceDeclaration(this.getPrefix(), this.getNamespace());
+	}
+
+	public void addDictRef(CMLElement element, String entryId, boolean checkDictionary) {
+		String dictRef = DictRefAttribute.createValue(this.getPrefix(), entryId);
+		if (checkDictionary) {
+			checkAgainstDictionary(element, dictRef);
+		}
+		element.setAttribute("dictRef", dictRef);
+	}
+	
+	private void checkAgainstDictionary(CMLElement element, String name) {
+		DictionaryTool dictionaryTool = getDictionaryTool();
+		String entryId = name.toLowerCase();
+		if (dictionaryTool != null) {
+			if (!dictionaryTool.isIdInDictionary(entryId)) {
+				LOG.warn("entryId "+entryId+" not found in dictionary: "+dictionaryTool);
+			}
+		}
+	}
+
+	public AbstractConverterModule(ConverterRegistry converterRegistry) {
+        getMimeTypeList();
+        getConverterList();
+	    typeSet = new HashSet<MimeType>();
+	    addConverterClassesAndTypes(converterRegistry);
+    }
+
+	public static String getResourceRoot(Class clazz) {
+		String packageRoot = (clazz == null) ? null :
+			clazz.getPackage().getName().replaceAll(Util.S_BACKSLASH+Util.S_PERIOD, Util.S_SLASH);
+		return packageRoot;
+	}
+	
+	protected String getResourceRoot() {
+		return getResourceRoot(this.getClass());
+	}
+	
+	
+    public abstract List<MimeType> getMimeTypeList();
+	public abstract List<Converter> getConverterList();
+	public abstract String getPrefix();
+	public String getNamespace() {
+		return NAMESPACE_ROOT+getPrefix();
+	}
+
+    public String getLocalDictionaryName() {
+    	return getResourceRoot()+getPrefix()+DICT_XML;
+    }
+
+    public String getDictionaryUrlName() {
+    	return null;
+    }
+    
+	protected void addConverterClassesAndTypes(ConverterRegistry converterRegistry) {
+		if (converterRegistry == null) {
+			throw new RuntimeException("Null converterRegistry");
+		}
+		List<Converter> converters = getConverterList();
+		for (Converter converter : converters) {
+			if (converter == null) {
+				System.err.println("trying to add null converter");
+			} else {
+				converterRegistry.add(converter);
+				typeSet.add(converter.getInputType());
+				typeSet.add(converter.getOutputType());
+			}
+		}
+	}
+
+	protected void ensureMimeTypeList() {
+		if (mimeTypeList == null) {
+			mimeTypeList = new ArrayList<MimeType>();
+		}
+	}
+
+}

jc-top-core/src/main/java/org/xmlcml/cml/converters/CoreConverterModule.java

 import java.util.List;
 
 import org.xmlcml.cml.converters.cml.CMLCommon;
-import org.xmlcml.cml.converters.registry.AbstractConverterModule;
 
 
 /**

jc-top-core/src/main/java/org/xmlcml/cml/converters/Foo2CMLConverter.java

 package org.xmlcml.cml.converters;
 
-import java.io.File;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.List;
-
 import nu.xom.Element;
 
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
-import org.xmlcml.cml.base.CMLBuilder;
-import org.xmlcml.cml.base.CMLElement;
-import org.xmlcml.cml.converters.cml.CML2CMLLiteConverter;
 import org.xmlcml.cml.converters.cml.CMLCommon;
-import org.xmlcml.cml.converters.cml.CMLLiteHelper;
 import org.xmlcml.cml.element.CMLCml;
 
 /** dummy class

jc-top-core/src/main/java/org/xmlcml/cml/converters/ModuleResourceOLD.java

+package org.xmlcml.cml.converters;
+
+import nu.xom.Element;
+import nu.xom.Nodes;
+
+import org.xmlcml.cml.base.CMLUtil;
+import org.xmlcml.euclid.Util;
+
+
+public class ModuleResourceOLD {
+	
+	/**
+<resourceList name="nwchem">
+  <prefix>nwchem</prefix>
+  <namespace>http://wwmm.ch.cam.ac.uk/dict/nwchem</namespace>
+  <typeList>
+    <type name"input" mime="chemical/x-nwchem-input" objectType="TEXT">
+      <suffix>inp</suffix>
+    </type>
+    <type name="log" mime="chemical/x-nwchem-log" objectType="TEXT">
+      <suffix>log</suffix>
+    </type>
+    <type name="logXml" mime="chemical/x-nwchem-log-xml" objectType="XML">
+      <suffix>log.xml</suffix>
+      <suffix>xml</suffix>
+    </type>
+  </typeList>
+  <dictionaryList>
+    <dictionary resource="org/xmlcml/cml/converters/compchem/nwchem/nwchemDictionary.xml"
+      url="http://no.where.yet"/>
+  </dictionaryList>
+  <converterList>
+    <converter name="org.xmlcml.cml.converters.compchem.nwchem.input.CML2NWChemInputConverter"
+      input="cml" output="input" description="converts cml to NWChem input"/>
+    <converter name="org.xmlcml.cml.converters.compchem.nwchem.log.NWChemLog2XMLConverter"
+      input="log" output="logXml" description="converts log file to xmlCml"
+      templateDir="org/xmlcml/cml/converters/compchem/nwchem/log/templates"
+      template="topTemplate.dir"/>
+    <converter name="org.xmlcml.cml.converters.compchem.nwchem.log.NWChemLog2CompchemConverter"
+      input="log" output="cml" description="converts log to comchem:CML"/>
+  </converterList>
+</resourceList>
+	 */
+	// fo
+	private static final String NAME = "name";
+	private static final String MODULE_RESOURCE = "moduleResource.xml";
+	
+	private Element moduleElement;
+	private String prefix;
+	private String namespace;
+
+    public ModuleResourceOLD() {
+    }
+
+	protected void createModuleResource() {
+		String packageName = this.getClass().getPackage().getName().replaceAll(Util.S_BACKSLASH+Util.S_PERIOD, Util.S_SLASH);
+		try {
+			moduleElement = CMLUtil.parseQuietlyToDocument(Util.getInputStreamFromResource(packageName+Util.S_SLASH+MODULE_RESOURCE)).getRootElement();
+		} catch (Exception e) {
+			throw new RuntimeException("Cannot find/read module resource", e);
+		}
+		processPrefix();
+		processNamespace();
+		processTypes();
+		processDictionaries();
+		processConverters();
+	}
+
+	/**
+  <prefix>nwchem</prefix>
+	 */
+	private void processPrefix() {
+		prefix = getStringContent("prefix");
+	}
+
+	/**
+	  <namespace>http://wwmm.ch.cam.ac.uk/dict/nwchem</namespace>
+		 */
+	private void processNamespace() {
+		namespace = getStringContent("namespace");
+	}
+
+	/**
+    <type name"input" mime="chemical/x-nwchem-input" objectType="TEXT">
+      <suffix>inp</suffix>
+    </type>
+	 */
+	private void processTypes() {
+		Nodes types = moduleElement.query("typelist/type");
+		for (int i = 0; i < types.size(); i++) {
+			Element typeElement = (Element) types.get(i);
+			MimeType type = new MimeType(typeElement);
+		}
+	}
+
+	/**
+  <dictionaryList>
+    <dictionary resource="org/xmlcml/cml/converters/compchem/nwchem/nwchemDictionary.xml"
+      url="http://no.where.yet"/>
+  </dictionaryList>
+	 */
+	private void processDictionaries() {
+		// TODO Auto-generated method stub
+		
+	}
+
+	/**
+  <converterList>
+    <converter name="org.xmlcml.cml.converters.compchem.nwchem.input.CML2NWChemInputConverter"
+      input="cml" output="input" description="converts cml to NWChem input"/>
+    <converter name="org.xmlcml.cml.converters.compchem.nwchem.log.NWChemLog2XMLConverter"
+      input="log" output="logXml" description="converts log file to xmlCml"
+      templateDir="org/xmlcml/cml/converters/compchem/nwchem/log/templates"
+      template="topTemplate.dir"/>
+    <converter name="org.xmlcml.cml.converters.compchem.nwchem.log.NWChemLog2CompchemConverter"
+      input="log" output="cml" description="converts log to comchem:CML"/>
+  </converterList>
+	 */
+	private void processConverters() {
+		// TODO Auto-generated method stub
+		
+	}
+
+	private String getStringContent(String xpath) {
+		Element element = CMLUtil.getSingleElement(moduleElement, xpath);
+		return element == null ? null : element.getValue();
+	}
+	
+}

jc-top-core/src/main/java/org/xmlcml/cml/converters/TypePair.java

+package org.xmlcml.cml.converters;
+
+import org.xmlcml.euclid.Util;
+
+public class TypePair {
+
+    private String inString;
+    private String outString;
+    private MimeType inType;
+    private MimeType outType;
+
+    public TypePair(String in, String out) {
+        this.inString = in;
+        this.outString = out;
+    }
+
+    public TypePair(MimeType inType, MimeType outType) {
+        this.inType = inType;
+        this.outType = outType;
+    }
+
+    public String getInString() {
+        return inString;
+    }
+
+    public String getOutString() {
+        return outString;
+    }
+
+    public MimeType getInType() {
+        return inType;
+    }
+
+    public MimeType 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;
+    }
+
+}

jc-top-core/src/main/java/org/xmlcml/cml/converters/cml/CML2CMLLiteConverter.java

 import org.xmlcml.cml.base.CMLBuilder;
 import org.xmlcml.cml.base.CMLElement;
 import org.xmlcml.cml.converters.AbstractConverter;
-import org.xmlcml.cml.converters.Converter;
 import org.xmlcml.cml.converters.MimeType;
 import org.xmlcml.cml.element.CMLCml;
 

jc-top-core/src/main/java/org/xmlcml/cml/converters/cml/CMLModule.java

 import java.util.ArrayList;
 import java.util.List;
 
+import org.xmlcml.cml.converters.AbstractConverterModule;
 import org.xmlcml.cml.converters.Converter;
-import org.xmlcml.cml.converters.Foo2CMLConverter;
 import org.xmlcml.cml.converters.MimeType;
 import org.xmlcml.cml.converters.MimeType.ObjectType;
-import org.xmlcml.cml.converters.registry.AbstractConverterModule;
 
 /**
  * @author Sam Adams

jc-top-core/src/main/java/org/xmlcml/cml/converters/cml/RawXML2CMLProcessor.java

 import org.xmlcml.cml.base.CMLBuilder;
 import org.xmlcml.cml.base.CMLElement;
 import org.xmlcml.cml.base.CMLUtil;
-import org.xmlcml.cml.converters.registry.AbstractConverterModule;
+import org.xmlcml.cml.converters.AbstractConverterModule;
 import org.xmlcml.cml.element.CMLProperty;
 
 /** abstract class for RawXML2CML conversion.

jc-top-core/src/main/java/org/xmlcml/cml/converters/registry/AbstractConverterModule.java

-package org.xmlcml.cml.converters.registry;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import nu.xom.Nodes;
-
-import org.apache.log4j.Logger;
-import org.xmlcml.cml.attribute.DictRefAttribute;
-import org.xmlcml.cml.base.CMLElement;
-import org.xmlcml.cml.base.CMLUtil;
-import org.xmlcml.cml.converters.Converter;
-import org.xmlcml.cml.converters.MimeType;
-import org.xmlcml.cml.element.CMLDictionary;
-import org.xmlcml.cml.tools.DictionaryTool;
-import org.xmlcml.euclid.Util;
-
-
-
-public abstract class AbstractConverterModule {
-
-	private static final Logger LOG = Logger.getLogger(AbstractConverterModule.class);
-	
-	private static String DICT_XML = "Dict.xml";
-	private static String NAMESPACE_ROOT = "http://www.xml-cml.org/dict/";
-	
-	protected List<Converter> converterList = null;
-	
-	protected Set<MimeType> typeSet = null;
-	protected List<MimeType> mimeTypeList = null;
-	ModuleResource moduleResource = null;
-
-	/** 
-	 * DONT by default register modules with ConverterRegistry.CONVERTER_REGISTRY
-	 * 
-	 */
-	public AbstractConverterModule() {
-//		this(ConverterRegistry.getDefaultConverterRegistry());
-	}
-	
-	private CMLDictionary dictionary;
-
-	public DictionaryTool getDictionaryTool() {
-		getDictionary();
-		return DictionaryTool.getOrCreateTool(dictionary);
-	}
-	
-	public CMLDictionary getDictionary() {
-		if (dictionary == null) {
-			String dictionaryResource = getDictionaryResource();
-			try {
-				InputStream inputStream = org.xmlcml.euclid.Util.getInputStreamFromResource(dictionaryResource);
-				CMLElement cmlElement = (CMLElement) CMLUtil.parseQuietlyIntoCML(inputStream);
-				Nodes dictionaryNodes = cmlElement.query(".//*[local-name()='dictionary']");
-				dictionary = (dictionaryNodes.size() == 1) ?
-						(CMLDictionary) dictionaryNodes.get(0) : null;
-			} catch (Exception e) {
-				throw new RuntimeException("cannot read dictionary: "+dictionaryResource, e);
-			}
-		}
-		return dictionary;
-		
-	}
-	
-	protected String getDictionaryResource() {
-		return getLocalDictionaryName();
-	}
-
-	public void addNamespaceDeclaration(CMLElement cml) {
-		cml.addNamespaceDeclaration(this.getPrefix(), this.getNamespace());
-	}
-
-	public void addDictRef(CMLElement element, String entryId, boolean checkDictionary) {
-		String dictRef = DictRefAttribute.createValue(this.getPrefix(), entryId);
-		if (checkDictionary) {
-			checkAgainstDictionary(element, dictRef);
-		}
-		element.setAttribute("dictRef", dictRef);
-	}
-	
-	private void checkAgainstDictionary(CMLElement element, String name) {
-		DictionaryTool dictionaryTool = getDictionaryTool();
-		String entryId = name.toLowerCase();
-		if (dictionaryTool != null) {
-			if (!dictionaryTool.isIdInDictionary(entryId)) {
-				LOG.warn("entryId "+entryId+" not found in dictionary: "+dictionaryTool);
-			}
-		}
-	}
-
-	public AbstractConverterModule(ConverterRegistry converterRegistry) {
-        getMimeTypeList();
-        getConverterList();
-	    typeSet = new HashSet<MimeType>();
-	    addConverterClassesAndTypes(converterRegistry);
-    }
-
-	public static String getResourceRoot(Class clazz) {
-		String packageRoot = (clazz == null) ? null :
-			clazz.getPackage().getName().replaceAll(Util.S_BACKSLASH+Util.S_PERIOD, Util.S_SLASH);
-		return packageRoot;
-	}
-	
-	protected String getResourceRoot() {
-		return getResourceRoot(this.getClass());
-	}
-	
-	
-    public abstract List<MimeType> getMimeTypeList();
-	public abstract List<Converter> getConverterList();
-	public abstract String getPrefix();
-	public String getNamespace() {
-		return NAMESPACE_ROOT+getPrefix();
-	}
-
-    public String getLocalDictionaryName() {
-    	return getResourceRoot()+getPrefix()+DICT_XML;
-    }
-
-    public String getDictionaryUrlName() {
-    	return null;
-    }
-    
-	protected void addConverterClassesAndTypes(ConverterRegistry converterRegistry) {
-		if (converterRegistry == null) {
-			throw new RuntimeException("Null converterRegistry");
-		}
-		List<Converter> converters = getConverterList();
-		for (Converter converter : converters) {
-			if (converter == null) {
-				System.err.println("trying to add null converter");
-			} else {
-				converterRegistry.add(converter);
-				typeSet.add(converter.getInputType());
-				typeSet.add(converter.getOutputType());
-			}
-		}
-	}
-
-	protected void ensureMimeTypeList() {
-		if (mimeTypeList == null) {
-			mimeTypeList = new ArrayList<MimeType>();
-		}
-	}
-
-}

jc-top-core/src/main/java/org/xmlcml/cml/converters/registry/ConverterRegistry.java

 
 import org.apache.commons.io.IOUtils;
 import org.apache.log4j.Logger;
+import org.xmlcml.cml.converters.AbstractConverterModule;
 import org.xmlcml.cml.converters.Converter;
 import org.xmlcml.cml.converters.MimeType;
+import org.xmlcml.cml.converters.TypePair;
 
 /**
  * @author Sam Adams
     private static ConverterRegistry CONVERTER_REGISTRY = null;
     
     protected ClassLoader classLoader;
+    protected List<AbstractConverterModule> moduleList = null;
     protected Map<TypePair, List<Converter>> converterMap = null;
     protected List<Converter> converterList = null;
     protected Set<MimeType> typeSet = null;
     protected Map<String, Set<MimeType>> typesBySuffixMap = null;
 
+	private List<Converter> totalConverterList = new ArrayList<Converter>();
+
     public static synchronized ConverterRegistry getDefaultConverterRegistry() {
     	if (CONVERTER_REGISTRY == null) {
     		CONVERTER_REGISTRY = new ConverterRegistry(ConverterRegistry.class.getClassLoader());
 
 	public void populateAndRegister() {
 		createConvertersList();
-        registerConverters();
+        registerConvertersAndMimeTypes();
 	}
 
-	public void createConvertersList() {
-		if (converterList == null) {
-	        converterList = new ArrayList<Converter>();
- 	        LOG.trace("new ArrayList:"+this.getClass());
+	public List<AbstractConverterModule> createModuleList() {
+		if (moduleList == null) {
+	        moduleList = new ArrayList<AbstractConverterModule>();
 			try {
 	            Enumeration<URL> e = classLoader.getResources(META_INF_JUMBO);
 	            List<URL> urlList = Collections.list(e);
 	            for (URL url : urlList) {
-	            	LOG.trace(url);
 	                InputStream is = url.openStream();
 	                try {
-	                    List<String> lineList = IOUtils.readLines(is);
-	                    registerModuleClasses(lineList);
+	                    List<String> moduleNameList = IOUtils.readLines(is);
+	                    getModuleList(moduleNameList, url);
 	                } finally {
 	                    IOUtils.closeQuietly(is);
 	                }
 	            e.printStackTrace();
 	        }
 		}
+		return moduleList;
 	}
 
-	private void registerModuleClasses(List<String> lineList) {
-		for (String line : lineList) {
+	private void getModuleList(List<String> moduleNameList, URL url) {
+		for (String line : moduleNameList) {
 		    line = stripComments(line);
-		    String convertersName = line.trim();
-		    if (convertersName.length() > 0) {
+		    String moduleName = line.trim();
+		    if (moduleName.length() > 0) {
 		        try {
-		        	LOG.trace("Meta-inf Name: "+convertersName+" classLoader "+classLoader);
-		            Class<?> clazz = Class.forName(convertersName);
+		        	LOG.trace("Meta-inf Name: "+moduleName+" in "+url);
+		            Class<?> clazz = Class.forName(moduleName);
 		            AbstractConverterModule converterModule = (AbstractConverterModule) clazz.newInstance();
-		            List<Converter> newConverterList = converterModule.getConverterList();
-		            for (Converter newConverter : newConverterList) {
-		            	LOG.trace(newConverter);
-		            }
-		            converterList.addAll(newConverterList);
+		            moduleList.add(converterModule);
 		        } catch (Exception ex) {
-		            LOG.error("Error loading converter: "+ex);
-		            ex.printStackTrace();
+		            System.err.println("Error loading converter: "+ex+" in "+url);
 		        }
 		    }
 		}
 	}
 	
-	private void registerConverters() {
-//		createConvertersList();
+	public List<Converter> createConvertersList() {
+		if (converterList == null) {
+	        converterList = new ArrayList<Converter>();
+	        createModuleList();
+	        for (AbstractConverterModule module : moduleList) {
+	        	List<Converter> moduleConverterList = module.getConverterList(); 
+	        	converterList.addAll(moduleConverterList);
+	        }
+		}
+		return converterList;
+	}
+
+	private void registerConvertersAndMimeTypes() {
         for (Converter converter : converterList) {
         	register(converter);
     		register(converter.getInputType());

jc-top-core/src/main/java/org/xmlcml/cml/converters/registry/ModuleResource.java

-package org.xmlcml.cml.converters.registry;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import nu.xom.Element;
-import nu.xom.Elements;
-import nu.xom.Nodes;
-
-import org.xmlcml.cml.base.CMLUtil;
-import org.xmlcml.cml.converters.Converter;
-import org.xmlcml.cml.converters.MimeType;
-import org.xmlcml.euclid.Util;
-
-
-public class ModuleResource {
-	
-	/**
-<resourceList name="nwchem">
-  <prefix>nwchem</prefix>
-  <namespace>http://wwmm.ch.cam.ac.uk/dict/nwchem</namespace>
-  <typeList>
-    <type name"input" mime="chemical/x-nwchem-input" objectType="TEXT">
-      <suffix>inp</suffix>
-    </type>
-    <type name="log" mime="chemical/x-nwchem-log" objectType="TEXT">
-      <suffix>log</suffix>
-    </type>
-    <type name="logXml" mime="chemical/x-nwchem-log-xml" objectType="XML">
-      <suffix>log.xml</suffix>
-      <suffix>xml</suffix>
-    </type>
-  </typeList>
-  <dictionaryList>
-    <dictionary resource="org/xmlcml/cml/converters/compchem/nwchem/nwchemDictionary.xml"
-      url="http://no.where.yet"/>
-  </dictionaryList>
-  <converterList>
-    <converter name="org.xmlcml.cml.converters.compchem.nwchem.input.CML2NWChemInputConverter"
-      input="cml" output="input" description="converts cml to NWChem input"/>
-    <converter name="org.xmlcml.cml.converters.compchem.nwchem.log.NWChemLog2XMLConverter"
-      input="log" output="logXml" description="converts log file to xmlCml"
-      templateDir="org/xmlcml/cml/converters/compchem/nwchem/log/templates"
-      template="topTemplate.dir"/>
-    <converter name="org.xmlcml.cml.converters.compchem.nwchem.log.NWChemLog2CompchemConverter"
-      input="log" output="cml" description="converts log to comchem:CML"/>
-  </converterList>
-</resourceList>
-	 */
-	// fo
-	private static final String NAME = "name";
-	private static final String MODULE_RESOURCE = "moduleResource.xml";
-	
-	private Element moduleElement;
-	private String prefix;
-	private String namespace;
-
-    public ModuleResource() {
-    }
-
-	protected void createModuleResource() {
-		String packageName = this.getClass().getPackage().getName().replaceAll(Util.S_BACKSLASH+Util.S_PERIOD, Util.S_SLASH);
-		try {
-			moduleElement = CMLUtil.parseQuietlyToDocument(Util.getInputStreamFromResource(packageName+Util.S_SLASH+MODULE_RESOURCE)).getRootElement();
-		} catch (Exception e) {
-			throw new RuntimeException("Cannot find/read module resource", e);
-		}
-		processPrefix();
-		processNamespace();
-		processTypes();
-		processDictionaries();
-		processConverters();
-	}
-
-	/**
-  <prefix>nwchem</prefix>
-	 */
-	private void processPrefix() {
-		prefix = getStringContent("prefix");
-	}
-
-	/**
-	  <namespace>http://wwmm.ch.cam.ac.uk/dict/nwchem</namespace>
-		 */
-	private void processNamespace() {
-		namespace = getStringContent("namespace");
-	}
-
-	/**
-    <type name"input" mime="chemical/x-nwchem-input" objectType="TEXT">
-      <suffix>inp</suffix>
-    </type>
-	 */
-	private void processTypes() {
-		Nodes types = moduleElement.query("typelist/type");
-		for (int i = 0; i < types.size(); i++) {
-			Element typeElement = (Element) types.get(i);
-			MimeType type = new MimeType(typeElement);
-		}
-	}
-
-	/**
-  <dictionaryList>
-    <dictionary resource="org/xmlcml/cml/converters/compchem/nwchem/nwchemDictionary.xml"
-      url="http://no.where.yet"/>
-  </dictionaryList>
-	 */
-	private void processDictionaries() {
-		// TODO Auto-generated method stub
-		
-	}
-
-	/**
-  <converterList>
-    <converter name="org.xmlcml.cml.converters.compchem.nwchem.input.CML2NWChemInputConverter"
-      input="cml" output="input" description="converts cml to NWChem input"/>
-    <converter name="org.xmlcml.cml.converters.compchem.nwchem.log.NWChemLog2XMLConverter"
-      input="log" output="logXml" description="converts log file to xmlCml"
-      templateDir="org/xmlcml/cml/converters/compchem/nwchem/log/templates"
-      template="topTemplate.dir"/>
-    <converter name="org.xmlcml.cml.converters.compchem.nwchem.log.NWChemLog2CompchemConverter"
-      input="log" output="cml" description="converts log to comchem:CML"/>
-  </converterList>
-	 */
-	private void processConverters() {
-		// TODO Auto-generated method stub
-		
-	}
-
-	private String getStringContent(String xpath) {
-		Element element = CMLUtil.getSingleElement(moduleElement, xpath);
-		return element == null ? null : element.getValue();
-	}
-	
-}

jc-top-core/src/main/java/org/xmlcml/cml/converters/registry/TypePair.java

-package org.xmlcml.cml.converters.registry;
-
-import org.xmlcml.cml.converters.MimeType;
-import org.xmlcml.euclid.Util;
-
-public class TypePair {
-
-    private String inString;
-    private String outString;
-    private MimeType inType;
-    private MimeType outType;
-
-    public TypePair(String in, String out) {
-        this.inString = in;
-        this.outString = out;
-    }
-
-    public TypePair(MimeType inType, MimeType outType) {
-        this.inType = inType;
-        this.outType = outType;
-    }
-
-    public String getInString() {
-        return inString;
-    }
-
-    public String getOutString() {
-        return outString;
-    }
-
-    public MimeType getInType() {
-        return inType;
-    }
-
-    public MimeType 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;
-    }
-
-}

jc-top-core/src/test/java/org/xmlcml/cml/converters/registry/ConverterRegistryTest.java

 import org.junit.Test;
 import org.xmlcml.cml.converters.Converter;
 import org.xmlcml.cml.converters.MimeType;
+import org.xmlcml.cml.converters.TypePair;
 import org.xmlcml.cml.converters.cml.CML2CMLLiteConverter;
 import org.xmlcml.cml.converters.cml.CMLCommon;