/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Override public Accounting load() throws IOException { final Path dataFile = getDataFile(); log.info(">>>> loading data from {}...", dataFile); try (final InputStream is = new FileInputStream(dataFile.toFile())) { return accounting.as(Unmarshallable).unmarshal(is); } }
/******************************************************************************************************************* * * * ******************************************************************************************************************/ private void loadArchive() throws IOException { log.info("loadArchive()"); archive.clear(); final @Cleanup InputStream is = persistenceFile.getInputStream(); archive = archive.as(Unmarshallable).unmarshal(is); is.close(); }
@Override @Nonnull public UniformityArchive unmarshal (final @Nonnull InputStream is) throws IOException { final UniformityArchive archive = new UniformityArchive(); for (;;) { try { final UniformityMeasurements measurements = new UniformityMeasurements().as(Unmarshallable).unmarshal(is); archive.add(measurements); } catch (EOFException e) { break; // ok, finished } } return archive; } }
/******************************************************************************************************************* * ******************************************************************************************************************/ @Nonnull private DefaultLayout loadLayout (final @Nonnull ResourceFile layoutFile) throws IOException { log.trace(">>>> reading layout from {}...", layoutFile.getPath().asString()); final @Cleanup InputStream is = layoutFile.getInputStream(); return modelFactory.createLayout().build().as(Unmarshallable).unmarshal(is); } }
@Cleanup final InputStream is = propertyFile.getInputStream(); final ResourceProperties tempProperties = modelFactory.createProperties().build().as(Unmarshallable).unmarshal(is);
/******************************************************************************************************************* * * ******************************************************************************************************************/ @Nonnull private ResourceProperties loadProperties() throws IOException { final ResourceFile file = getFile(); log.debug("loadProperties() for {}", file.getPath().asString()); ResourceProperties properties = modelFactory.createProperties().withPropertyResolver(propertyResolver).build(); try { final ResourceFile propertyFile = file.findChildren().withName("Properties.xml").result(); // FIXME reuse the inheritance helper // log.trace(">>>> reading properties from {} ({})...", propertyFile.getPath().asString(), locale); @Cleanup final InputStream is = propertyFile.getInputStream(); final ResourceProperties tempProperties = // modelFactory.createProperties().build().as(Unmarshallable).unmarshal(is); modelFactory.createProperties().withPropertyResolver(propertyResolver).build().as(Unmarshallable).unmarshal(is); // log.trace(">>>>>>>> read properties: {} ({})", tempProperties, locale); properties = properties.merged(tempProperties); } catch (NotFoundException e) { // ok, no properties } return properties; } }