JAL-4059 rename vars to j2s_ this and that for clarity
[jalview.git] / src / jalview / bin / Jalview.java
index 4eed72f..d0a8be3 100755 (executable)
@@ -312,7 +312,7 @@ public class Jalview implements JalviewObjectI
     }
     else
     {
-      setJSInfo();
+      setJ2sInfo();
     }
 
     if (args == null || args.length == 0 || (args.length == 1
@@ -2100,29 +2100,57 @@ public class Jalview implements JalviewObjectI
   }
 
   /**
-   * Info dict set by instantiating JalviewJS
+   * To be populated by Info={} hash set by instantiating JalviewJS
    */
-  private Map<String, String> JSInfo = null;
+  private Map<String, String> j2sInfo = null;
 
-  private final String[] JSSavedKeys = { "main", "core", "width", "height",
+  /**
+   * The non-j2s_-prefixed parameters to store
+   */
+  private final String[] j2sSavedKeys = { "main", "core", "width", "height",
       "serverURL", "j2sPath", "console" };
 
-  private final String JSSavedKeysPrefix = "js_";
+  /**
+   * The prefix for non-named keys in the Info={} block
+   */
+  private static final String j2sParameterPrefix = "j2s_";
 
-  private final String JSNamespaceKey = JSSavedKeysPrefix + "namespace";
+  /**
+   * The Info key name for namespacing (query string parameters, class and id
+   * values)
+   */
+  private static final String j2sNamespaceKey = j2sParameterPrefix
+          + "namespace";
 
-  public String getJSInfoValue(String key)
+  /**
+   * Get a value passed in from the Info={} hash. key should NOT use the
+   * namespace prefix.
+   * 
+   * @param key
+   *          key name without the j2s_ namespace in the Info={} hash.
+   * @return value value from the Info={} hash.
+   */
+  public String getJ2sInfoValue(String key)
   {
-    return JSInfo == null ? null : JSInfo.get(key);
+    if (j2sInfo == null || key == null)
+    {
+      return null;
+    }
+    String j2sKey = Arrays.asList(j2sSavedKeys).contains(key) ? key
+            : j2sParameterPrefix + key;
+    return j2sInfo.get(j2sKey);
   }
 
-  public void setJSInfo()
+  /**
+   * Get and save parameters and values from the Info={} hash.
+   */
+  public void setJ2sInfo()
   {
     if (!Platform.isJS())
     {
       return;
     }
-    JSInfo = new HashMap<>();
+    j2sInfo = new HashMap<>();
     String key = null;
     String val = null;
     /**
@@ -2134,14 +2162,14 @@ public class Jalview implements JalviewObjectI
      * 
      *            val = entry[1];
      */
-    if (key != null && (key.startsWith(JSSavedKeysPrefix)
-            || Arrays.asList(JSSavedKeys).contains(key)))
+    if (key != null && (key.startsWith(j2sParameterPrefix)
+            || Arrays.asList(j2sSavedKeys).contains(key)))
     {
-      JSInfo.put(key, val);
+      j2sInfo.put(key, val);
 
-      if (key.equals(JSNamespaceKey))
+      if (key.equals(j2sNamespaceKey))
       {
-        setJSNamespace(val);
+        setJ2sNamespace(val);
       }
     }
     /**
@@ -2156,20 +2184,20 @@ public class Jalview implements JalviewObjectI
   /**
    * Namespace (if set) by JalviewJS
    */
-  private String JSNamespace = null;
+  private String j2sNamespace = null;
 
-  private void setJSNamespace(String ns)
+  private void setJ2sNamespace(String ns)
   {
     if (!Platform.isJS())
     {
       return;
     }
-    Console.outPrintln("JSNamespace set to '" + ns + "'");
-    JSNamespace = ns;
+    Console.outPrintln("j2sNamespace set to '" + ns + "'");
+    j2sNamespace = ns;
   }
 
-  public String getJSNamespace()
+  public String getJ2sNamespace()
   {
-    return JSNamespace;
+    return j2sNamespace;
   }
 }