@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()); }
@Override public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext uc) { Payload payload = new Payload(); reader.moveDown(); while (reader.hasMoreChildren()) { reader.moveDown(); ArrayList<String> statementValues = new ArrayList<>(); while (reader.hasMoreChildren()) { reader.moveDown(); statementValues.add(reader.getValue()); reader.moveUp(); } payload.addStatement(statementValues.get(0), statementValues.get(1), statementValues.get(2), statementValues.get(3)); reader.moveUp(); } reader.moveUp(); return payload; }
PayloadConverter implements Converter { @Override public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext uc) { Payload payload = new Payload(); reader.moveDown(); while (reader.hasMoreChildren()) { reader.moveDown(); ArrayList<String> statementValues = new ArrayList<>(); while (reader.hasMoreChildren()) { reader.moveDown(); statementValues.add(reader.getValue()); reader.moveUp(); } payload.addStatement(statementValues.get(0), statementValues.get(1), statementValues.get(2), statementValues.get(3)); reader.moveUp(); } reader.moveUp(); return payload; } }
PayloadConverter implements Converter { @Override public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext uc) { Payload payload = new Payload(); reader.moveDown(); while (reader.hasMoreChildren()) { reader.moveDown(); ArrayList<String> statementValues = new ArrayList<>(); while (reader.hasMoreChildren()) { reader.moveDown(); statementValues.add(reader.getValue()); reader.moveUp(); } payload.addStatement(statementValues.get(0), statementValues.get(1), statementValues.get(2), statementValues.get(3)); reader.moveUp(); } reader.moveUp(); return payload; }  }
PayloadConverter implements Converter { @Override public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext uc) { Payload payload = new Payload(); reader.moveDown(); while (reader.hasMoreChildren()) { reader.moveDown(); ArrayList<String> statementValues = new ArrayList<>(); while (reader.hasMoreChildren()) { reader.moveDown(); statementValues.add(reader.getValue()); reader.moveUp(); } payload.addStatement(statementValues.get(0), statementValues.get(1), statementValues.get(2), statementValues.get(3)); reader.moveUp(); } reader.moveUp(); return payload; }  @Override void marshal(Object o, HierarchicalStreamWriter writer, MarshallingContext mc); @Override Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext uc); @Override boolean canConvert(Class clazz); }
PayloadConverter implements Converter { @Override public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext uc) { Payload payload = new Payload(); reader.moveDown(); while (reader.hasMoreChildren()) { reader.moveDown(); ArrayList<String> statementValues = new ArrayList<>(); while (reader.hasMoreChildren()) { reader.moveDown(); statementValues.add(reader.getValue()); reader.moveUp(); } payload.addStatement(statementValues.get(0), statementValues.get(1), statementValues.get(2), statementValues.get(3)); reader.moveUp(); } reader.moveUp(); return payload; }  @Override void marshal(Object o, HierarchicalStreamWriter writer, MarshallingContext mc); @Override Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext uc); @Override boolean canConvert(Class clazz);  }