JAL-1551 formatting
authorJim Procter <jprocter@dundee.ac.uk>
Wed, 5 Jun 2024 14:20:51 +0000 (15:20 +0100)
committerJim Procter <jprocter@dundee.ac.uk>
Wed, 5 Jun 2024 14:20:51 +0000 (15:20 +0100)
getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java
getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/EnvConfig.java

index f83add3..c85f1bb 100644 (file)
@@ -1205,8 +1205,10 @@ public class Application
         }
 
         // almost finally check the startup file arguments
-        for (String f : _startupFiles) {
-          _appargs.add(HttpUtils.isPlausibleUri(f)?f:new File(f).getAbsolutePath());
+        for (String f : _startupFiles)
+        {
+          _appargs.add(HttpUtils.isPlausibleUri(f) ? f
+                  : new File(f).getAbsolutePath());
         }
         
         // check if one arg with recognised extension
@@ -1944,20 +1946,27 @@ public class Application
         return new File(appdir, path);
     }
     
-    public static void setStartupFilesFromParameters(List<String> parameters) {
+    public static void setStartupFilesFromParameters(
+            List<String> parameters)
+    {
       // multiple files *might* be passed in as space separated quoted filenames
       String q = "\"";
-      for (String p: parameters) {
-        if (!StringUtil.isBlank(p)) {
+      for (String p : parameters)
+      {
+        if (!StringUtil.isBlank(p))
+        {
           String filename;
           // split quoted params or treat as single string array
-          if (p.startsWith(q) && p.endsWith(q)) {
-            filename = p.substring(q.length(),p.length()-q.length());
-          } else {
+          if (p.startsWith(q) && p.endsWith(q))
+          {
+            filename = p.substring(q.length(), p.length() - q.length());
+          }
+          else
+          {
             // single unquoted filename
             filename = p;
           }
-          
+
           /* Now letting Jalview convert these URIs.
           // convert jalviewX://... URLs
           if (HttpUtils.isJalviewSchemeUri(filename)) {
@@ -1965,33 +1974,49 @@ public class Application
           }
           */
 
-          // check for locator file.  Only allow one locator file to be double clicked (if multiple files opened, ignore locator files)
-          if (filename.toLowerCase(Locale.ROOT).endsWith("."+Application.LOCATOR_FILE_EXTENSION)) {
+          // check for locator file. Only allow one locator file to be double
+          // clicked (if multiple files opened, ignore locator files)
+          if (filename.toLowerCase(Locale.ROOT)
+                  .endsWith("." + Application.LOCATOR_FILE_EXTENSION))
+          {
             // convert jalviewX://... JVL files
             setLocatorFile(HttpUtils.equivalentJalviewUrl(filename));
-          } else {
+          }
+          else
+          {
             // skip any other locator files in a multiple file list
             addStartupFile(filename);
           }
         }
       }
     }
-        
-    public static String getStartupFilesParameterString(List<String> parameters, boolean changeJalviewSchemeUris) {
+
+    public static String getStartupFilesParameterString(
+            List<String> parameters, boolean changeJalviewSchemeUris)
+    {
       StringBuilder sb = new StringBuilder();
       boolean first = true;
-      for(String f : parameters) {
-        if (first) {
+      for (String f : parameters)
+      {
+        if (first)
+        {
           first = false;
-        } else {
+        }
+        else
+        {
           sb.append(' ');
         }
-        String p = changeJalviewSchemeUris ? HttpUtils.equivalentJalviewUrl(f) : f;
-        if (p.contains(" ")) {
+        String p = changeJalviewSchemeUris
+                ? HttpUtils.equivalentJalviewUrl(f)
+                : f;
+        if (p.contains(" "))
+        {
           sb.append('"');
           sb.append(p);
           sb.append('"');
-        } else {
+        }
+        else
+        {
           sb.append(p);
         }
       }
@@ -2017,19 +2042,27 @@ public class Application
       
       Config locatorConfig = null;
       
-      try {
+      try
+      {
         Config tmpConfig = null;
         Map<String, Object> tmpData = new HashMap<>();
-        if (HttpUtils.startsWithHttpOrHttps(_locatorFile)) {
+        if (HttpUtils.startsWithHttpOrHttps(_locatorFile))
+        {
           URL locatorUrl = new URL(_locatorFile);
-          try (InputStream in = ConnectionUtil.open(proxy, locatorUrl, 0, 0).getInputStream();
-                 InputStreamReader reader = new InputStreamReader(in, UTF_8);
-                 BufferedReader bin = new BufferedReader(reader)) {
-                   tmpConfig = Config.parseConfig(bin, opts);
+          try (InputStream in = ConnectionUtil.open(proxy, locatorUrl, 0, 0)
+                  .getInputStream();
+                  InputStreamReader reader = new InputStreamReader(in,
+                          UTF_8);
+                  BufferedReader bin = new BufferedReader(reader))
+          {
+            tmpConfig = Config.parseConfig(bin, opts);
           }
-        } else if (new File(_locatorFile).exists()) {
-          tmpConfig = Config.parseConfig(new File(_locatorFile),  opts);
         }
+        else if (new File(_locatorFile).exists())
+        {
+          tmpConfig = Config.parseConfig(new File(_locatorFile), opts);
+        }
+
         if (tmpConfig != null) {
           // appbase is sanitised in HostWhitelist
           Map<String, Object> tmpConfigData = tmpConfig.getData();
index 862c18e..7c2ab7d 100644 (file)
@@ -149,8 +149,11 @@ public final class EnvConfig {
         // Look for locator file, pass to Application and remove from appArgs
         String argvLocatorFilename = argv.length > 2 ? argv[2] : null;
         if (!StringUtil.isBlank(argvLocatorFilename)
-              && argvLocatorFilename.toLowerCase(Locale.ROOT).endsWith("."+Application.LOCATOR_FILE_EXTENSION)) {
-          argvLocatorFilename = HttpUtils.equivalentJalviewUrl(argvLocatorFilename);
+                && argvLocatorFilename.toLowerCase(Locale.ROOT)
+                        .endsWith("." + Application.LOCATOR_FILE_EXTENSION))
+        {
+          argvLocatorFilename = HttpUtils
+                  .equivalentJalviewUrl(argvLocatorFilename);
           notes.add(Note.info("locatorFilename in args: '"+argv[2]+"'"));
           Application.setLocatorFile(argvLocatorFilename);