Package it.freedomotic.reactions

Examples of it.freedomotic.reactions.Payload


    private void save(Trigger t) {
        if (table.getCellEditor() != null) {
            table.getCellEditor().stopCellEditing();
        }

        Payload payload = new Payload();

        for (int r = 0; r < model.getRowCount(); r++) {
            boolean saveCurrent = true;

            for (int k = 0; k < 4; k++) {
                String test = model.getValueAt(r, 0).toString();

                if ((test == null) || test.equals("")) {
                    saveCurrent = false;

                    break;
                }
            }

            if (saveCurrent) {
                payload.addStatement(model.getValueAt(r, 0).toString(),
                        model.getValueAt(r, 1).toString(),
                        model.getValueAt(r, 2).toString(),
                        model.getValueAt(r, 3).toString());
            }
        }
View Full Code Here


    }

    @Test
    public void testMarshal() {
        System.out.println("Testing Payload to XML");
        Payload payload = new Payload();
        payload.addStatement("protocol", "SNT084Eth8R8I");
        payload.addStatement("SET", "behaviorValue", "EQUALS", "@event.isOn");
        String marshal = xstream.toXML(payload);
        marshal = marshal.replace("\n", "");
        marshal = marshal.replace(" ", "");
        assertEquals(marshal, xml);
    }
View Full Code Here

    }

    @Test
    public void testUnmarshal() {
        System.out.println("Testing XML to Payload");
        Payload payload = (Payload) xstream.fromXML(xml);
        assertEquals("protocol", payload.getStatements("protocol").get(0).getAttribute());
        assertEquals("SNT084Eth8R8I", payload.getStatements("protocol").get(0).getValue());
        assertEquals("behaviorValue", payload.getStatements("behaviorValue").get(0).getAttribute());
        assertEquals("@event.isOn", payload.getStatements("behaviorValue").get(0).getValue());                 
    }
View Full Code Here

    @Test
    public void testGetComponent() {
        result = new Trigger();

        Payload p = new Payload();

        for (int row = 0; row < panel.getRows(); row++) {
            for (int col = 0; col < panel.getColumns(); col++) {
                String logical = panel.getComponent(row, 0);
                String attribute = panel.getComponent(row, 1);
                String operand = panel.getComponent(row, 2);
                String value = panel.getComponent(row, 3);
                p.addStatement(logical, attribute, operand, value);
            }
        }

        result.setName(trigger.getName());
        result.setChannel(trigger.getChannel());
View Full Code Here

public class PayloadConverter
        implements Converter {

    @Override
    public void marshal(Object o, HierarchicalStreamWriter writer, MarshallingContext mc) {
        Payload payload = (Payload) o;
        writer.startNode("payload");
        Iterator<Statement> it = payload.iterator();
        while (it.hasNext()) {
            Statement statement = it.next();
            writer.startNode("it.freedomotic.reactions.Statement");
            writer.startNode("logical");
            writer.setValue(statement.getLogical());
View Full Code Here

        writer.endNode(); //</payload>
    }

    @Override
    public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext uc) {
        Payload payload = new Payload();
        reader.moveDown(); //goes down to <payload>

        while (reader.hasMoreChildren()) { //<statements> are the childs of payload
            reader.moveDown();

            ArrayList<String> statementValues = new ArrayList<String>();

            while (reader.hasMoreChildren()) { //childs of statement (logical, attribute, ...)
                reader.moveDown();
                statementValues.add(reader.getValue());
                reader.moveUp();
            }

            payload.addStatement(statementValues.get(0),
                    statementValues.get(1),
                    statementValues.get(2),
                    statementValues.get(3));
            reader.moveUp(); //next <statement>
        } //no more <statements> (childs of payload)
View Full Code Here

    /**
     * Creates an empty resolution context
     */
    public Resolver() {
        this.context = new Payload();
    }
View Full Code Here

        t.getPayload().merge(context);
    }

    public void addContext(final String PREFIX, final Config aContext) {
        if (context == null) {
            context = new Payload();
        }

        //registering the new prefix
        if (!prefixes.contains(PREFIX)) {
            prefixes.add(PREFIX);
View Full Code Here

        }
    }

    public void addContext(final String PREFIX, final Map<String, String> aContext) {
        if (context == null) {
            context = new Payload();
        }

        //registering the new prefix
        if (!prefixes.contains(PREFIX)) {
            prefixes.add(PREFIX);
View Full Code Here

        }
    }

    public void addContext(final String PREFIX, final Payload aContext) {
        if (context == null) {
            context = new Payload();
        }

        //registering the new prefix
        if (!prefixes.contains(PREFIX)) {
            prefixes.add(PREFIX);
View Full Code Here

TOP

Related Classes of it.freedomotic.reactions.Payload

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.