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:
parent
d9ee5757fe
commit
b735055492
1 changed files with 14 additions and 9 deletions
|
@ -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{}]";
|
||||||
|
|
Loading…
Add table
Reference in a new issue