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
16 * Indicate to SwingJS that the given file type is binary.
20 void addBinaryFileType(String ext);
23 * Indicate to SwingJS that we can load files using AJAX from the given
24 * domain, such as "www.stolaf.edu", because we know that CORS access has been
29 void addDirectDatabaseCall(String domain);
32 * Cache or uncache data under the given path name.
36 * null to remove from the cache
38 void cachePathData(String path, Object data);
41 * Get the HTML5 object corresponding to the specified Component, or the
42 * current thread if null.
45 * the associated component, or null for the current thread
46 * @return HTML5 applet object
48 HTML5Applet getAppletForComponent(Component c);
51 * Get an attribute applet.foo for the applet found using getApplet(null).
56 Object getAppletAttribute(String key);
59 * Get the code base (swingjs/j2s, probably) for the applet found using
67 * Get the document base (wherever the page is) for the applet found using
73 URL getDocumentBase();
76 * Get an attribute from the div on the page that is associated with this
77 * frame, i.e. with id frame.getName() + "-div".
84 Object getEmbeddedAttribute(Component frame, String type);
87 * Get a file synchronously.
91 * true for String; false for byte[]
92 * @return byte[] or String
94 Object getFile(String path, boolean asString);
97 * Get the 秘bytes field associated with a file, but only if the File object
98 * itself has them attached, not downloading them.
103 byte[] getBytes(File f);
106 * Retrieve a HashMap consisting of whatever the application wants, but
107 * guaranteed to be unique to this app context, that is, for the applet found
108 * using getApplet(null).
113 HashMap<?, ?> getJSContext(Object contextKey);
116 * Load a resource -- probably a core file -- if and only if a particular
117 * class has not been instantialized. We use a String here because if we used
118 * a .class object, that reference itself would simply load the class, and we
119 * want the core package to include that as well.
121 * @param resourcePath
124 void loadResourceIfClassUnknown(String resource, String className);
127 * Read all applet.__Info properties for the applet found using
128 * getApplet(null) that start with the given prefix, such as "jalview_". A
129 * null prefix retrieves all properties. Note that non-string properties will
133 * an application prefix, or null for all properties
135 * properties to be appended to
137 void readInfoProperties(String prefix, Properties p);
140 * Set an attribute for the applet found using getApplet(null). That is,
146 void setAppletAttribute(String key, Object val);
149 * Set an attribute of applet's Info map for the applet found using
150 * getApplet(null). That is, applet.__Info[key] = val.
155 void setAppletInfo(String infoKey, Object val);
158 * Set the given File object's 秘bytes field from an InputStream or a byte[]
159 * array. If the file is a JSTempFile, then also cache those bytes.
163 * BufferedInputStream, ByteArrayInputStream, FileInputStream, or
167 boolean setFileBytes(File f, Object isOrBytes);
170 * Same as setFileBytes, but also caches the data if it is a JSTempFile.
176 boolean streamToFile(InputStream is, File outFile);
179 * Switch the flag in SwingJS to use or not use the JavaScript Map object in
180 * Hashtable, HashMap, and HashSet. Default is enabled.
184 void setJavaScriptMapObjectEnabled(boolean enabled);