@Override
public Object call(Context cx, Scriptable scope,
Scriptable thisObj, Object[] args) {
final StringWriter writer = new StringWriter();
IndividualRequest request = Client.getCurrentObjectResponse();
HttpServletResponse currentResponse = request.getHttpResponse();
request.setHttpResponse(new HttpServletResponse(){
public void addCookie(Cookie arg0) {
}
public void addDateHeader(String arg0, long arg1) {
}
public void addHeader(String arg0, String arg1) {
}
public void addIntHeader(String arg0, int arg1) {
}
public boolean containsHeader(String arg0) {
return false;
}
public String encodeRedirectUrl(String arg0) {
throw new UnsupportedOperationException("Not implemented yet");
}
public String encodeRedirectURL(String arg0) {
throw new UnsupportedOperationException("Not implemented yet");
}
public String encodeUrl(String arg0) {
throw new UnsupportedOperationException("Not implemented yet");
}
public String encodeURL(String arg0) {
throw new UnsupportedOperationException("Not implemented yet");
}
public void sendError(int arg0, String arg1) throws IOException {
throw new UnsupportedOperationException("Not implemented yet");
}
public void sendError(int arg0) throws IOException {
throw new UnsupportedOperationException("Not implemented yet");
}
public void sendRedirect(String arg0) throws IOException {
throw new UnsupportedOperationException("Not implemented yet");
}
public void setDateHeader(String arg0, long arg1) {
throw new UnsupportedOperationException("Not implemented yet");
}
public void setHeader(String arg0, String arg1) {
throw new UnsupportedOperationException("Not implemented yet");
}
public void setIntHeader(String arg0, int arg1) {
throw new UnsupportedOperationException("Not implemented yet");
}
public void setStatus(int arg0, String arg1) {
}
public void setStatus(int arg0) {
}
public void flushBuffer() throws IOException {
}
public int getBufferSize() {
throw new UnsupportedOperationException("Not implemented yet");
}
public String getCharacterEncoding() {
throw new UnsupportedOperationException("Not implemented yet");
}
public String getContentType() {
return "application/json";
}
public Locale getLocale() {
throw new UnsupportedOperationException("Not implemented yet");
}
public ServletOutputStream getOutputStream() throws IOException {
return new ServletOutputStream(){
@Override
public void write(byte[] b) throws IOException {
writer.write(new String(b));
}
@Override
public void write(int b) throws IOException {
writer.write(new String(new byte[]{(byte) b}));
}
};
}
public PrintWriter getWriter() throws IOException {
return new PrintWriter(writer);
}
public boolean isCommitted() {
throw new UnsupportedOperationException("Not implemented yet");
}
public void reset() {
}
public void resetBuffer() {
}
public void setBufferSize(int arg0) {
}
public void setCharacterEncoding(String arg0) {
}
public void setContentLength(int arg0) {
}
public void setContentType(String arg0) {
}
public void setLocale(Locale arg0) {
}
});
try{
DataSerializer.serialize(args[0], args.length > 1 ? (String) args[1] : null);
}finally{
request.setHttpResponse(currentResponse);
}
return writer.toString();
}
},true,false);
set("_setIdSequence", new PersevereNativeFunction() {