Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / jalview / io / FileParse.js
index 5b2c791..37e85d9 100644 (file)
-Clazz.declarePackage ("jalview.io");\r
-Clazz.load (null, "jalview.io.FileParse", ["jalview.io.AppletFormatAdapter", "jalview.util.MessageManager", "java.io.BufferedReader", "$.IOException", "$.InputStreamReader", "$.StringReader", "java.lang.Error", "java.net.URL", "java.util.zip.GZIPInputStream"], function () {\r
-c$ = Clazz.decorateAsClass (function () {\r
-this.dataName = "unknown source";\r
-this.inFile = null;\r
-this.viewport = null;\r
-this.exportSettings = null;\r
-this.index = 1;\r
-this.suffixSeparator = '#';\r
-this.newline = null;\r
-this.suffix = null;\r
-this.type = null;\r
-this.dataIn = null;\r
-this.errormessage = "UNITIALISED SOURCE";\r
-this.error = true;\r
-this.warningMessage = null;\r
-this.READAHEAD_LIMIT = 2048;\r
-Clazz.instantialize (this, arguments);\r
-}, jalview.io, "FileParse");\r
-Clazz.prepareFields (c$, function () {\r
-this.newline = System.getProperty ("line.separator");\r
-});\r
-Clazz.defineMethod (c$, "setNewlineString", \r
-function (nl) {\r
-this.newline = nl;\r
-}, "~S");\r
-Clazz.defineMethod (c$, "getNewlineString", \r
-function () {\r
-return this.newline;\r
-});\r
-Clazz.makeConstructor (c$, \r
-function () {\r
-});\r
-Clazz.makeConstructor (c$, \r
-function (from) {\r
-if (from == null) {\r
-throw  new Error (jalview.util.MessageManager.getString ("error.implementation_error_null_fileparse"));\r
-}if (from === this) {\r
-return;\r
-}this.index = ++from.index;\r
-this.inFile = from.inFile;\r
-this.suffixSeparator = from.suffixSeparator;\r
-this.suffix = from.suffix;\r
-this.errormessage = from.errormessage;\r
-this.error = false;\r
-this.type = from.type;\r
-this.dataIn = from.dataIn;\r
-if (this.dataIn != null) {\r
-this.mark ();\r
-}this.dataName = from.dataName;\r
-}, "jalview.io.FileParse");\r
-Clazz.defineMethod (c$, "tryAsGzipSource", \r
- function (inputStream) {\r
-var inData =  new java.io.BufferedReader ( new java.io.InputStreamReader ( new java.util.zip.GZIPInputStream (inputStream)));\r
-inData.mark (2048);\r
-inData.read ();\r
-inData.reset ();\r
-return inData;\r
-}, "java.io.InputStream");\r
-Clazz.defineMethod (c$, "checkURLSource", \r
- function (fileStr) {\r
-this.errormessage = "URL NOT FOUND";\r
-var url =  new java.net.URL (fileStr);\r
-var e = null;\r
-if (fileStr.toLowerCase ().endsWith (".gz")) {\r
-try {\r
-var inputStream = url.openStream ();\r
-this.dataIn = this.tryAsGzipSource (inputStream);\r
-this.dataName = fileStr;\r
-return false;\r
-} catch (ex) {\r
-if (Clazz.exceptionOf (ex, Exception)) {\r
-e = ex;\r
-} else {\r
-throw ex;\r
-}\r
-}\r
-}try {\r
-this.dataIn =  new java.io.BufferedReader ( new java.io.InputStreamReader (url.openStream ()));\r
-} catch (q) {\r
-if (Clazz.exceptionOf (q, java.io.IOException)) {\r
-if (e != null) {\r
-throw  new java.io.IOException (jalview.util.MessageManager.getString ("exception.failed_to_resolve_gzip_stream"), e);\r
-}throw q;\r
-} else {\r
-throw q;\r
-}\r
-}\r
-this.dataName = fileStr;\r
-return false;\r
-}, "~S");\r
-Clazz.defineMethod (c$, "extractSuffix", \r
- function (fileStr) {\r
-var sfpos = fileStr.lastIndexOf (this.suffixSeparator);\r
-if (sfpos > -1 && sfpos < fileStr.length - 1) {\r
-this.suffix = fileStr.substring (sfpos + 1);\r
-return fileStr.substring (0, sfpos);\r
-}return null;\r
-}, "~S");\r
-Clazz.makeConstructor (c$, \r
-function (fileStr, type) {\r
-this.type = type;\r
-this.error = false;\r
-if (type.equals (jalview.io.AppletFormatAdapter.FILE)) {\r
-{\r
-}} else if (type.equals (jalview.io.AppletFormatAdapter.URL)) {\r
-try {\r
-try {\r
-this.checkURLSource (fileStr);\r
-if (this.suffixSeparator == '#') {\r
-this.extractSuffix (fileStr);\r
-}} catch (e) {\r
-if (Clazz.exceptionOf (e, java.io.IOException)) {\r
-var suffixLess = this.extractSuffix (fileStr);\r
-if (suffixLess == null) {\r
-throw (e);\r
-} else {\r
-try {\r
-this.checkURLSource (suffixLess);\r
-} catch (e2) {\r
-if (Clazz.exceptionOf (e2, java.io.IOException)) {\r
-this.errormessage = "BAD URL WITH OR WITHOUT SUFFIX";\r
-throw (e);\r
-} else {\r
-throw e2;\r
-}\r
-}\r
-}} else {\r
-throw e;\r
-}\r
-}\r
-} catch (e) {\r
-if (Clazz.exceptionOf (e, Exception)) {\r
-this.errormessage = "CANNOT ACCESS DATA AT URL '" + fileStr + "' (" + e.getMessage () + ")";\r
-this.error = true;\r
-} else {\r
-throw e;\r
-}\r
-}\r
-} else if (type.equals (jalview.io.AppletFormatAdapter.PASTE)) {\r
-this.errormessage = "PASTE INACCESSIBLE!";\r
-this.dataIn =  new java.io.BufferedReader ( new java.io.StringReader (fileStr));\r
-this.dataName = "Paste";\r
-} else if (type.equals (jalview.io.AppletFormatAdapter.CLASSLOADER)) {\r
-this.errormessage = "RESOURCE CANNOT BE LOCATED";\r
-var is = this.getClass ().getResourceAsStream ("/" + fileStr);\r
-if (is == null) {\r
-var suffixLess = this.extractSuffix (fileStr);\r
-if (suffixLess != null) {\r
-is = this.getClass ().getResourceAsStream ("/" + suffixLess);\r
-}}if (is != null) {\r
-this.dataIn =  new java.io.BufferedReader ( new java.io.InputStreamReader (is));\r
-this.dataName = fileStr;\r
-} else {\r
-this.error = true;\r
-}} else {\r
-this.errormessage = "PROBABLE IMPLEMENTATION ERROR : Datasource Type given as '" + (type != null ? type : "null") + "'";\r
-this.error = true;\r
-}if (this.dataIn == null || this.error) {\r
-throw  new java.io.IOException (jalview.util.MessageManager.formatMessage ("exception.failed_to_read_data_from_source",  Clazz.newArray (-1, [this.errormessage])));\r
-}this.error = false;\r
-this.dataIn.mark (2048);\r
-}, "~S,~S");\r
-Clazz.defineMethod (c$, "mark", \r
-function () {\r
-if (this.dataIn != null) {\r
-this.dataIn.mark (2048);\r
-} else {\r
-throw  new java.io.IOException (jalview.util.MessageManager.getString ("exception.no_init_source_stream"));\r
-}});\r
-Clazz.defineMethod (c$, "nextLine", \r
-function () {\r
-if (!this.error) {\r
-return this.dataIn.readLine ();\r
-}throw  new java.io.IOException (jalview.util.MessageManager.formatMessage ("exception.invalid_source_stream",  Clazz.newArray (-1, [this.errormessage])));\r
-});\r
-Clazz.defineMethod (c$, "isExporting", \r
-function () {\r
-return !this.error && this.dataIn == null;\r
-});\r
-Clazz.defineMethod (c$, "isValid", \r
-function () {\r
-return !this.error;\r
-});\r
-Clazz.defineMethod (c$, "close", \r
-function () {\r
-this.errormessage = "EXCEPTION ON CLOSE";\r
-this.error = true;\r
-this.dataIn.close ();\r
-this.dataIn = null;\r
-this.errormessage = "SOURCE IS CLOSED";\r
-});\r
-Clazz.defineMethod (c$, "reset", \r
-function () {\r
-if (this.dataIn != null && !this.error) {\r
-this.dataIn.reset ();\r
-} else {\r
-throw  new java.io.IOException (jalview.util.MessageManager.getString ("error.implementation_error_reset_called_for_invalid_source"));\r
-}});\r
-Clazz.defineMethod (c$, "hasWarningMessage", \r
-function () {\r
-return (this.warningMessage != null && this.warningMessage.length > 0);\r
-});\r
-Clazz.defineMethod (c$, "getWarningMessage", \r
-function () {\r
-return this.warningMessage;\r
-});\r
-Clazz.defineMethod (c$, "getInFile", \r
-function () {\r
-if (this.inFile != null) {\r
-return this.inFile.getAbsolutePath () + " (" + this.index + ")";\r
-} else {\r
-return "From Paste + (" + this.index + ")";\r
-}});\r
-Clazz.defineMethod (c$, "getDataName", \r
-function () {\r
-return this.dataName;\r
-});\r
-Clazz.defineMethod (c$, "setDataName", \r
-function (dataname) {\r
-this.dataName = dataname;\r
-}, "~S");\r
-Clazz.defineMethod (c$, "getReader", \r
-function () {\r
-if (this.dataIn != null) {\r
-return this.dataIn;\r
-}return null;\r
-});\r
-Clazz.defineMethod (c$, "getViewport", \r
-function () {\r
-return this.viewport;\r
-});\r
-Clazz.defineMethod (c$, "setViewport", \r
-function (viewport) {\r
-this.viewport = viewport;\r
-}, "jalview.api.AlignViewportI");\r
-Clazz.defineMethod (c$, "getExportSettings", \r
-function () {\r
-return this.exportSettings;\r
-});\r
-Clazz.defineMethod (c$, "setExportSettings", \r
-function (exportSettings) {\r
-this.exportSettings = exportSettings;\r
-}, "jalview.api.AlignExportSettingI");\r
-Clazz.defineMethod (c$, "configureForView", \r
-function (avpanel) {\r
-if (avpanel != null) {\r
-this.setViewport (avpanel.getAlignViewport ());\r
-}}, "jalview.api.AlignmentViewPanel");\r
-});\r
+Clazz.declarePackage ("jalview.io");
+Clazz.load (null, "jalview.io.FileParse", ["jalview.io.AppletFormatAdapter", "jalview.util.MessageManager", "java.io.BufferedReader", "$.IOException", "$.InputStreamReader", "$.StringReader", "java.lang.Error", "java.net.URL", "java.util.zip.GZIPInputStream"], function () {
+c$ = Clazz.decorateAsClass (function () {
+this.dataName = "unknown source";
+this.inFile = null;
+this.viewport = null;
+this.exportSettings = null;
+this.index = 1;
+this.suffixSeparator = '#';
+this.newline = null;
+this.suffix = null;
+this.type = null;
+this.dataIn = null;
+this.errormessage = "UNITIALISED SOURCE";
+this.error = true;
+this.warningMessage = null;
+this.READAHEAD_LIMIT = 2048;
+Clazz.instantialize (this, arguments);
+}, jalview.io, "FileParse");
+Clazz.prepareFields (c$, function () {
+this.newline = System.getProperty ("line.separator");
+});
+Clazz.defineMethod (c$, "setNewlineString", 
+function (nl) {
+this.newline = nl;
+}, "~S");
+Clazz.defineMethod (c$, "getNewlineString", 
+function () {
+return this.newline;
+});
+Clazz.makeConstructor (c$, 
+function () {
+});
+Clazz.makeConstructor (c$, 
+function (from) {
+if (from == null) {
+throw  new Error (jalview.util.MessageManager.getString ("error.implementation_error_null_fileparse"));
+}if (from === this) {
+return;
+}this.index = ++from.index;
+this.inFile = from.inFile;
+this.suffixSeparator = from.suffixSeparator;
+this.suffix = from.suffix;
+this.errormessage = from.errormessage;
+this.error = false;
+this.type = from.type;
+this.dataIn = from.dataIn;
+if (this.dataIn != null) {
+this.mark ();
+}this.dataName = from.dataName;
+}, "jalview.io.FileParse");
+Clazz.defineMethod (c$, "tryAsGzipSource", 
+ function (inputStream) {
+var inData =  new java.io.BufferedReader ( new java.io.InputStreamReader ( new java.util.zip.GZIPInputStream (inputStream)));
+inData.mark (2048);
+inData.read ();
+inData.reset ();
+return inData;
+}, "java.io.InputStream");
+Clazz.defineMethod (c$, "checkURLSource", 
+ function (fileStr) {
+this.errormessage = "URL NOT FOUND";
+var url =  new java.net.URL (fileStr);
+var e = null;
+if (fileStr.toLowerCase ().endsWith (".gz")) {
+try {
+var inputStream = url.openStream ();
+this.dataIn = this.tryAsGzipSource (inputStream);
+this.dataName = fileStr;
+return false;
+} catch (ex) {
+if (Clazz.exceptionOf (ex, Exception)) {
+e = ex;
+} else {
+throw ex;
+}
+}
+}try {
+this.dataIn =  new java.io.BufferedReader ( new java.io.InputStreamReader (url.openStream ()));
+} catch (q) {
+if (Clazz.exceptionOf (q, java.io.IOException)) {
+if (e != null) {
+throw  new java.io.IOException (jalview.util.MessageManager.getString ("exception.failed_to_resolve_gzip_stream"), e);
+}throw q;
+} else {
+throw q;
+}
+}
+this.dataName = fileStr;
+return false;
+}, "~S");
+Clazz.defineMethod (c$, "extractSuffix", 
+ function (fileStr) {
+var sfpos = fileStr.lastIndexOf (this.suffixSeparator);
+if (sfpos > -1 && sfpos < fileStr.length - 1) {
+this.suffix = fileStr.substring (sfpos + 1);
+return fileStr.substring (0, sfpos);
+}return null;
+}, "~S");
+Clazz.makeConstructor (c$, 
+function (fileStr, type) {
+this.type = type;
+this.error = false;
+if (type.equals (jalview.io.AppletFormatAdapter.FILE)) {
+{
+}} else if (type.equals (jalview.io.AppletFormatAdapter.URL)) {
+try {
+try {
+this.checkURLSource (fileStr);
+if (this.suffixSeparator == '#') {
+this.extractSuffix (fileStr);
+}} catch (e) {
+if (Clazz.exceptionOf (e, java.io.IOException)) {
+var suffixLess = this.extractSuffix (fileStr);
+if (suffixLess == null) {
+throw (e);
+} else {
+try {
+this.checkURLSource (suffixLess);
+} catch (e2) {
+if (Clazz.exceptionOf (e2, java.io.IOException)) {
+this.errormessage = "BAD URL WITH OR WITHOUT SUFFIX";
+throw (e);
+} else {
+throw e2;
+}
+}
+}} else {
+throw e;
+}
+}
+} catch (e) {
+if (Clazz.exceptionOf (e, Exception)) {
+this.errormessage = "CANNOT ACCESS DATA AT URL '" + fileStr + "' (" + e.getMessage () + ")";
+this.error = true;
+} else {
+throw e;
+}
+}
+} else if (type.equals (jalview.io.AppletFormatAdapter.PASTE)) {
+this.errormessage = "PASTE INACCESSIBLE!";
+this.dataIn =  new java.io.BufferedReader ( new java.io.StringReader (fileStr));
+this.dataName = "Paste";
+} else if (type.equals (jalview.io.AppletFormatAdapter.CLASSLOADER)) {
+this.errormessage = "RESOURCE CANNOT BE LOCATED";
+var is = this.getClass ().getResourceAsStream ("/" + fileStr);
+if (is == null) {
+var suffixLess = this.extractSuffix (fileStr);
+if (suffixLess != null) {
+is = this.getClass ().getResourceAsStream ("/" + suffixLess);
+}}if (is != null) {
+this.dataIn =  new java.io.BufferedReader ( new java.io.InputStreamReader (is));
+this.dataName = fileStr;
+} else {
+this.error = true;
+}} else {
+this.errormessage = "PROBABLE IMPLEMENTATION ERROR : Datasource Type given as '" + (type != null ? type : "null") + "'";
+this.error = true;
+}if (this.dataIn == null || this.error) {
+throw  new java.io.IOException (jalview.util.MessageManager.formatMessage ("exception.failed_to_read_data_from_source",  Clazz.newArray (-1, [this.errormessage])));
+}this.error = false;
+this.dataIn.mark (2048);
+}, "~S,~S");
+Clazz.defineMethod (c$, "mark", 
+function () {
+if (this.dataIn != null) {
+this.dataIn.mark (2048);
+} else {
+throw  new java.io.IOException (jalview.util.MessageManager.getString ("exception.no_init_source_stream"));
+}});
+Clazz.defineMethod (c$, "nextLine", 
+function () {
+if (!this.error) {
+return this.dataIn.readLine ();
+}throw  new java.io.IOException (jalview.util.MessageManager.formatMessage ("exception.invalid_source_stream",  Clazz.newArray (-1, [this.errormessage])));
+});
+Clazz.defineMethod (c$, "isExporting", 
+function () {
+return !this.error && this.dataIn == null;
+});
+Clazz.defineMethod (c$, "isValid", 
+function () {
+return !this.error;
+});
+Clazz.defineMethod (c$, "close", 
+function () {
+this.errormessage = "EXCEPTION ON CLOSE";
+this.error = true;
+this.dataIn.close ();
+this.dataIn = null;
+this.errormessage = "SOURCE IS CLOSED";
+});
+Clazz.defineMethod (c$, "reset", 
+function () {
+if (this.dataIn != null && !this.error) {
+this.dataIn.reset ();
+} else {
+throw  new java.io.IOException (jalview.util.MessageManager.getString ("error.implementation_error_reset_called_for_invalid_source"));
+}});
+Clazz.defineMethod (c$, "hasWarningMessage", 
+function () {
+return (this.warningMessage != null && this.warningMessage.length > 0);
+});
+Clazz.defineMethod (c$, "getWarningMessage", 
+function () {
+return this.warningMessage;
+});
+Clazz.defineMethod (c$, "getInFile", 
+function () {
+if (this.inFile != null) {
+return this.inFile.getAbsolutePath () + " (" + this.index + ")";
+} else {
+return "From Paste + (" + this.index + ")";
+}});
+Clazz.defineMethod (c$, "getDataName", 
+function () {
+return this.dataName;
+});
+Clazz.defineMethod (c$, "setDataName", 
+function (dataname) {
+this.dataName = dataname;
+}, "~S");
+Clazz.defineMethod (c$, "getReader", 
+function () {
+if (this.dataIn != null) {
+return this.dataIn;
+}return null;
+});
+Clazz.defineMethod (c$, "getViewport", 
+function () {
+return this.viewport;
+});
+Clazz.defineMethod (c$, "setViewport", 
+function (viewport) {
+this.viewport = viewport;
+}, "jalview.api.AlignViewportI");
+Clazz.defineMethod (c$, "getExportSettings", 
+function () {
+return this.exportSettings;
+});
+Clazz.defineMethod (c$, "setExportSettings", 
+function (exportSettings) {
+this.exportSettings = exportSettings;
+}, "jalview.api.AlignExportSettingI");
+Clazz.defineMethod (c$, "configureForView", 
+function (avpanel) {
+if (avpanel != null) {
+this.setViewport (avpanel.getAlignViewport ());
+}}, "jalview.api.AlignmentViewPanel");
+});