Examples of HGridFormat


Examples of org.haystack.io.HGridFormat

        b.addCol("mime");
        b.addCol("read");
        b.addCol("write");
        HGridFormat[] formats = HGridFormat.list();
        for (int i = 0; i < formats.length; ++i) {
            HGridFormat format = formats[i];
            b.addRow(new HVal[] { HStr.make(format.mime), format.reader != null ? HMarker.VAL : null,
                    format.writer != null ? HMarker.VAL : null, });
        }

        writeGrid(writer, b.toGrid());
View Full Code Here

Examples of org.haystack.io.HGridFormat

            reqGrid = postToGrid(req, res);
        if (reqGrid == null)
            return;

        // figure out best format to use for response
        HGridFormat format = toFormat(req);

        // send response
        res.setStatus(HttpServletResponse.SC_OK);
        if (format.mime.startsWith("text/")) {
            res.setCharacterEncoding("UTF-8");
            res.setContentType(format.mime + "; charset=utf-8");
        }
        else
            res.setContentType(format.mime);

        HGridWriter writer = format.makeWriter(res.getOutputStream());
        try {
            onService(db, reqGrid, writer);
        }
        catch (Throwable e) {
            writeGrid(writer, HGridBuilder.errToGrid(e));
View Full Code Here

Examples of org.haystack.io.HGridFormat

            res.sendError(HttpServletResponse.SC_BAD_REQUEST, "Missing 'Content-Type' header");
            return null;
        }

        // check if we have a format that supports reading the content type
        HGridFormat format = HGridFormat.find(mime, false);
        if (format == null || format.reader == null) {
            res.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE, "No format reader available for MIME type: "
                    + mime);
            return null;
        }

        // read the grid
        return format.makeReader(req.getInputStream()).readGrid();
    }
View Full Code Here

Examples of org.haystack.io.HGridFormat

    /**
     * Find the best format to use for encoding response using
     * HTTP content negotiation.
     */
    private HGridFormat toFormat(HttpServletRequest req) {
        HGridFormat format = null;
        String accept = req.getHeader("Accept");
        if (accept != null) {
            String[] mimes = accept.split(",");
            for (int i = 0; i < mimes.length; ++i) {
                format = HGridFormat.find(mimes[i], false);
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.