package jalview.io; import jalview.datamodel.*; import java.lang.reflect.*; public class FormatFactory { public static AlignFile get(int index) { try { Class c = Class.forName(FormatProperties.getClassName(index)); Class [] paramTypes = new Class[1]; paramTypes[0] = SequenceI[].class; Constructor cons = c.getConstructor(null); return (AlignFile)cons.newInstance(null); } catch (Exception e) { System.err.println("Errore FFactory:"+e); return null; } } public static AlignFile get(int index,String inStr) { try { Class c = Class.forName(FormatProperties.getClassName(index)); Class [] paramTypes = new Class[1]; paramTypes[0] = String.class; Constructor cons = c.getConstructor(paramTypes); Object [] params = new Object[1]; params[0] = inStr; return (AlignFile)cons.newInstance(params); } catch (Exception e) { System.err.println("error2"+e); return null; } } public static AlignFile get(int index,String inFile,String type) { try { Class c = Class.forName(FormatProperties.getClassName(index)); Class [] paramTypes = new Class[2]; paramTypes[0] = String.class; paramTypes[1] = String.class; Constructor cons = c.getConstructor(paramTypes); Object [] params = new Object[2]; params[0] = inFile; params[1] = type; AlignFile af = (AlignFile)cons.newInstance(params); return af; } catch (Exception e) { System.err.println("FormatFactory "+e); return null; } } public static AlignFile get(String format) { return get(FormatProperties.indexOf(format)); } public static AlignFile get(String format,String inStr) { return get(FormatProperties.indexOf(format),inStr); } public static AlignFile get(String format,String inFile,String type) { return get(FormatProperties.indexOf(format),inFile,type); } }