2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
3 * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.datamodel.xdb.embl;
21 import java.io.FileReader;
22 import java.io.Reader;
23 import java.util.Vector;
25 import org.exolab.castor.mapping.Mapping;
26 import org.exolab.castor.xml.Unmarshaller;
37 public Vector getEntries()
46 public void setEntries(Vector entries)
48 this.entries = entries;
54 public Vector getErrors()
63 public void setErrors(Vector errors)
69 * Parse an EmblXML file into an EmblFile object
72 * @return parsed EmblXML or null if exceptions were raised
74 public static EmblFile getEmblFile(File file)
80 return EmblFile.getEmblFile(new FileReader(file));
83 System.err.println("Exception whilst reading EMBLfile from " + file);
84 e.printStackTrace(System.err);
89 public static EmblFile getEmblFile(Reader file)
91 EmblFile record = new EmblFile();
94 // 1. Load the mapping information from the file
95 Mapping map = new Mapping(record.getClass().getClassLoader());
96 java.net.URL url = record.getClass().getResource("/embl_mapping.xml");
99 // 2. Unmarshal the data
100 Unmarshaller unmar = new Unmarshaller(record);
103 // uncomment to DEBUG EMBLFile reading
104 if (((String) jalview.bin.Cache.getDefault(
105 jalview.bin.Cache.CASTORLOGLEVEL, "debug"))
106 .equalsIgnoreCase("DEBUG"))
107 unmar.setDebug(jalview.bin.Cache.log.isDebugEnabled());
108 } catch (Exception e)
112 unmar.setIgnoreExtraElements(true);
113 unmar.setMapping(map);
115 record = (EmblFile) unmar.unmarshal(file);
116 } catch (Exception e)
118 e.printStackTrace(System.err);
125 public static void main(String args[])
128 if (args.length == 1)
130 mf = new File(args[0]);
135 "C:\\Documents and Settings\\JimP\\workspace-3.2\\Jalview Release\\schemas\\embleRecordV1.1.xml");
137 EmblFile myfile = EmblFile.getEmblFile(mf);
138 if (myfile != null && myfile.entries != null
139 && myfile.entries.size() > 0)
140 System.out.println(myfile.entries.size() + " Records read. (" + mf