X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FAppletFormatAdapter.java;h=00fcb9c39c598d12dc6d285b5b9720bb080ba129;hb=f41806761ec9086c852941a7f91c890190fb522a;hp=6db04a09a546dfa26f902ca1967bc12a2198e5d5;hpb=26b115b0a77d521da92a06572d9b7819c2d0d49a;p=jalview.git diff --git a/src/jalview/io/AppletFormatAdapter.java b/src/jalview/io/AppletFormatAdapter.java index 6db04a0..00fcb9c 100755 --- a/src/jalview/io/AppletFormatAdapter.java +++ b/src/jalview/io/AppletFormatAdapter.java @@ -20,6 +20,8 @@ */ package jalview.io; +import java.util.Locale; + import jalview.api.AlignExportSettingsI; import jalview.api.AlignmentViewPanel; import jalview.datamodel.Alignment; @@ -152,14 +154,17 @@ public class AppletFormatAdapter { return readFile(null, file, sourceType, fileFormat); } - - public AlignmentI readFile(File selectedFile, String file, DataSourceType sourceType, - FileFormatI fileFormat) throws IOException + + public AlignmentI readFile(File selectedFile, String file, + DataSourceType sourceType, FileFormatI fileFormat) + throws IOException { this.selectedFile = selectedFile; if (selectedFile != null) + { this.inFile = selectedFile.getPath(); + } this.inFile = file; try { @@ -175,7 +180,8 @@ public class AppletFormatAdapter if (isParseWithJMOL) { // needs a File option - alignFile = new JmolParser(selectedFile == null ? inFile : selectedFile, sourceType); + alignFile = new JmolParser( + selectedFile == null ? inFile : selectedFile, sourceType); } else { @@ -188,9 +194,12 @@ public class AppletFormatAdapter ((StructureFile) alignFile).setDbRefType( FileFormat.PDB.equals(fileFormat) ? Type.PDB : Type.MMCIF); } - else if (selectedFile != null) { - alignFile = fileFormat.getReader(new FileParse(selectedFile, sourceType)); - } else + else if (selectedFile != null) + { + alignFile = fileFormat + .getReader(new FileParse(selectedFile, sourceType)); + } + else { // alignFile = fileFormat.getAlignmentFile(inFile, sourceType); alignFile = fileFormat.getReader(new FileParse(inFile, sourceType)); @@ -422,24 +431,26 @@ public class AppletFormatAdapter return null; } - /** * Determines the protocol (i.e DataSourceType.{FILE|PASTE|URL}) for the input * data * * BH 2018 allows File or String, and can return RELATIVE_URL * - * @param dataObject File or String + * @param dataObject + * File or String * @return the protocol for the input data */ public static DataSourceType checkProtocol(Object dataObject) { - if(dataObject instanceof File) + if (dataObject instanceof File) + { return DataSourceType.FILE; - + } + String data = dataObject.toString(); DataSourceType protocol = DataSourceType.PASTE; - String ft = data.toLowerCase().trim(); + String ft = data.toLowerCase(Locale.ROOT).trim(); if (ft.indexOf("http:") == 0 || ft.indexOf("https:") == 0 || ft.indexOf("file:") == 0) { @@ -456,6 +467,10 @@ public class AppletFormatAdapter return protocol; } + /** + * @param args + * @j2sIgnore + */ public static void main(String[] args) { int i = 0;