import java.net.URL;
import java.util.zip.GZIPInputStream;
+
+import jalview.ws.dbsources.Pfam;
+import jalview.ws.dbsources.Rfam;
+
/**
* implements a random access wrapper around a particular datasource, for
* passing to identifyFile and AlignFile objects.
protected static final String TAB = "\t";
+ private static final String GZ_EXT = ".gz";
+
/**
* text specifying source of data. usually filename or url.
*/
public File inFile = null;
+
/**
* a viewport associated with the current file operation. May be null. May
* move to different object.
}
if (!error)
{
- if (fileStr.toLowerCase().endsWith(".gz"))
+ if (fileStr.toLowerCase().endsWith(GZ_EXT))
{
try
{
// GZIPInputStream code borrowed from Aquaria (soon to be open sourced) via
// Kenny Sabir
Exception e = null;
- if (fileStr.toLowerCase().endsWith(".gz"))
+ if (isGzipped(fileStr))
{
try
{
}
/**
+ * Answers true if the filename (or URL) has a format which Jalview recognises
+ * as denoting gzipped content.
+ * <p>
+ * Currently this means having a ".gz" extension, or ending in "/gzipped" or
+ * "?gz=1" (used to retrieve gzipped from Pfam and Rfam respectively).
+ *
+ * @param filename
+ * @return
+ */
+ protected static boolean isGzipped(String filename)
+ {
+ if (filename == null)
+ {
+ return false;
+ }
+ String lower = filename.toLowerCase();
+ return lower.endsWith(GZ_EXT) || lower.endsWith(Pfam.GZIPPED)
+ || lower.endsWith(Rfam.GZIPPED);
+ }
+
+ /**
* sets the suffix string (if any) and returns remainder (if suffix was
* detected)
*