use new file filter
[jalview.git] / src / jalview / io / FormatFactory.java
1 package jalview.io;\r
2 \r
3 import jalview.datamodel.*;\r
4 \r
5 import java.lang.reflect.*;\r
6 \r
7 public class FormatFactory {\r
8 \r
9   public static AlignFile get(int index) {\r
10     try {\r
11       Class c = Class.forName(FormatProperties.getClassName(index));\r
12       Class [] paramTypes = new Class[1];\r
13       paramTypes[0] = SequenceI[].class;\r
14 \r
15       Constructor cons = c.getConstructor(null);\r
16 \r
17       return (AlignFile)cons.newInstance(null);\r
18     } catch (Exception e) {\r
19       System.err.println("Errore FFactory:"+e);\r
20       return null;\r
21     }\r
22   }\r
23 \r
24   public static AlignFile get(int index,String inStr) {\r
25     try {\r
26       Class c = Class.forName(FormatProperties.getClassName(index));\r
27       Class [] paramTypes = new Class[1];\r
28       paramTypes[0] = String.class;\r
29       Constructor cons = c.getConstructor(paramTypes);\r
30 \r
31       Object [] params = new Object[1];\r
32       params[0] = inStr;\r
33       return (AlignFile)cons.newInstance(params);\r
34     } catch (Exception e) {\r
35       System.err.println("error2"+e);\r
36       return null;\r
37     }\r
38   }\r
39 \r
40   public static AlignFile get(int index,String inFile,String type) {\r
41     try {\r
42 \r
43       Class c = Class.forName(FormatProperties.getClassName(index));\r
44       Class [] paramTypes = new Class[2];\r
45       paramTypes[0] = String.class;\r
46       paramTypes[1] = String.class;\r
47       Constructor cons = c.getConstructor(paramTypes);\r
48       Object [] params = new Object[2];\r
49       params[0] = inFile;\r
50       params[1] = type;\r
51 \r
52       AlignFile af = (AlignFile)cons.newInstance(params);\r
53 \r
54       return af;\r
55     } catch (Exception e) {\r
56       System.err.println("FormatFactory "+e);\r
57       return null;\r
58     }\r
59   }\r
60 \r
61   public static AlignFile get(String format) {\r
62     return get(FormatProperties.indexOf(format));\r
63   }\r
64 \r
65   public static AlignFile get(String format,String inStr) {\r
66     return get(FormatProperties.indexOf(format),inStr);\r
67   }\r
68   public static AlignFile get(String format,String inFile,String type) {\r
69     return get(FormatProperties.indexOf(format),inFile,type);\r
70   }\r
71 }\r