Examples of HDictBuilder


Examples of org.haystack.HDictBuilder

    //////////////////////////////////////////////////////////////////////////
    // Include
    //////////////////////////////////////////////////////////////////////////

    public void testInclude() {
        HDict a = new HDictBuilder().add("dis", "a").add("num", 100).add("foo", 99)
                .add("date", HDate.make(2011, 10, 5)).toDict();

        HDict b = new HDictBuilder().add("dis", "b").add("num", 200).add("foo", 88)
                .add("date", HDate.make(2011, 10, 20)).add("bar").add("ref", HRef.make("a")).toDict();

        HDict c = new HDictBuilder().add("dis", "c").add("num", 300).add("ref", HRef.make("b")).add("bar").toDict();

        final Map<String, HDict> db = new HashMap<String, HDict>();
        db.put("a", a);
        db.put("b", b);
        db.put("c", c);
View Full Code Here

Examples of org.haystack.HDictBuilder

    public void test() {
        verifyGrid("ver:\"2.0\"\n" + "fooBar33\n" + "\n", null, new Object[] { "fooBar33", null, }, new HVal[][] {});

        verifyGrid("ver:\"2.0\" tag foo:\"bar\"\n" + "xyz\n" + "\"val\"\n" + "\n",
                new HDictBuilder().add("tag", HMarker.VAL).add("foo", HStr.make("bar")).toDict(), new Object[] { "xyz",
                        null, }, new HVal[][] { new HVal[] { HStr.make("val"), }, });

        verifyGrid("ver:\"2.0\"\n" + "val\n" + "N\n" + "\n", null, new Object[] { "val", null, },
                new HVal[][] { new HVal[] { null, }, });

        verifyGrid(
                "ver:\"2.0\"\n" + "a,b\n" + "1,2\n" + "3,4\n" + "\n",
                null,
                new Object[] { "a", null, "b", null, },
                new HVal[][] { new HVal[] { HNum.make(1.0), HNum.make(2.0), },
                        new HVal[] { HNum.make(3.0), HNum.make(4.0), }, });

        verifyGrid(
                "ver:\"2.0\" bg: Bin(image/jpeg) mark\n"
                        + "file1 dis:\"F1\" icon: Bin(image/gif),file2 icon: Bin(image/jpg)\n" + "Bin(text/plain),N\n"
                        + "4,Bin(image/png)\n" + "Bin(text/html; a=foo; bar=\"sep\"),Bin(text/html; charset=utf8)\n",
                new HDictBuilder().add("bg", HBin.make("image/jpeg")).add("mark", HMarker.VAL).toDict(),
                new Object[] { "file1",
                        new HDictBuilder().add("icon", HBin.make("image/gif")).add("dis", HStr.make("F1")).toDict(),
                        "file2", new HDictBuilder().add("icon", HBin.make("image/jpg")).toDict(), },
                new HVal[][] {
                        new HVal[] { HBin.make("text/plain"), null, },
                        new HVal[] { HNum.make(4.0), HBin.make("image/png"), },
                        new HVal[] { HBin.make("text/html; a=foo; bar=\"sep\""), HBin.make("text/html; charset=utf8"), }, });
View Full Code Here

Examples of org.haystack.HDictBuilder

    /**
     * Get the about metadata which should contain following tags:
     */
    @Override
    public final HDict about() {
        return new HDictBuilder().add(onAbout()).add("haystackVersion", "2.0").add("serverTime", HDateTime.now())
                .add("serverBootTime", this.bootTime).add("tz", HTimeZone.getDefault().name).toDict();
    }
View Full Code Here

Examples of org.haystack.HDictBuilder

        // checking
        if (!r.start.tz.equals(tz))
            throw new RuntimeException("range.tz != rec: " + r.start.tz + " != " + tz);

        // build and return result grid
        HDict meta = new HDictBuilder().add("id", id).add("hisStart", r.start).add("hisEnd", r.end).toDict();
        writer.writeMeta(meta);

        HDictBuilder dictBuilder = new HDictBuilder();
        HCol[] cols = { new HCol(0, "ts", dictBuilder.toDict()), new HCol(1, "val", dictBuilder.toDict()), };
        writer.writeCols(cols);

        // route to subclass
        onHisRead(rec, r, writer, cols);
View Full Code Here

Examples of org.haystack.HDictBuilder

     * point's configured "tz" tag. If duplicate or out-of-order items are
     * inserted then they must be gracefully merged.
     */
    @Override
    public void hisWrite(HRef id, HHisItem[] items) {
        HDict meta = new HDictBuilder().add("id", id).toDict();
        HGrid req = HGridBuilder.hisItemsToGrid(meta, items);
        call("hisWrite", req);
    }
View Full Code Here

Examples of org.haystack.HDictBuilder

    /**
     * Invoke a remote action using the "invokeAction" REST operation.
     */
    public HGrid invokeAction(HRef id, String action, HDict args) {
        HDict meta = new HDictBuilder().add("id", id).add("action", action).toDict();
        HGrid req = HGridBuilder.dictsToGrid(meta, new HDict[] { args });
        return call("invokeAction", req);
    }
View Full Code Here

Examples of org.haystack.HDictBuilder

        }
    }

    /** Read set of name/value tags as dictionary */
    public HDict readDict() {
        HDictBuilder b = new HDictBuilder();
        readMeta(b);
        if (cur >= 0)
            throw errChar("Expected end of stream");
        return b.toDict();
    }
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.