Package org.syrup.helpers

Examples of org.syrup.helpers.XMLOutput


     */
    public static int match(WorkSpace sp, PTaskTemplate template,
        OutputStream out) throws Exception
    {

        XMLOutput o = new XMLOutput();
        SerializationHandler h = o.wrap(out);

        PTask p[] = sp.match(template);

        // Outputs the fetched PTasks to the OutputStream in XML format.
        o.startDocument("match", h);

        for (int i = 0; i < p.length; i++)
        {
            o.output(p[i], h);
        }

        o.endDocument("match", h);

        return p.length;
    }
View Full Code Here


    public static int match(WorkSpace sp, LogEntryTemplate template,
        OutputStream out) throws Exception
    {

        XMLOutput o = new XMLOutput();
        SerializationHandler h = o.wrap(out);

        LogEntry l[] = sp.match(template);

        // Outputs the fetched PTasks to the OutputStream in XML format.
        o.startDocument("log", h);

        for (int i = 0; i < l.length; i++)
        {
            o.output(l[i], h);
        }

        o.endDocument("log", h);

        return l.length;
    }
View Full Code Here

     * @return The number of matched Contexts.
     */
    public static int get(WorkSpace sp, PTaskTemplate template, OutputStream out)
        throws Exception
    {
        XMLOutput o = new XMLOutput();
        SerializationHandler h = o.wrap(out);

        org.syrup.Context c[] = sp.get(template);

        Hashtable parents = new Hashtable();

        // Make a parent Task table
        for (int i = 0; i < c.length; i++)
        {
            org.syrup.Context pc = c[i];
            if (pc.task().isParent())
            {
                Hashtable pn = new Hashtable();
                pn.put("_parent", pc);
                parents.put(pc.task().key(), pn);
            }
        }

        // Put the child Tasks underneath the parent Tasks.
        for (int i = 0; i < c.length; i++)
        {
            org.syrup.Context ct = c[i];
            if (!ct.task().isParent())
            {
                Hashtable pn = (Hashtable) parents.get(ct.task().parentKey());
                if (pn != null)
                {
                    pn.put(ct.task().key(), ct);
                }
                else
                {
                    parents.put(ct.task().key(), ct);
                }
            }
        }

        Hashtable cl = new Hashtable(parents);
        Iterator keys = cl.keySet().iterator();

        // Build hierarchy
        while (keys.hasNext())
        {
            String k = (String) keys.next();
            Object ph = (Object) cl.get(k);
            if (ph instanceof Hashtable)
            {
                Hashtable phh = (Hashtable) ph;
                org.syrup.Context ct = (org.syrup.Context) phh.get("_parent");

                Hashtable oo = (Hashtable) cl.get(ct.task().parentKey());

                if (oo != null)
                {
                    parents.remove(k);
                    oo.put(k, phh);
                }
            }
        }

        // Outputs the fetched Contexts to the OutputStream in XML format.
        o.startDocument("get", h);
        output(parents, o, h);
        o.endDocument("get", h);

        return c.length;
    }
View Full Code Here

TOP

Related Classes of org.syrup.helpers.XMLOutput

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.