X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FAppletFormatAdapter.java;h=5f738981a3c2bd630ba45bd1306660ab5ff6fc1d;hb=99f3f01792321efb671ac7ad946efffc3a3319a4;hp=f8b809ea2a4b6cf77c608c628a2ef5ff1f7c2e80;hpb=55e2e9b22b133db8b9ff0979b0338a33081fc8fd;p=jalview.git diff --git a/src/jalview/io/AppletFormatAdapter.java b/src/jalview/io/AppletFormatAdapter.java index f8b809e..5f73898 100755 --- a/src/jalview/io/AppletFormatAdapter.java +++ b/src/jalview/io/AppletFormatAdapter.java @@ -34,6 +34,11 @@ /** DOCUMENT ME!! */ public static final Vector formats = new Vector(); + public static String INVALID_CHARACTERS = "Contains invalid characters"; + + public static String SUPPORTED_FORMATS = "Formats currently supported are\n" + + "Fasta, MSF, Clustal, BLC, PIR, MSP, and PFAM"; + static { formats.addElement("BLC"); @@ -45,6 +50,12 @@ formats.addElement("PFAM"); } + + public static String FILE = "File"; + public static String URL = "URL"; + public static String PASTE = "Paste"; + public static String CLASSLOADER = "ClassLoader"; + AlignFile afile = null; /** @@ -57,6 +68,7 @@ * @return DOCUMENT ME! */ public SequenceI[] readFile(String inFile, String type, String format) + throws java.io.IOException { try { @@ -89,6 +101,7 @@ afile = new PfamFile(inFile, type); } + return afile.getSeqsAsArray(); } catch (Exception e) @@ -96,6 +109,9 @@ System.err.println("Failed to read alignment using the '" + format + "' reader.\n"+e); + if(e.getMessage()!=null && e.getMessage().startsWith(INVALID_CHARACTERS)) + throw new java.io.IOException(e.getMessage()); + // Finally test if the user has pasted just the sequence, no id if(type.equalsIgnoreCase("Paste")) { @@ -103,16 +119,19 @@ // Possible sequence is just residues with no label afile = new FastaFile(">UNKNOWN\n" + inFile, "Paste"); return afile.getSeqsAsArray(); - }catch(Exception ex) + } + catch(Exception ex) { - System.err.println("Failed to read alignment using the 'FASTA' reader.\n"+e); + if(ex.toString().startsWith(INVALID_CHARACTERS)) + throw new java.io.IOException(e.getMessage()); + ex.printStackTrace(); } - } - } - return null; + // If we get to this stage, the format was not supported + throw new java.io.IOException(SUPPORTED_FORMATS); + } }