Examples of OutputRepresentation


Examples of org.restlet.resource.OutputRepresentation

            if (ret instanceof PyString) {
                getResponse().setEntity(ret.toString(), mediaType);
            }
            else if (ret instanceof PyList) {
                final PyList list = (PyList) ret;
                getResponse().setEntity(new OutputRepresentation(mediaType) {
                   
                    @Override
                    public void write(OutputStream outputStream) throws IOException {
                        for (Iterator i = list.iterator(); i.hasNext();) {
                            outputStream.write(i.next().toString().getBytes());
                            outputStream.write('\n');
                        }
                    }
                });
            }
            else if (ret instanceof PyIterator) {
                final PyIterator iter = (PyIterator) ret;
                getResponse().setEntity(new OutputRepresentation(mediaType) {
                   
                    @Override
                    public void write(OutputStream outputStream) throws IOException {
                        for (Iterator i = iter.iterator(); i.hasNext();) {
                            outputStream.write(i.next().toString().getBytes());
View Full Code Here

Examples of org.restlet.resource.OutputRepresentation

                if (ret instanceof PyString) {
                    response.setEntity(ret.toString(), mediaType);
                }
                else if (ret instanceof PyList) {
                    final PyList list = (PyList) ret;
                    response.setEntity(new OutputRepresentation(mediaType) {
                       
                        @Override
                        public void write(OutputStream outputStream) throws IOException {
                            for (Iterator i = list.iterator(); i.hasNext();) {
                                outputStream.write(i.next().toString().getBytes());
                                if (i.hasNext()) {
                                    outputStream.write('\n');
                                }
                            }
                        }
                    });
                }
                else if (ret instanceof PyIterator) {
                    final PyIterator iter = (PyIterator) ret;
                    response.setEntity(new OutputRepresentation(mediaType) {
   
                        @Override
                        public void write(OutputStream outputStream) throws IOException {
                            for (Iterator i = iter.iterator(); i.hasNext();) {
                                outputStream.write(i.next().toString().getBytes());
                                outputStream.write('\n');
                            }
                        }
                    });
                }
                else if (ret instanceof PyObjectDerived) {
                    final PyObjectDerived iter = (PyObjectDerived)ret;
                    response.setEntity(new OutputRepresentation(mediaType) {
   
                        @Override
                        public void write(OutputStream outputStream) throws IOException {
                            PyObject next = null;
                            while ((next = iter.__iternext__()) != null) {
View Full Code Here

Examples of org.restlet.resource.OutputRepresentation

            }
           
            pi.setOut(out);
            pi.execfile(new FileInputStream(script));
           
            getResponse().setEntity(new OutputRepresentation(MediaType.TEXT_PLAIN) {
                @Override
                public void write(OutputStream output) throws IOException {
                    output.write(out.toByteArray());
                }
            });
View Full Code Here

Examples of org.restlet.resource.OutputRepresentation

            if (ret instanceof PyString) {
                getResponse().setEntity(ret.toString(), mediaType);
            }
            else if (ret instanceof PyList) {
                final PyList list = (PyList) ret;
                getResponse().setEntity(new OutputRepresentation(mediaType) {
                   
                    @Override
                    public void write(OutputStream outputStream) throws IOException {
                        for (Iterator i = list.iterator(); i.hasNext();) {
                            outputStream.write(i.next().toString().getBytes());
                            outputStream.write('\n');
                        }
                    }
                });
            }
            else if (ret instanceof PyIterator) {
                final PyIterator iter = (PyIterator) ret;
                getResponse().setEntity(new OutputRepresentation(mediaType) {
                   
                    @Override
                    public void write(OutputStream outputStream) throws IOException {
                        for (Iterator i = iter.iterator(); i.hasNext();) {
                            outputStream.write(i.next().toString().getBytes());
View Full Code Here

Examples of org.restlet.resource.OutputRepresentation

        }
        catch(IOException e) {
            throw new RestletException("i/o error", Status.SERVER_ERROR_INTERNAL, e);
        }
       
        getResponse().setEntity(new OutputRepresentation(MediaType.TEXT_PLAIN) {
            @Override
            public void write(OutputStream outputStream) throws IOException {
                outputStream.write(output.toByteArray());
            }
        });
View Full Code Here

Examples of org.restlet.resource.OutputRepresentation

   /**
    * Returns an {@link OutputRepresentation} which delegates to {@link #write(Object, OutputStream)}.
    */
   @Override
   public final Representation toRepresentation(final Object object) {
       return new OutputRepresentation(getMediaType()) {
           @Override
           public void write(OutputStream outputStream) throws IOException {
               StreamDataFormat.this.write(object, outputStream);
           }
       };
View Full Code Here

Examples of org.restlet.resource.OutputRepresentation

            mediaType = new MediaType(type);
        }
       
        final Method writeMethod = getClass().getDeclaredMethod("write", Context.class, Scriptable.class, Object[].class, Function.class);
       
        response.setEntity(new OutputRepresentation(mediaType) {
           
            @Override
            public void write(OutputStream outputStream) throws IOException {
                Context cx = CommonJSEngine.enterContext();
                FunctionObject writeFunc = new FunctionObject("bodyWriter", writeMethod, scope);
View Full Code Here

Examples of org.restlet.resource.OutputRepresentation

            //as per KMLMapOutputFormat.produceMap
            Assert.isInstanceOf(XMLTransformerMap.class, webMap);
            final XMLTransformerMapResponse respEncoder = new XMLTransformerMapResponse();
           
            // wrap response in a reslet output rep
            OutputRepresentation output = new OutputRepresentation(
                    new MediaType("application/vnd.google-earth.kml+xml")) {
                public void write(OutputStream outputStream) throws IOException {
                    try {
                        respEncoder.write(webMap, outputStream);
                    } catch (IOException ioe) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.