gets on internal properties are now handled by a separate method
This commit is contained in:
parent
906a1ac9ab
commit
926063cfac
1 changed files with 20 additions and 10 deletions
|
@ -400,10 +400,8 @@ public class ESNode extends ObjectPrototype {
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is not very nice, but as a hack we return the id of a node as node.__id__
|
// this is not very nice, but as a hack we return the id of a node as node.__id__
|
||||||
if ("__id__".equalsIgnoreCase (propertyName))
|
if (propertyName.startsWith ("__") && propertyName.endsWith ("__"))
|
||||||
return new ESString (node.getID ());
|
return getInternalProperty (propertyName);
|
||||||
if ("__prototype__".equalsIgnoreCase (propertyName))
|
|
||||||
return new ESString (node.getPrototype ());
|
|
||||||
|
|
||||||
// this _may_ do a relational query if properties are mapped to a relational type.
|
// this _may_ do a relational query if properties are mapped to a relational type.
|
||||||
IProperty p = node.get (propertyName, false);
|
IProperty p = node.get (propertyName, false);
|
||||||
|
@ -434,6 +432,24 @@ public class ESNode extends ObjectPrototype {
|
||||||
return ESLoader.normalizeObject (p.getJavaObjectValue (), evaluator);
|
return ESLoader.normalizeObject (p.getJavaObjectValue (), evaluator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// as last resort, try to get property as anonymous subnode
|
||||||
|
INode anon = node.getSubnode (propertyName);
|
||||||
|
if (anon != null)
|
||||||
|
return eval.getNodeWrapper (anon);
|
||||||
|
|
||||||
|
return ESNull.theNull;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ESValue getInternalProperty (String propertyName) throws EcmaScriptException {
|
||||||
|
if ("__id__".equalsIgnoreCase (propertyName))
|
||||||
|
return new ESString (node.getID ());
|
||||||
|
if ("__prototype__".equalsIgnoreCase (propertyName)) {
|
||||||
|
String p = node.getPrototype ();
|
||||||
|
if (p == null)
|
||||||
|
return ESNull.theNull;
|
||||||
|
else
|
||||||
|
return new ESString (node.getPrototype ());
|
||||||
|
}
|
||||||
// some more internal properties
|
// some more internal properties
|
||||||
if ("__parent__".equals (propertyName)) {
|
if ("__parent__".equals (propertyName)) {
|
||||||
INode n = node.getParent ();
|
INode n = node.getParent ();
|
||||||
|
@ -450,12 +466,6 @@ public class ESNode extends ObjectPrototype {
|
||||||
return new ESString (""+node.hashCode ());
|
return new ESString (""+node.hashCode ());
|
||||||
if ("__node__".equals (propertyName))
|
if ("__node__".equals (propertyName))
|
||||||
return ESLoader.normalizeObject (node, evaluator);
|
return ESLoader.normalizeObject (node, evaluator);
|
||||||
|
|
||||||
// as last resort, try to get property as anonymous subnode
|
|
||||||
INode anon = node.getSubnode (propertyName);
|
|
||||||
if (anon != null)
|
|
||||||
return eval.getNodeWrapper (anon);
|
|
||||||
|
|
||||||
return ESNull.theNull;
|
return ESNull.theNull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue