+
+ public Blessing bless(JS b) { return new XWT.Blessing((JS.Cloneable)b, this, null, null); }
+ public static class Blessing extends JS.Clone {
+ private XWT xwt;
+ private Template t = null;
+ private Object parentkey = null;
+ private Blessing parent = null;
+ public Blessing(JS.Cloneable clonee, XWT xwt, Blessing parent, Object parentkey) {
+ super(clonee); this.xwt = xwt; this.parentkey = parentkey; this.parent = parent; }
+ public Object get(Object key) throws JSExn {
+ return key.equals("") ? ((Object)getStatic()) : (new Blessing((JS.Cloneable)clonee.get(key), xwt, this, key));
+ }
+ public InputStream getImage() throws JSExn {
+ InputStream in = null;
+ try {
+ in = Stream.getInputStream(this);
+ if (in != null) return in;
+ } catch (IOException e) { /* DELIBERATE */ in = null; }
+ String[] exts = new String[] { ".png", ".jpeg", ".gif" };
+ for (int i=0; i < exts.length && in == null; i++) {
+ try {
+ in = Stream.getInputStream(parent.get(parentkey + exts[i]));
+ if (in != null) return in;
+ } catch (IOException f) { in = null; }
+ }
+ return null;
+ }
+ public JSScope getStatic() throws JSExn {
+ try {
+ // FIXME background?
+ if (t == null) t = new Template(Stream.getInputStream(parent.get(parentkey + ".xwt")), xwt);
+ return t.getStatic();
+ } catch (Exception e) {
+ Log.error(this, e);
+ return null;
+ }
+ }
+ public Object call(Object a, Object b, Object c, Object[] rest, int nargs) throws JSExn {
+ if (nargs != 1) throw new JSExn("FIXME can only call with one arg");
+ getStatic();
+ t.apply((Box)a);
+ return a;
+ }
+ }
+