return thisObj instanceof Persistable ? ((Persistable)thisObj).getParent() : null;
}
},false);
objectProto.setAttributes("parent",ScriptableObject.DONTENUM);
Scriptable applicationJavascript = new NativeObject();
objectProto.put("representation:application/javascript", objectProto, applicationJavascript);
objectProtoMirror.put("representation:application/javascript", objectProtoMirror, applicationJavascript);
objectProto.setAttributes("representation:application/javascript",ScriptableObject.DONTENUM);
applicationJavascript.put("quality", applicationJavascript, 0.9);
applicationJavascript.put("output", applicationJavascript, new PersevereNativeFunction(){
@Override
public Object call(Context cx, Scriptable scope,
Scriptable thisObj, Object[] args) {
try {
HttpServletResponse response = Client.getCurrentObjectResponse().getHttpResponse();
DirtyOutputStreamWriter writer = new DirtyOutputStreamWriter(response.getOutputStream(),"UTF8");
try{
new JavaScriptSerializer().serialize(args[0], Client.getCurrentObjectResponse(), writer);
}
catch(RuntimeException e){
if(writer.isDirty)
writer.write("&&");
throw e;
}
finally{
writer.flushIfDirty();
}
return null;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
});
Scriptable applicationJson = new NativeObject();
objectProto.put("representation:application/json", objectProto, applicationJson);
objectProtoMirror.put("representation:application/json", objectProtoMirror, applicationJson);
objectProto.setAttributes("representation:application/json",ScriptableObject.DONTENUM);
applicationJson.put("quality", applicationJson, 0.8);
applicationJson.put("output", applicationJson, new PersevereNativeFunction(){
@Override
public Object call(Context cx, Scriptable scope,
Scriptable thisObj, Object[] args) {
try {
HttpServletResponse response = Client.getCurrentObjectResponse().getHttpResponse();