Here you can find the source of copyScriptableToProperties(Scriptable scriptable, Map
public static void copyScriptableToProperties(Scriptable scriptable, Map<String, Object> properties)
//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(); } } }