}
else
{
- setJSInfo();
+ setJ2sInfo();
}
if (args == null || args.length == 0 || (args.length == 1
}
/**
- * 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;
/**
*
* 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);
}
}
/**
/**
* 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;
}
}