jvmmemmax = argString.substring(11);
continue;
}
+ if (argString.startsWith("--jvmmempc=")) {
+ jvmmempc = argString.substring(11);
+ continue;
+ }
+ if (argString.startsWith("--jvmmemmax=")) {
+ jvmmemmax = argString.substring(12);
+ continue;
+ }
}
// use saved preferences if no cmdline args
// almost finally check the startup file arguments
for (String f : _startupFiles) {
- _appargs.add(HttpUtils.startsWithHttpOrHttps(f)?f:new File(f).getAbsolutePath());
+ _appargs.add(HttpUtils.startsWithHttpOrHttpsOrJalviewScheme(f)?f:new File(f).getAbsolutePath());
}
// check if one arg with recognised extension
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+import java.net.URLConnection;
public class HttpUtils
{
+ public final static String JALVIEWSCHEMEPREFIX = "jalview";
/**
* Returns true if it is possible to open an input stream at the given URL,
return file.startsWith("http://") || file.startsWith("https://");
}
+ public static boolean startsWithHttpOrHttpsOrJalviewScheme(String file)
+ {
+ if (startsWithHttpOrHttps(file))
+ {
+ return true;
+ }
+ return isJalviewSchemeUri(file);
+ }
+
/**
* wrapper to get/post to a URL or check headers
*
* url
* @return HttpUrlConnection conn
*/
- public static HttpURLConnection openConnection(URL url) throws IOException
+ public static URLConnection openConnection(URL url) throws IOException
{
if (url == null)
{
return null;
}
- HttpURLConnection conn = null;
+ URLConnection conn = null;
String protocol = url.getProtocol();
if ("http".equals(protocol) || "https".equals(protocol))
{
conn = conn0;
}
}
+ else
+ {
+ conn = url.openConnection();
+ }
return conn;
}
return false;
}
String scheme = jalviewUri.getScheme();
- if (scheme == null || !scheme.startsWith("jalview"))
+ if (scheme == null || !scheme.startsWith(JALVIEWSCHEMEPREFIX))
{
return false;
}
- return scheme.length() == 7 // jalview
- || scheme.length() == 8 // jalviewX
- || scheme.substring(7).equals("http") // jalviewhttp
- || scheme.substring(7).equals("https"); // jalviewhttps
+ int jspl = JALVIEWSCHEMEPREFIX.length();
+ return scheme.length() == jspl // jalview
+ || scheme.length() == jspl + 1 // jalviewX
+ || scheme.substring(jspl).equals("http") // jalviewhttp
+ || scheme.substring(jspl).equals("https"); // jalviewhttps
}
/**
}
String scheme = jalviewUri.getScheme();
String host = jalviewUri.getHost();
- if (host != null && host.length() > 0
- || scheme.substring(7).startsWith("http"))
+ if (host != null && host.length() > 0 || scheme
+ .substring(JALVIEWSCHEMEPREFIX.length()).startsWith("http"))
{
URI newUri;
try
{
- newUri = new URI(scheme.equals("jalviewhttp") ? "http" : "https",
+ newUri = new URI(
+ scheme.equals(JALVIEWSCHEMEPREFIX + "http") ? "http"
+ : "https",
jalviewUri.getUserInfo(), host, jalviewUri.getPort(),
jalviewUri.getPath(), jalviewUri.getQuery(),
jalviewUri.getFragment());
public class HttpUtils
{
+ public final static String JALVIEWSCHEMEPREFIX = "jalview";
/**
* Returns true if it is possible to open an input stream at the given URL,
return file.startsWith("http://") || file.startsWith("https://");
}
+ public static boolean startsWithHttpOrHttpsOrJalviewScheme(String file)
+ {
+ if (startsWithHttpOrHttps(file))
+ {
+ return true;
+ }
+ return isJalviewSchemeUri(file);
+ }
+
/**
* wrapper to get/post to a URL or check headers
*
return false;
}
String scheme = jalviewUri.getScheme();
- if (scheme == null || !scheme.startsWith("jalview"))
+ if (scheme == null || !scheme.startsWith(JALVIEWSCHEMEPREFIX))
{
return false;
}
- return scheme.length() == 7 // jalview
- || scheme.length() == 8 // jalviewX
- || scheme.substring(7).equals("http") // jalviewhttp
- || scheme.substring(7).equals("https"); // jalviewhttps
+ int jspl = JALVIEWSCHEMEPREFIX.length();
+ return scheme.length() == jspl // jalview
+ || scheme.length() == jspl + 1 // jalviewX
+ || scheme.substring(jspl).equals("http") // jalviewhttp
+ || scheme.substring(jspl).equals("https"); // jalviewhttps
}
/**
}
String scheme = jalviewUri.getScheme();
String host = jalviewUri.getHost();
- if (host != null && host.length() > 0
- || scheme.substring(7).startsWith("http"))
+ if (host != null && host.length() > 0 || scheme
+ .substring(JALVIEWSCHEMEPREFIX.length()).startsWith("http"))
{
URI newUri;
try
{
- newUri = new URI(scheme.equals("jalviewhttp") ? "http" : "https",
+ newUri = new URI(
+ scheme.equals(JALVIEWSCHEMEPREFIX + "http") ? "http"
+ : "https",
jalviewUri.getUserInfo(), host, jalviewUri.getPort(),
jalviewUri.getPath(), jalviewUri.getQuery(),
jalviewUri.getFragment());