Package it.freedomotic.model.ds

Examples of it.freedomotic.model.ds.Tuples


public class TupleConverter
        implements Converter {

    @Override
    public void marshal(Object o, HierarchicalStreamWriter writer, MarshallingContext mc) {
        Tuples t = (Tuples) o;

        for (int i = 0; i < t.size(); i++) {
            HashMap<String, String> properties = t.getTuple(i);
            Set<Map.Entry<String, String>> entrySet = properties.entrySet();
            writer.startNode("tuple");
            for (Map.Entry<String, String> entry : entrySet) {
                writer.startNode("property");
                // TODO unnecessary explicit .toString() invocation
View Full Code Here


        }
    }

    @Override
    public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext uc) {
        Tuples t = new Tuples();

        //starts from root <tuples>
        while (reader.hasMoreChildren()) {
            reader.moveDown(); //goes down to <tuple>
            HashMap<String, String> map = new HashMap<String, String>();
            //reads properties on the same level
            while (reader.hasMoreChildren()) {
                reader.moveDown();
                map.put(reader.getAttribute("name"),
                        reader.getAttribute("value"));
                reader.moveUp();
            }

            t.add(map);
            reader.moveUp(); //goes up to the next <tuple>
        }

        return t;
    }
View Full Code Here

TOP

Related Classes of it.freedomotic.model.ds.Tuples

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.