X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2Fxdb%2Fembl%2FEmblFile.java;h=54aab8bae651de0d8b9e7ceaaf3da0b77029d716;hb=c19d2a91ca05e052e3408bf5852d88eb5d0608f1;hp=f69011c6b9065c02e36e7495c433bb2fcda1c02d;hpb=ab43013b7e357b84b4abade0dba949668dfb2a0e;p=jalview.git diff --git a/src/jalview/datamodel/xdb/embl/EmblFile.java b/src/jalview/datamodel/xdb/embl/EmblFile.java index f69011c..54aab8b 100644 --- a/src/jalview/datamodel/xdb/embl/EmblFile.java +++ b/src/jalview/datamodel/xdb/embl/EmblFile.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2b1) - * Copyright (C) 2014 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b2) + * Copyright (C) 2015 The Jalview Authors * * This file is part of Jalview. * @@ -22,22 +22,31 @@ package jalview.datamodel.xdb.embl; import java.io.File; import java.io.FileReader; +import java.io.PrintWriter; import java.io.Reader; import java.util.Vector; import org.exolab.castor.mapping.Mapping; import org.exolab.castor.xml.Unmarshaller; +/** + * Data model for entries returned from an EMBL query, as marshalled by a Castor + * binding file + * + * For example: http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/embl/x53828/emblxml + * + * @see embl_mapping.xml + */ public class EmblFile { - Vector entries; + Vector entries; - Vector errors; + Vector errors; /** * @return the entries */ - public Vector getEntries() + public Vector getEntries() { return entries; } @@ -46,7 +55,7 @@ public class EmblFile * @param entries * the entries to set */ - public void setEntries(Vector entries) + public void setEntries(Vector entries) { this.entries = entries; } @@ -54,7 +63,7 @@ public class EmblFile /** * @return the errors */ - public Vector getErrors() + public Vector getErrors() { return errors; } @@ -63,7 +72,7 @@ public class EmblFile * @param errors * the errors to set */ - public void setErrors(Vector errors) + public void setErrors(Vector errors) { this.errors = errors; } @@ -77,7 +86,9 @@ public class EmblFile public static EmblFile getEmblFile(File file) { if (file == null) + { return null; + } try { return EmblFile.getEmblFile(new FileReader(file)); @@ -96,6 +107,7 @@ public class EmblFile { // 1. Load the mapping information from the file Mapping map = new Mapping(record.getClass().getClassLoader()); + java.net.URL url = record.getClass().getResource("/embl_mapping.xml"); map.loadMapping(url); @@ -104,17 +116,18 @@ public class EmblFile try { // uncomment to DEBUG EMBLFile reading - if (((String) jalview.bin.Cache.getDefault( - jalview.bin.Cache.CASTORLOGLEVEL, "debug")) - .equalsIgnoreCase("DEBUG")) + if (jalview.bin.Cache.getDefault(jalview.bin.Cache.CASTORLOGLEVEL, + "debug").equalsIgnoreCase("DEBUG")) + { unmar.setDebug(jalview.bin.Cache.log.isDebugEnabled()); + } } catch (Exception e) { } - ; unmar.setIgnoreExtraElements(true); + unmar.setIgnoreExtraAttributes(true); unmar.setMapping(map); - + unmar.setLogWriter(new PrintWriter(System.out)); record = (EmblFile) unmar.unmarshal(file); } catch (Exception e) { @@ -124,23 +137,4 @@ public class EmblFile return record; } - - public static void main(String args[]) - { - File mf = null; - if (args.length == 1) - { - mf = new File(args[0]); - } - if (!mf.exists()) - { - mf = new File( - "C:\\Documents and Settings\\JimP\\workspace-3.2\\Jalview Release\\schemas\\embleRecordV1.1.xml"); - } - EmblFile myfile = EmblFile.getEmblFile(mf); - if (myfile != null && myfile.entries != null - && myfile.entries.size() > 0) - System.out.println(myfile.entries.size() + " Records read. (" + mf - + ")"); - } }