Make MapWrapper implement org.mozilla.javascript.Wrapper so that the map

is autimatically unwrapped when passing it outside the scripting engine.
Added/enhanced some comments.
This commit is contained in:
hns 2004-02-18 11:39:33 +00:00
parent d9ee5757fe
commit b735055492

View file

@ -25,9 +25,11 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
* * A class that wraps a Java Map as a native JavaScript object. This is
* used by the RhinoCore Wrapper for instances of helma.util.SystemMap
* and helma.util.WrappedMap.
*/ */
public class MapWrapper extends ScriptableObject { public class MapWrapper extends ScriptableObject implements Wrapper {
Map map; Map map;
RhinoCore core; RhinoCore core;
@ -199,9 +201,7 @@ public class MapWrapper extends ScriptableObject {
/** /**
* * Return an array containing the property key values of this map.
*
* @return ...
*/ */
public Object[] getIds() { public Object[] getIds() {
if (map == null) { if (map == null) {
@ -218,7 +218,10 @@ public class MapWrapper extends ScriptableObject {
return super.getDefaultValue(hint); return super.getDefaultValue(hint);
} }
public Map unwrap() { /**
* Return the wrapped Map object.
*/
public Object unwrap() {
if (map == null) { if (map == null) {
map = new HashMap(); map = new HashMap();
} }
@ -226,14 +229,16 @@ public class MapWrapper extends ScriptableObject {
} }
/** /**
* * Return the class name for wrapped maps.
*
* @return ...
*/ */
public String getClassName() { public String getClassName() {
return "[MapWrapper]"; return "[MapWrapper]";
} }
/**
* Return a string representation for this wrapped map. This calls
* Map.toString(), so usually the contents of the map will be listed.
*/
public String toString() { public String toString() {
if (map == null) { if (map == null) {
return "[MapWrapper{}]"; return "[MapWrapper{}]";