Package org.restlet.resource

Examples of org.restlet.resource.OutputRepresentation


    public JSONFormat(MediaType type){
        myType = type;
    }

    public Representation makeRepresentation(final Object o) {
        return new OutputRepresentation(myType) {
                public void write(OutputStream os) {
                    try {
                        Writer outWriter = new BufferedWriter(new OutputStreamWriter(os));

                        outWriter.flush();
View Full Code Here


    public Representation makeRepresentation(Object context) {
        Element root = new Element(myRootName);
        final Document doc = new Document(root);
        insert(root, context);
        return new OutputRepresentation(MediaType.APPLICATION_XML){
            public void write(OutputStream outputStream){
                try{
                    XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
                    outputter.output(doc, outputStream);
                } catch(IOException ioe){
View Full Code Here

import org.opengis.referencing.crs.CoordinateReferenceSystem;

public class XStreamFormat implements DataFormat {

    public Representation makeRepresentation(final Object data) {
        return new OutputRepresentation(MediaType.APPLICATION_XML){
            public void write(OutputStream outputStream){
                XStream xstream = getXStream();
                xstream.toXML(data, outputStream);
            }
        };
View Full Code Here

            resp.setRedirectRef(new Reference(req.getResourceRef(), l.get(0)));
        }
    }

    private void listFiles(Request req, Response resp) throws Exception {
        resp.setEntity(new OutputRepresentation(MediaType.APPLICATION_JSON) {
            public InputStream getStream() {
                throw new UnsupportedOperationException();
            }

            public void write(OutputStream out) throws IOException {
View Full Code Here

            // delegate to wms reflector
            final GetMapResponse getMapResponse = webMapService
                    .reflect(getMapRequest);

            // 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 {
                        getMapResponse.execute(getMapRequest);
                        getMapResponse.writeTo(outputStream);
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

            }
           
            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

            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

                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

            }
           
            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

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.