@Test public void getValueTest() { Optional<? extends VTLValue> search = new CSVFileEnvironment().getValue(CSVALIAS); assertTrue(search.isPresent(), "Cannot find " + CSVALIAS); assertTrue(DataSet.class.isInstance(search.get()), CSVALIAS + " is not a DataSet"); DataSet dataset = (DataSet) search.get(); assertEquals(3, dataset.getMetadata().size(), "Wrong number of columns"); assertTrue(dataset.getMetadata().contains(IDENTIFIER), "Missing IDENTIFIER Column"); assertTrue(dataset.getMetadata().contains(MEASURE), "Missing MEASURE Column"); assertTrue(dataset.getMetadata().contains(ATTRIBUTE), "Missing ATTRIBUTE Column"); try (Stream<DataPoint> stream = dataset.stream()) { assertEquals(7, stream.count(), "Wrong number of rows"); } }
@Override public Optional<VTLValue> getValue(String name) { if (!contains(name)) return Optional.empty(); String fileName = name.substring(4); LOGGER.debug("Looking for csv file '{}'", fileName); try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), StandardCharsets.UTF_8))) { final DataSetMetadata structure = new DataStructureBuilder(extractMetadata(reader.readLine().split(",")).getKey()).build(); return Optional.of(new LightFDataSet<>(structure, this::streamFileName, fileName)); } catch (IOException e) { throw new VTLNestedException("Exception while reading " + fileName, e); } }
CSVFileEnvironment implements Environment { @Override public Optional<VTLValue> getValue(String name) { if (!contains(name)) return Optional.empty(); String fileName = name.substring(4); LOGGER.debug("Looking for csv file '{}'", fileName); try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), StandardCharsets.UTF_8))) { final DataSetMetadata structure = new DataStructureBuilder(extractMetadata(reader.readLine().split(",")).getKey()).build(); return Optional.of(new LightFDataSet<>(structure, this::streamFileName, fileName)); } catch (IOException e) { throw new VTLNestedException("Exception while reading " + fileName, e); } } }
CSVFileEnvironment implements Environment { @Override public Optional<VTLValue> getValue(String name) { if (!contains(name)) return Optional.empty(); String fileName = name.substring(4); LOGGER.debug("Looking for csv file '{}'", fileName); try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), StandardCharsets.UTF_8))) { final DataSetMetadata structure = new DataStructureBuilder(extractMetadata(reader.readLine().split(",")).getKey()).build(); return Optional.of(new LightFDataSet<>(structure, this::streamFileName, fileName)); } catch (IOException e) { throw new VTLNestedException("Exception while reading " + fileName, e); } }  }
CSVFileEnvironment implements Environment { @Override public Optional<VTLValue> getValue(String name) { if (!contains(name)) return Optional.empty(); String fileName = name.substring(4); LOGGER.debug("Looking for csv file '{}'", fileName); try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), StandardCharsets.UTF_8))) { final DataSetMetadata structure = new DataStructureBuilder(extractMetadata(reader.readLine().split(",")).getKey()).build(); return Optional.of(new LightFDataSet<>(structure, this::streamFileName, fileName)); } catch (IOException e) { throw new VTLNestedException("Exception while reading " + fileName, e); } }  @Override boolean contains(String name); @Override Optional<VTLValue> getValue(String name); @Override Optional<VTLValueMetadata> getValueMetadata(String name); }
CSVFileEnvironment implements Environment { @Override public Optional<VTLValue> getValue(String name) { if (!contains(name)) return Optional.empty(); String fileName = name.substring(4); LOGGER.debug("Looking for csv file '{}'", fileName); try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), StandardCharsets.UTF_8))) { final DataSetMetadata structure = new DataStructureBuilder(extractMetadata(reader.readLine().split(",")).getKey()).build(); return Optional.of(new LightFDataSet<>(structure, this::streamFileName, fileName)); } catch (IOException e) { throw new VTLNestedException("Exception while reading " + fileName, e); } }  @Override boolean contains(String name); @Override Optional<VTLValue> getValue(String name); @Override Optional<VTLValueMetadata> getValueMetadata(String name);  }