Package org.haystack.io

Examples of org.haystack.io.HZincReader


        verifyZinc("dis  :  \"Bob\"  bday : 1970-06-03  marker",
                new HDictBuilder().add("dis", "Bob").add("bday", HDate.make(1970, 6, 3)).add("marker").toDict());
    }

    void verifyZinc(String s, HDict tags) {
        HDict x = new HZincReader(s).readDict();
        if (tags.size() <= 1)
            verifyEq(tags.toZinc(), s);
        verifyEq(x, tags);
    }
View Full Code Here


     * Decode a string into a HFilter; return null or throw
     * ParseException if not formatted correctly
     */
    public static HFilter make(String s, boolean checked) {
        try {
            return new HZincReader(s).readFilter();
        }
        catch (Exception e) {
            if (!checked)
                return null;
            if (e instanceof ParseException)
View Full Code Here

        verifyEq(val.toZinc(), s);
        verifyEq(read(s), val);
    }

    public HVal read(String s) {
        return new HZincReader(s).readScalar();
    }
View Full Code Here

        for (int i = 0; i < cols.length; ++i)
            if (cols[i] == null)
                cols[i] = HDict.EMPTY;

        // read from zinc
        HGrid grid = new HZincReader(str).readGrid();
        verifyGridEq(grid, meta, cols, rows);

        // write grid and verify we can parse that too
        String writeStr = HZincWriter.gridToString(grid);
        HGrid writeGrid = new HZincReader(writeStr).readGrid();
        verifyGridEq(writeGrid, meta, cols, rows);
    }
View Full Code Here

        // parse scalars
        int comma = str.indexOf(',');
        HVal start = null, end = null;
        if (comma < 0) {
            start = new HZincReader(str).readScalar();
        }
        else {
            start = new HZincReader(str.substring(0, comma)).readScalar();
            end = new HZincReader(str.substring(comma + 1)).readScalar();
        }

        // figure out what we parsed for start,end
        if (start instanceof HDate) {
            if (end == null)
View Full Code Here

                c.get(Calendar.MILLISECOND));
    }

    /** Parse from string fomat "hh:mm:ss.FF" or raise ParseException */
    public static HTime make(String s) {
        HVal val = new HZincReader(s).readScalar();
        if (val instanceof HTime)
            return (HTime) val;
        throw new ParseException(s);
    }
View Full Code Here

     * requests failed, then raise CallErrException for first failure.
     */
    public HGrid[] evalAll(HGrid req, boolean checked) {
        String reqStr = HZincWriter.gridToString(req);
        String resStr = postString("evalAll", reqStr);
        HGrid[] res = new HZincReader(resStr).readGrids();
        if (checked) {
            for (int i = 0; i < res.length; ++i)
                if (res[i].isErr())
                    throw new CallErrException(res[i]);
        }
View Full Code Here

    }

    private HGrid postGrid(String op, HGrid req) {
        String reqStr = HZincWriter.gridToString(req);
        String resStr = postString(op, reqStr);
        return new HZincReader(resStr).readGrid();
    }
View Full Code Here

            String name = entry.getKey();
            String valStr = entry.getValue()[0];

            HVal val;
            try {
                val = new HZincReader(valStr).readScalar();
            }
            catch (Exception e) {
                val = HStr.make(valStr);
            }
            b.add(name, val);
View Full Code Here

        return new HDate(c.get(Calendar.YEAR), c.get(Calendar.MONTH) + 1, c.get(Calendar.DAY_OF_MONTH));
    }

    /** Parse from string fomat "YYYY-MM-DD" or raise ParseException */
    public static HDate make(String s) {
        HVal val = new HZincReader(s).readScalar();
        if (val instanceof HDate)
            return (HDate) val;
        throw new ParseException(s);
    }
View Full Code Here

TOP

Related Classes of org.haystack.io.HZincReader

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.