2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1)
3 * Copyright (C) 2014 The Jalview Authors
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/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
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