3 import java.awt.Component;
5 import java.io.InputStream;
7 import java.util.HashMap;
8 import java.util.Properties;
10 import swingjs.api.js.HTML5Applet;
12 public interface JSUtilI {
15 * Indicate to SwingJS that the given file type is binary.
19 void addBinaryFileType(String ext);
22 * Indicate to SwingJS that we can load files using AJAX from the given
23 * domain, such as "www.stolaf.edu", because we know that CORS access has been
28 void addDirectDatabaseCall(String domain);
31 * Cache or uncache data under the given path name.
35 * null to remove from the cache
37 void cachePathData(String path, Object data);
40 * Get the HTML5 object corresponding to the specified Component, or the
41 * current thread if null.
44 * the associated component, or null for the current thread
45 * @return HTML5 applet object
47 HTML5Applet getAppletForComponent(Component c);
50 * Get an attribute applet.foo for the applet found using getApplet(null).
55 Object getAppletAttribute(String key);
58 * Get the code base (swingjs/j2s, probably) for the applet found using
66 * Get the document base (wherever the page is) for the applet found using
72 URL getDocumentBase();
75 * Get an attribute from the div on the page that is associated with this
76 * frame, i.e. with id frame.getName() + "-div".
83 Object getEmbeddedAttribute(Component frame, String type);
86 * Get a file synchronously.
90 * true for String; false for byte[]
91 * @return byte[] or String
93 Object getFile(String path, boolean asString);
96 * Get the 秘bytes field associated with a file, but only if the File object
97 * itself has them attached, not downloading them.
102 byte[] getBytes(File f);
105 * Retrieve a HashMap consisting of whatever the application wants, but
106 * guaranteed to be unique to this app context, that is, for the applet found
107 * using getApplet(null).
112 HashMap<?, ?> getJSContext(Object contextKey);
115 * Load a resource -- probably a core file -- if and only if a particular
116 * class has not been instantialized. We use a String here because if we used
117 * a .class object, that reference itself would simply load the class, and we
118 * want the core package to include that as well.
120 * @param resourcePath
123 void loadResourceIfClassUnknown(String resource, String className);
126 * Read all applet.__Info properties for the applet found using
127 * getApplet(null) that start with the given prefix, such as "jalview_". A
128 * null prefix retrieves all properties. Note that non-string properties will
132 * an application prefix, or null for all properties
134 * properties to be appended to
136 void readInfoProperties(String prefix, Properties p);
139 * Set an attribute for the applet found using getApplet(null). That is,
145 void setAppletAttribute(String key, Object val);
148 * Set an attribute of applet's Info map for the applet found using
149 * getApplet(null). That is, applet.__Info[key] = val.
154 void setAppletInfo(String infoKey, Object val);
157 * Set the given File object's 秘bytes field from an InputStream or a byte[]
158 * array. If the file is a JSTempFile, then also cache those bytes.
162 * BufferedInputStream, ByteArrayInputStream, FileInputStream, or
166 boolean setFileBytes(File f, Object isOrBytes);
169 * Same as setFileBytes, but also caches the data if it is a JSTempFile.
175 boolean streamToFile(InputStream is, File outFile);
178 * Switch the flag in SwingJS to use or not use the JavaScript Map object in
179 * Hashtable, HashMap, and HashSet. Default is enabled.
183 void setJavaScriptMapObjectEnabled(boolean enabled);