Unwrap JS-native number and boolean objects in put() and return them as
they are in get().
This commit is contained in:
parent
6d7a8eba66
commit
fb3196cfd5
1 changed files with 10 additions and 13 deletions
|
@ -486,6 +486,10 @@ public class HopObject extends ScriptableObject implements Wrapper {
|
||||||
node.setDate(name, new Date((long) ScriptRuntime.toNumber(s)));
|
node.setDate(name, new Date((long) ScriptRuntime.toNumber(s)));
|
||||||
} else if ("String".equals(s.getClassName())) {
|
} else if ("String".equals(s.getClassName())) {
|
||||||
node.setString(name, ScriptRuntime.toString(s));
|
node.setString(name, ScriptRuntime.toString(s));
|
||||||
|
} else if ("Number".equals(s.getClassName())) {
|
||||||
|
node.setFloat(name, ScriptRuntime.toNumber(s));
|
||||||
|
} else if ("Boolean".equals(s.getClassName())) {
|
||||||
|
node.setBoolean(name, ScriptRuntime.toBoolean(s));
|
||||||
} else if (s instanceof MapWrapper) {
|
} else if (s instanceof MapWrapper) {
|
||||||
node.setJavaObject(name, ((MapWrapper) s).unwrap());
|
node.setJavaObject(name, ((MapWrapper) s).unwrap());
|
||||||
} else {
|
} else {
|
||||||
|
@ -580,20 +584,13 @@ public class HopObject extends ScriptableObject implements Wrapper {
|
||||||
IProperty p = node.get(name);
|
IProperty p = node.get(name);
|
||||||
|
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
if (p.getType() == IProperty.STRING) {
|
|
||||||
return p.getStringValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p.getType() == IProperty.BOOLEAN) {
|
switch (p.getType()) {
|
||||||
return p.getBooleanValue() ? Boolean.TRUE : Boolean.FALSE;
|
case IProperty.STRING:
|
||||||
}
|
case IProperty.INTEGER:
|
||||||
|
case IProperty.FLOAT:
|
||||||
if (p.getType() == IProperty.INTEGER) {
|
case IProperty.BOOLEAN:
|
||||||
return new Long(p.getIntegerValue());
|
return p.getValue();
|
||||||
}
|
|
||||||
|
|
||||||
if (p.getType() == IProperty.FLOAT) {
|
|
||||||
return new Double(p.getFloatValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Context cx = Context.getCurrentContext();
|
Context cx = Context.getCurrentContext();
|
||||||
|
|
Loading…
Add table
Reference in a new issue