Example usage for com.fasterxml.jackson.databind MappingIterator readAll

List of usage examples for com.fasterxml.jackson.databind MappingIterator readAll

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind MappingIterator readAll.

Prototype

public List<T> readAll() throws IOException 

Source Link

Document

Convenience method for reading all entries accessible via this iterator

Usage

From source file:ed.cracken.code.SimpleTestExp1.java

public static List<Map<?, ?>> readObjectsFromCsv(String file) throws IOException {
    CsvSchema bootstrap = CsvSchema.emptySchema().withHeader();
    CsvMapper csvMapper = new CsvMapper();
    MappingIterator<Map<?, ?>> mappingIterator = csvMapper.reader(Map.class).with(bootstrap).readValues(file);

    return mappingIterator.readAll();
}

From source file:org.nuxeo.connect.tools.report.viewer.Viewer.java

public static PrintStream printThreadDeadlocked(MappingIterator<Long> values, PrintStream out)
        throws IOException {
    out.print("deadlocked " + Arrays.toString(values.readAll().toArray()));
    return out;/*from w  w  w. ja  va 2 s .c  o  m*/
}

From source file:org.nuxeo.connect.tools.report.viewer.Viewer.java

public static PrintStream printThreadMonitorDeadlocked(MappingIterator<Long> values, PrintStream out)
        throws IOException {
    out.print("monitor deadlocked " + Arrays.toString(values.readAll().toArray()));
    return out;/*from w  w w.  j ava2  s. co  m*/
}

From source file:org.apache.nifi.processors.ParseCSV.ParseCSV.java

public static List<Map<?, ?>> readObjectsFromCsv(InputStream is) throws IOException {
    CsvSchema bootstrap = CsvSchema.emptySchema().withHeader();
    CsvMapper csvMapper = new CsvMapper();
    MappingIterator<Map<?, ?>> mappingIterator = csvMapper.reader(Map.class).with(bootstrap).readValues(is);

    return mappingIterator.readAll();
}

From source file:org.opentestsystem.ap.ivs.service.ValidationUtility.java

public List<ErrorReport> parseErrorReport(final Path reportFolder) {
    final Path errorFilePath = reportFolder.resolve(this.ivsProperties.getErrorReportFileName());
    try {/*ww w . ja va  2  s.  co m*/
        final MappingIterator<ErrorReport> results = new CsvMapper().readerWithTypedSchemaFor(ErrorReport.class)
                .readValues(errorFilePath.toFile());
        return results.readAll();
    } catch (IOException e) {
        throw new SystemException("Error converting item history list to CSV", e);
    }
}

From source file:datadidit.helpful.hints.processors.csv.converter.ConvertCSVToJSON.java

public List<Map<?, ?>> readObjectsFromCsv(String fileContent) throws JsonProcessingException, IOException {
    CsvMapper csvMapper = new CsvMapper();
    MappingIterator<Map<?, ?>> mappingIterator = csvMapper.readerFor(Map.class).with(schema)
            .readValues(fileContent);/*  ww  w.j av a2  s. co  m*/

    return this.fixMap(mappingIterator.readAll());
}

From source file:com.streamsets.datacollector.execution.store.FilePipelineStateStore.java

@Override
public List<PipelineState> getHistory(String pipelineName, String rev, boolean fromBeginning)
        throws PipelineStoreException {
    if (!pipelineDirExists(pipelineName, rev) || !pipelineStateHistoryFileExists(pipelineName, rev)) {
        return Collections.emptyList();
    }/*from  w ww  . j a  v  a2  s .com*/
    try (Reader reader = new FileReader(getPipelineStateHistoryFile(pipelineName, rev))) {
        ObjectMapper objectMapper = ObjectMapperFactory.get();
        JsonParser jsonParser = objectMapper.getFactory().createParser(reader);
        MappingIterator<PipelineStateJson> pipelineStateMappingIterator = objectMapper.readValues(jsonParser,
                PipelineStateJson.class);
        List<PipelineStateJson> pipelineStateJsons = pipelineStateMappingIterator.readAll();
        Collections.reverse(pipelineStateJsons);
        if (fromBeginning) {
            return BeanHelper.unwrapPipelineStatesNewAPI(pipelineStateJsons);
        } else {
            int toIndex = pipelineStateJsons.size() > 100 ? 100 : pipelineStateJsons.size();
            return BeanHelper.unwrapPipelineStatesNewAPI(pipelineStateJsons.subList(0, toIndex));
        }
    } catch (IOException e) {
        throw new PipelineStoreException(ContainerError.CONTAINER_0115, pipelineName, rev, e.toString(), e);
    }
}

From source file:org.gitia.jdataanalysis.JDataAnalysis.java

private void obtainData() {
    try {/*from w  w  w  . j ava2 s. c o m*/
        CSVFormat csvf;
        if (this.isHeader) {
            csvf = CSVFormat.DEFAULT.withHeader();

            parser = new CSVParser(new FileReader(path), csvf);
            datos = IteratorUtils.toList(parser.iterator());
            data = new String[datos.size()][datos.get(0).size()];
            for (int i = 0; i < datos.size(); i++) {
                for (int j = 0; j < datos.get(0).size(); j++) {
                    data[i][j] = datos.get(i).get(j);
                }
            }

        } else {
            csvf = CSVFormat.DEFAULT.withIgnoreHeaderCase(isHeader);

            CsvMapper mapper = new CsvMapper();
            // important: we need "array wrapping" (see next section) here:
            mapper.enable(CsvParser.Feature.WRAP_AS_ARRAY);
            File csvFile = new File("src/main/resources/handwrittennumbers/mnist_train_in.csv"); // or from String, URL etc
            MappingIterator<double[]> it = mapper.readerFor(double[].class).readValues(csvFile);
            int a = 1;
            List<double[]> listData = it.readAll();
            double[][] data = new double[listData.size()][listData.get(0).length];
            for (int i = 0; i < listData.size(); i++) {
                data[i] = listData.get(i);
                System.out.println(a++ + ":\t");
            }
            SimpleMatrix A = new SimpleMatrix(data);
            A.print();

        }
        parser = new CSVParser(new FileReader(path), csvf);
        datos = IteratorUtils.toList(parser.iterator());
        data = new String[datos.size()][datos.get(0).size()];
        for (int i = 0; i < datos.size(); i++) {
            for (int j = 0; j < datos.get(0).size(); j++) {
                data[i][j] = datos.get(i).get(j);
            }
        }
    } catch (IOException ex) {
        Logger.getLogger(JDataAnalysis.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:org.wso2.developerstudio.datamapper.diagram.schemagen.util.SchemaGeneratorForCSV.java

/**
 * Read objects from CSV/*from  ww w .j  a va2s. c  om*/
 * 
 * @param content
 * @return
 * @throws IOException
 */
public List<Map<String, String>> readObjectsFromCsv(String content) throws IOException {
    CsvMapper mapper = new CsvMapper();
    CsvSchema schema = CsvSchema.emptySchema().withHeader();
    MappingIterator<Map<String, String>> it = mapper.readerFor(Map.class).with(schema).readValues(content);
    return it.readAll();
}