當前位置: 首頁>>代碼示例>>Java>>正文


Java MappingIterator.readAll方法代碼示例

本文整理匯總了Java中com.fasterxml.jackson.databind.MappingIterator.readAll方法的典型用法代碼示例。如果您正苦於以下問題:Java MappingIterator.readAll方法的具體用法?Java MappingIterator.readAll怎麽用?Java MappingIterator.readAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.fasterxml.jackson.databind.MappingIterator的用法示例。


在下文中一共展示了MappingIterator.readAll方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readChartCsv

import com.fasterxml.jackson.databind.MappingIterator; //導入方法依賴的package包/類
/**
 * Uses a {@link CsvMapper} to reading a String representing a CSV representation of a PDF
 * Chart, returning a list of {@link ChartCharacter}s
 */
static List<ChartCharacter> readChartCsv(String csvChart) throws ChartParserException {
    CsvSchema schema = CsvSchema.emptySchema()
            .withHeader()
            .withColumnSeparator('|')
            .withoutQuoteChar();

    try {
        MappingIterator<ChartCharacter> mappingIterator =
                getCsvMapper().readerFor(ChartCharacter.class)
                        .with(schema)
                        .readValues(csvChart);
        return mappingIterator.readAll();
    } catch (Exception e) {
        throw new ChartParserException("Error deserializing the Chart CSV data", e);
    }
}
 
開發者ID:robinhowlett,項目名稱:chart-parser,代碼行數:21,代碼來源:ChartParser.java

示例2: csvIteratorExistingHeaders

import com.fasterxml.jackson.databind.MappingIterator; //導入方法依賴的package包/類
private Iterable<Map<String,String>> csvIteratorExistingHeaders(String filename, char escapeChar) throws JsonProcessingException, IOException {
	//InputStream in = new FileInputStream(filename, "UTF-8");
	InputStreamReader in = new InputStreamReader(new FileInputStream(filename), "ISO-8859-1");
       MappingIterator<Map<String, String>> iterator = new CsvMapper()
               .readerFor(Map.class)
               .with(CsvSchema.emptySchema().withColumnSeparator(',').withHeader().withEscapeChar(escapeChar))
               .readValues(in);
       List<Map<String,String>> sortable = iterator.readAll();
       if (sortable.get(0).containsKey("discussion_answer_created_ts")) {
       		sortable.sort(new Comparator<Map<String,String>>() {
       		    @Override
       		    public int compare(Map<String,String> lhs, Map<String,String> rhs) {
       		        return lhs.get("discussion_answer_created_ts").compareTo(rhs.get("discussion_answer_created_ts"));
       		    }
       		} );
       }
       return () -> sortable.iterator();
}
 
開發者ID:DiscourseDB,項目名稱:discoursedb-core,代碼行數:19,代碼來源:CourseraConverter.java

示例3: getHistory

import com.fasterxml.jackson.databind.MappingIterator; //導入方法依賴的package包/類
@Override
public List<PipelineState> getHistory(String pipelineName, String rev, boolean fromBeginning) throws PipelineStoreException {
  if (!pipelineDirExists(pipelineName, rev) || !pipelineStateHistoryFileExists(pipelineName, rev)) {
    return Collections.emptyList();
  }
  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);
  }
}
 
開發者ID:streamsets,項目名稱:datacollector,代碼行數:23,代碼來源:FilePipelineStateStore.java

示例4: parse

import com.fasterxml.jackson.databind.MappingIterator; //導入方法依賴的package包/類
/**
 * Parse the data from the given CSV file into a List of Maps, where the key is the
 * column name. Uses a LinkedHashMap specifically to ensure the order of columns is preserved in
 * the resulting maps.
 * 
 * @param csvData
 *          Raw CSV data
 * @return parsed data
 * @throws IOException
 *           if any exception occurs while parsing the data
 */
public static List<LinkedHashMap<String, String>> parse(String csvData) throws IOException {
  // Read schema from the first line; start with bootstrap instance
  // to enable reading of schema from the first line
  // NOTE: reads schema and uses it for binding
  CsvMapper mapper = new CsvMapper();
  // use first row as header; otherwise defaults are fine
  CsvSchema schema = CsvSchema.emptySchema().withHeader();

  MappingIterator<LinkedHashMap<String, String>> it = mapper.readerFor(LinkedHashMap.class)
      .with(schema).readValues(csvData);

  return it.readAll();
}
 
