@Test public void unmarshalParse1() throws Exception { XmlValues values = ReplayParser.parse(new URI("./src/test/resources/org/diirt/datasource/replay/parse1.xml")); assertThat(values.getValues().size(), equalTo(4)); assertThat(values.getValues().get(0), instanceOf(XmlVDouble.class)); XmlVDouble value = (XmlVDouble) values.getValues().get(0); assertThat(value.getValue(), equalTo(0.0)); assertThat(value.getTimestamp(), equalTo(Instant.ofEpochSecond(0, 0))); assertThat(value.getAlarmSeverity(), equalTo(AlarmSeverity.NONE)); assertThat(value.getAlarmName(), equalTo("NONE")); assertThat(value.getTimeUserTag(), equalTo(0)); assertThat(value.getLowerCtrlLimit(), equalTo(-10.0)); assertThat(value.getLowerDisplayLimit(), equalTo(-10.0)); assertThat(value.getLowerAlarmLimit(), equalTo(-9.0)); assertThat(value.getLowerWarningLimit(), equalTo(-8.0)); assertThat(value.getUpperWarningLimit(), equalTo(8.0)); assertThat(value.getUpperAlarmLimit(), equalTo(9.0)); assertThat(value.getUpperCtrlLimit(), equalTo(10.0)); assertThat(value.getUpperDisplayLimit(), equalTo(10.0)); value = (XmlVDouble) values.getValues().get(1); assertThat(value.getValue(), equalTo(1.0)); assertThat(value.getTimestamp(), equalTo(Instant.ofEpochSecond(0, 0).plus(ofMillis(100)))); assertThat(value.getAlarmSeverity(), equalTo(AlarmSeverity.INVALID)); assertThat(value.getAlarmName(), equalTo("RECORD")); assertThat(value.getTimeUserTag(), equalTo(0)); value = (XmlVDouble) values.getValues().get(2); assertThat(value.getValue(), equalTo(2.0)); assertThat(value.getTimestamp(), equalTo(Instant.ofEpochSecond(0, 0).plus(ofMillis(200)))); assertThat(value.getAlarmSeverity(), equalTo(AlarmSeverity.NONE)); assertThat(value.getAlarmName(), equalTo("NONE")); assertThat(value.getTimeUserTag(), equalTo(0)); value = (XmlVDouble) values.getValues().get(3); assertThat(value.getValue(), equalTo(3.0)); assertThat(value.getTimestamp(), equalTo(Instant.ofEpochSecond(0, 0).plus(ofMillis(500)))); assertThat(value.getAlarmSeverity(), equalTo(AlarmSeverity.NONE)); assertThat(value.getAlarmName(), equalTo("NONE")); assertThat(value.getTimeUserTag(), equalTo(0)); }
static XmlValues parse(URI uri) { if (!uri.isAbsolute()) { File current = new File("."); uri = current.toURI().resolve(uri); } try { JAXBContext jaxbCtx = JAXBContext.newInstance(XmlValues.class); Unmarshaller reader = jaxbCtx.createUnmarshaller(); XmlValues values = (XmlValues) reader.unmarshal(uri.toURL()); ReplayValue previousValue = null; for (ReplayValue newValue : values.getValues()) { if (previousValue == null) { previousValue = newValue; } else { newValue.updateNullValues(previousValue); } } return values; } catch (MalformedURLException ex) { throw new RuntimeException("Can't access file", ex); } catch (JAXBException ex) { throw new RuntimeException("Can't parse file", ex); } }
ReplayParser { static XmlValues parse(URI uri) { if (!uri.isAbsolute()) { File current = new File("."); uri = current.toURI().resolve(uri); } try { JAXBContext jaxbCtx = JAXBContext.newInstance(XmlValues.class); Unmarshaller reader = jaxbCtx.createUnmarshaller(); XmlValues values = (XmlValues) reader.unmarshal(uri.toURL()); ReplayValue previousValue = null; for (ReplayValue newValue : values.getValues()) { if (previousValue == null) { previousValue = newValue; } else { newValue.updateNullValues(previousValue); } } return values; } catch (MalformedURLException ex) { throw new RuntimeException("Can't access file", ex); } catch (JAXBException ex) { throw new RuntimeException("Can't parse file", ex); } } }
ReplayParser { static XmlValues parse(URI uri) { if (!uri.isAbsolute()) { File current = new File("."); uri = current.toURI().resolve(uri); } try { JAXBContext jaxbCtx = JAXBContext.newInstance(XmlValues.class); Unmarshaller reader = jaxbCtx.createUnmarshaller(); XmlValues values = (XmlValues) reader.unmarshal(uri.toURL()); ReplayValue previousValue = null; for (ReplayValue newValue : values.getValues()) { if (previousValue == null) { previousValue = newValue; } else { newValue.updateNullValues(previousValue); } } return values; } catch (MalformedURLException ex) { throw new RuntimeException("Can't access file", ex); } catch (JAXBException ex) { throw new RuntimeException("Can't parse file", ex); } } private  ReplayParser(); }
ReplayParser { static XmlValues parse(URI uri) { if (!uri.isAbsolute()) { File current = new File("."); uri = current.toURI().resolve(uri); } try { JAXBContext jaxbCtx = JAXBContext.newInstance(XmlValues.class); Unmarshaller reader = jaxbCtx.createUnmarshaller(); XmlValues values = (XmlValues) reader.unmarshal(uri.toURL()); ReplayValue previousValue = null; for (ReplayValue newValue : values.getValues()) { if (previousValue == null) { previousValue = newValue; } else { newValue.updateNullValues(previousValue); } } return values; } catch (MalformedURLException ex) { throw new RuntimeException("Can't access file", ex); } catch (JAXBException ex) { throw new RuntimeException("Can't parse file", ex); } } private  ReplayParser();  }
ReplayParser { static XmlValues parse(URI uri) { if (!uri.isAbsolute()) { File current = new File("."); uri = current.toURI().resolve(uri); } try { JAXBContext jaxbCtx = JAXBContext.newInstance(XmlValues.class); Unmarshaller reader = jaxbCtx.createUnmarshaller(); XmlValues values = (XmlValues) reader.unmarshal(uri.toURL()); ReplayValue previousValue = null; for (ReplayValue newValue : values.getValues()) { if (previousValue == null) { previousValue = newValue; } else { newValue.updateNullValues(previousValue); } } return values; } catch (MalformedURLException ex) { throw new RuntimeException("Can't access file", ex); } catch (JAXBException ex) { throw new RuntimeException("Can't parse file", ex); } } private  ReplayParser();   }