X-Git-Url: http://git.megacz.com/?p=org.ibex.js.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fjs%2FJSSubProperties.java;fp=src%2Forg%2Fibex%2Fjs%2FJSSubProperties.java;h=dcf804275278e01245a87455bdf017c5379dd8e4;hp=0000000000000000000000000000000000000000;hb=95c5a8f2287c2869f100995b7e2bcf749bb097c8;hpb=28c7ed74a57e451da7c45a086848f0b86eff5ce2 diff --git a/src/org/ibex/js/JSSubProperties.java b/src/org/ibex/js/JSSubProperties.java new file mode 100644 index 0000000..dcf8042 --- /dev/null +++ b/src/org/ibex/js/JSSubProperties.java @@ -0,0 +1,25 @@ +// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Licensed under the Apache Public Source License 2.0 ("the License"). +// You may not use this file except in compliance with the License. + +package org.ibex.js; + +// FEATURE: cache JSSubProperties.Sub +public abstract class JSSubProperties extends JS.Immutable { + protected static final JS SUBPROPERTY = new JS.Immutable(); + public abstract JS _get(JS key) throws JSExn; + public final JS get(JS key) throws JSExn { + JS ret = _get(key); + return ret==SUBPROPERTY ? new Sub(key) : ret; + } + private class Sub extends JS.Immutable { + final JS key; + Sub(JS key) { this.key = key; } + public void put(JS key, JS val) throws JSExn { + JSSubProperties.this.put(JSU.S(JSU.toString(this.key) + "." + JSU.toString(key)), val); } + public JS get(JS key) throws JSExn { + return JSSubProperties.this.get(JSU.S(JSU.toString(this.key) + "." + JSU.toString(key))); } + public JS call(JS method, JS[] args) throws JSExn { + return JSSubProperties.this.call(JSU.S(JSU.toString(this.key) + "." + JSU.toString(method)), args); } + } +}