protected void addToScope(Scriptable scope) { Object value = exportingBundle.lookup(name); StringTokenizer tokenizer = new StringTokenizer(name, "."); // $NON-NLS-1$ while (true) { String token = tokenizer.nextToken(); Object current = scope.get(token, scope); if (!tokenizer.hasMoreTokens()) { if (current == Scriptable.NOT_FOUND) { if (value instanceof NativeObject) { Scriptable wrapped = Context.getCurrentContext().newObject(scope); wrapped.setPrototype((Scriptable) value); value = wrapped; } scope.put(token, scope, value); return; } throw new IllegalStateException( "Resolve error: " + name + " already exists for " + this.toString()); // $NON-NLS-1$//$NON-NLS-2$ } if (current == Scriptable.NOT_FOUND) { current = ScriptableObject.getProperty(scope, token); if (current == Scriptable.NOT_FOUND) current = Context.getCurrentContext().newObject(scope); else if (current instanceof NativeObject) { // we need to wrap this object from the prototype Scriptable wrapped = Context.getCurrentContext().newObject(scope); wrapped.setPrototype((Scriptable) current); current = wrapped; } else throw new IllegalStateException( "Resolve error: " + name + "-" + token + " already exists for " + this.toString()); // $NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ scope.put(token, scope, current); } scope = (Scriptable) current; } }
public int getBundleId() { return exportingBundle.getBundleId(); }
public Version getBundleVersion() { return exportingBundle.getVersion(); }
public String getBundleSymbolicName() { return exportingBundle.getSymbolicName(); }