開發者ID:synthetichealth,項目名稱:synthea_java,代碼行數:25,代碼來源:SimpleCSV.java

示例5: findAll

import com.fasterxml.jackson.databind.MappingIterator; //導入方法依賴的package包/類
public List<Track> findAll() {
    CsvSchema schema = CsvSchema.emptySchema().withColumnSeparator(';').withHeader();

    try {
        try (InputStream tracks = getClass().getClassLoader().getResourceAsStream(FILENAME)) {
            MappingIterator<Track> mappingIterator = csvMapper.readerFor(Track.class)
                    .with(schema).readValues(tracks);
            return mappingIterator.readAll();
        }
    } catch (IOException e) {
        throw new RuntimeException(String.format("Unable to read %s as CSV", FILENAME),
                e);
    }
}
 
開發者ID:robinhowlett,項目名稱:chart-parser,代碼行數:15,代碼來源:TrackRepository.java

示例6: mapInventoryReportLine

import com.fasterxml.jackson.databind.MappingIterator; //導入方法依賴的package包/類
/**
 * Map each line of the inventory report into a POJO
 * @return List<InventoryReportLine> which is a list of POJOs
 * @throws IOException when mapping with schema fails
 */
public List<InventoryReportLine> mapInventoryReportLine(List<String> inventoryReportLine) throws IOException{
    CsvMapper mapper = new CsvMapper();
    List<InventoryReportLine> inventoryReportLines = new ArrayList();

    for (String eachLine : inventoryReportLine) {
        MappingIterator<InventoryReportLine> iterator =
                mapper.readerFor(InventoryReportLine.class).with(schema).readValues(eachLine);
        List<InventoryReportLine> rowValue = iterator.readAll();
        inventoryReportLines.add(rowValue.get(0));
    }
    return inventoryReportLines;
}
 
開發者ID:awslabs,項目名稱:s3-inventory-usage-examples,代碼行數:18,代碼來源:InventoryReportLineMapper.java

示例7: workflowCreate

import com.fasterxml.jackson.databind.MappingIterator; //導入方法依賴的package包/類
private void workflowCreate() throws IOException, ExecutionException, InterruptedException {
  final String component = namespace.getString(parser.workflowCreateComponentId.getDest());
  final File file = namespace.get(parser.workflowCreateFile.getDest());

  final ObjectReader workflowReader = Json.YAML_MAPPER.reader()
      .forType(WorkflowConfiguration.class);
  final MappingIterator<WorkflowConfiguration> iterator;
  if (file == null || file.getName().equals("-")) {
    iterator = workflowReader.readValues(System.in);
  } else {
    iterator = workflowReader.readValues(file);
  }

  final List<WorkflowConfiguration> configurations = iterator.readAll();

  // TODO: validate workflows locally before creating them

  final List<CompletionStage<Workflow>> futures = configurations.stream()
      .map(configuration -> styxClient.createOrUpdateWorkflow(component, configuration))
      .collect(toList());

  for (CompletionStage<Workflow> future : futures) {
    final Workflow created = future.toCompletableFuture().get();
    cliOutput.printMessage("Workflow " + created.workflowId() + " in component "
        + created.componentId() + " created.");
  }
}
 
開發者ID:spotify,項目名稱:styx,代碼行數:28,代碼來源:CliMain.java

示例8: convertToJsonRecords

import com.fasterxml.jackson.databind.MappingIterator; //導入方法依賴的package包/類
public List<String> convertToJsonRecords(InputStream payloadStream, int limit) throws Exception {
    MappingIterator<TruckEvent> csvTruckEvents = readTruckEventsFromCsv(payloadStream);
    List<String> jsons = new ArrayList<>();
    int ct = 0;
    for (TruckEvent truckEvent : csvTruckEvents.readAll()) {
        truckEvent.setMiles((long) new Random().nextInt(500));
        String json = new ObjectMapper().writeValueAsString(truckEvent);
        jsons.add(json);
        if (++ct == limit) {
            break;
        }
    }

    return jsons;
}
 
開發者ID:hortonworks,項目名稱:registry,代碼行數:16,代碼來源:TruckEventsCsvConverter.java


注:本文中的com.fasterxml.jackson.databind.MappingIterator.readAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。