// 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); } } }