2 * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
3 * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 package jalview.datamodel.xdb.embl;
22 import java.io.FileReader;
23 import java.io.Reader;
24 import java.util.Vector;
26 import org.exolab.castor.mapping.Mapping;
27 import org.exolab.castor.xml.Unmarshaller;
38 public Vector getEntries()
47 public void setEntries(Vector entries)
49 this.entries = entries;
55 public Vector getErrors()
64 public void setErrors(Vector errors)
70 * Parse an EmblXML file into an EmblFile object
73 * @return parsed EmblXML or null if exceptions were raised
75 public static EmblFile getEmblFile(File file)
81 return EmblFile.getEmblFile(new FileReader(file));
84 System.err.println("Exception whilst reading EMBLfile from " + file);
85 e.printStackTrace(System.err);
90 public static EmblFile getEmblFile(Reader file)
92 EmblFile record = new EmblFile();
95 // 1. Load the mapping information from the file
96 Mapping map = new Mapping(record.getClass().getClassLoader());
97 java.net.URL url = record.getClass().getResource("/embl_mapping.xml");
100 // 2. Unmarshal the data
101 Unmarshaller unmar = new Unmarshaller(record);
104 // uncomment to DEBUG EMBLFile reading
105 if (((String) jalview.bin.Cache.getDefault(
106 jalview.bin.Cache.CASTORLOGLEVEL, "debug"))
107 .equalsIgnoreCase("DEBUG"))
108 unmar.setDebug(jalview.bin.Cache.log.isDebugEnabled());
109 } catch (Exception e)
113 unmar.setIgnoreExtraElements(true);
114 unmar.setMapping(map);
116 record = (EmblFile) unmar.unmarshal(file);
117 } catch (Exception e)
119 e.printStackTrace(System.err);
126 public static void main(String args[])
129 if (args.length == 1)
131 mf = new File(args[0]);
136 "C:\\Documents and Settings\\JimP\\workspace-3.2\\Jalview Release\\schemas\\embleRecordV1.1.xml");
138 EmblFile myfile = EmblFile.getEmblFile(mf);
139 if (myfile != null && myfile.entries != null
140 && myfile.entries.size() > 0)
141 System.out.println(myfile.entries.size() + " Records read. (" + mf