Package org.restlet.resource

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


        }
        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

   /**
    * 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

            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

            //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

Related Classes of org.restlet.resource.OutputRepresentation

Copyright © 2018 www.massapicom. 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.