Java Javascript Mozilla Library copyScriptableToProperties(Scriptable scriptable, Map properties)

Here you can find the source of copyScriptableToProperties(Scriptable scriptable, Map properties)

Description

copy Scriptable To Properties

License

LGPL

Declaration

public static void copyScriptableToProperties(Scriptable scriptable, Map<String, Object> properties) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.util.Map;
import org.mozilla.javascript.Context;

import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.Undefined;

public class Main {
    public static void copyScriptableToProperties(Scriptable scriptable, Map<String, Object> properties) {
        if (properties == null || scriptable == null)
            return;

        Context.enter();//from w  w  w . j a  v a 2 s  .c  o m
        try {
            Object ids[] = scriptable.getIds();
            for (int i = 0; i < ids.length; i++) {
                String key = ids[i].toString();
                Object value = scriptable.get(ids[i].toString(), scriptable);
                if (value == null || value == Undefined.instance)
                    continue;
                properties.put(key, value);
            }
        } finally {
            Context.exit();
        }
    }
}

Related

  1. callFn(Function function, Context cx, Scriptable scope, Scriptable thisObj, Object[] args)
  2. convertArray(NativeArray jsArray)
  3. convertObject(NativeObject jsObject, Map identities)
  4. copyPropertiesToScriptable(Hashtable properties, Scriptable scriptable)
  5. copyScope(Context context, Scriptable scope)
  6. createJavaAdapterArgs(Scriptable scope, Class[] ifaces, Object jsImpl)
  7. createNativeArray(int length, Scriptable scope)
  8. createSecurityController()
  9. ensureValid(Object obj)