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


Java MappingIterator.hasNext方法代碼示例

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


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

示例1: loadValuesFromFile

import com.fasterxml.jackson.databind.MappingIterator; //導入方法依賴的package包/類
public static List<Map<String, Object>> loadValuesFromFile(String filePath) {

		List<Map<String, Object>> result = new ArrayList<>();

		File csvFile = new File(filePath);
		if (!csvFile.exists()) {
			throw new FileLibraryException("Cannot find file " + csvFile.getAbsolutePath());
		}

		try {
			CsvMapper mapper = new CsvMapper();
			CsvSchema schema = CsvSchema.emptySchema().withHeader();
			MappingIterator<Map<String, Object>> it = mapper.readerFor(Map.class).with(schema).readValues(csvFile);
			while (it.hasNext()) {
				result.add(it.next());
			}
			return result;
		} catch (Exception e) {
			throw new FileLibraryException(e);
		}
	}
 
開發者ID:dvanherbergen,項目名稱:robotframework-filelibrary,代碼行數:22,代碼來源:CsvUtil.java

示例2: main

import com.fasterxml.jackson.databind.MappingIterator; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException {
    CsvParam csvParam = new CsvParam();
    csvParam.setUp();

    CsvMapper csvMapper = new CsvMapper();

    csvMapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);

    CsvSchema bootstrapSchema = CsvSchema.emptySchema().withHeader();

    try(Reader reader = csvParam.getReader()) {
        MappingIterator<City> iterator = csvMapper.readerFor(City.class).with(bootstrapSchema).readValues(reader);

        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
    }
}
 
開發者ID:arnaudroger,項目名稱:mapping-benchmark,代碼行數:19,代碼來源:JacksonCsvParserBenchmark.java

示例3: linkPresentations

import com.fasterxml.jackson.databind.MappingIterator; //導入方法依賴的package包/類
private void linkPresentations(File dir, List<Medicament> medicaments) throws IOException {
    LOG.info("liste présentations");

    CsvMapper csvMapper = new CsvMapper();
    CsvSchema schema = csvMapper.schemaFor(PresentationCSV.class).withArrayElementSeparator(';').withColumnSeparator('\t');
    MappingIterator<PresentationCSV> it = csvMapper.readerFor(PresentationCSV.class).with(schema).readValues(new File(dir, Constants.CIS_CIP_BDPM_FILE));

    Medicament medicament;
    while (it.hasNext()) {
        PresentationCSV presentation = it.next();

        LOG.debug("référencement presentation médicament - CodeCIS : " + presentation.getCodeCIS());

        medicament = medicaments.stream()
                .filter(x -> x.getCodeCIS().equals(presentation.getCodeCIS()))
                .findFirst().orElse(null);

        if (medicament != null) {
            medicament.getPresentations().add(mapper.toPresentationES(presentation));
        }
    }
}
 
開發者ID:Ellixo,項目名稱:MedicamentDB,代碼行數:23,代碼來源:MedicamentService.java

示例4: linkAvisSMR

import com.fasterxml.jackson.databind.MappingIterator; //導入方法依賴的package包/類
private void linkAvisSMR(File dir, List<Medicament> medicaments, Map<String, String> urlsHAS) throws IOException {
    LOG.info("liste avis SMR");

    CsvMapper csvMapper = new CsvMapper();
    CsvSchema schema = csvMapper.schemaFor(AvisSMRCSV.class).withArrayElementSeparator(';').withColumnSeparator('\t');
    MappingIterator<AvisSMRCSV> it = csvMapper.readerFor(AvisSMRCSV.class).with(schema).readValues(new File(dir, Constants.CIS_HAS_SMR_BDPM_FILE));

    Medicament medicament;
    AvisSMR avisSMR;
    while (it.hasNext()) {
        AvisSMRCSV csv = it.next();

        LOG.debug("référencement SMR médicament - CodeCIS : " + csv.getCodeCIS());

        medicament = medicaments.stream()
                .filter(x -> x.getCodeCIS().equals(csv.getCodeCIS()))
                .findFirst().orElse(null);

        if (medicament != null) {
            avisSMR = mapper.toAvisSMRES(csv);
            avisSMR.setUrlHAS(urlsHAS.get(avisSMR.getCodeDossierHAS()));
            medicament.getAvisSMR().add(avisSMR);
        }
    }
}
 
開發者ID:Ellixo,項目名稱:MedicamentDB,代碼行數:26,代碼來源:MedicamentService.java

示例5: linkAvisASMR

import com.fasterxml.jackson.databind.MappingIterator; //導入方法依賴的package包/類
private void linkAvisASMR(File dir, List<Medicament> medicaments, Map<String, String> urlsHAS) throws IOException {
    LOG.info("liste avis ASMR");

    CsvMapper csvMapper = new CsvMapper();
    CsvSchema schema = csvMapper.schemaFor(AvisASMRCSV.class).withArrayElementSeparator(';').withColumnSeparator('\t');
    MappingIterator<AvisASMRCSV> it = csvMapper.readerFor(AvisASMRCSV.class).with(schema).readValues(new File(dir, Constants.CIS_HAS_ASMR_BDPM_FILE));

    Medicament medicament;
    AvisASMR avisASMR;
    while (it.hasNext()) {
        AvisASMRCSV csv = it.next();

        LOG.debug("référencement ASMR médicament - CodeCIS : " + csv.getCodeCIS());

        medicament = medicaments.stream()
                .filter(x -> x.getCodeCIS().equals(csv.getCodeCIS()))
                .findFirst().orElse(null);

        if (medicament != null) {
            avisASMR = mapper.toAvisASMRES(csv);
            avisASMR.setUrlHAS(urlsHAS.get(avisASMR.getCodeDossierHAS()));
            medicament.getAvisASMR().add(avisASMR);
        }
    }
}
 
開發者ID:Ellixo,項目名稱:MedicamentDB,代碼行數:26,代碼來源:MedicamentService.java

示例6: loadPublisherMap

import com.fasterxml.jackson.databind.MappingIterator; //導入方法依賴的package包/類
private ImmutableMultimap<String, String> loadPublisherMap(String file) {
	// todo make sortedsetmultimap
	Multimap<String, String> temp = LinkedHashMultimap.create();
	CsvMapper mapper = new CsvMapper();
	mapper.enable(CsvParser.Feature.WRAP_AS_ARRAY);
	try {
		MappingIterator<Object[]> it = mapper.reader(Object[].class).readValues(
				getClass().getResourceAsStream(file));
		while (it.hasNext()) {
			Object[] row = it.next();
			if (row.length > 1 && (row[0] != null && row[1] != null)
					&& (!row[0].toString().isEmpty() && !row[1].toString().isEmpty())) {
				temp.put(row[1].toString().trim(), row[0].toString().trim());
			}
		}
	} catch (IOException e) {
		throw new RuntimeException(e);
	}
	return ImmutableMultimap.copyOf(temp);
}
 
開發者ID:TomDemeranville,項目名稱:orcid-update-java,代碼行數:21,代碼來源:DOIPrefixMapper.java

示例7: fetchUserEmail

import com.fasterxml.jackson.databind.MappingIterator; //導入方法依賴的package包/類
private String fetchUserEmail(Integer githubId, String accessToken) throws IOException {
	HttpGet emailsGet = new HttpGet(PROFILE_URL + "/emails");
	emailsGet.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken);
	emailsGet.setHeader(HttpHeaders.ACCEPT, "application/json");
	CloseableHttpResponse resp = httpclient.execute(emailsGet);
	HttpEntity respEntity = resp.getEntity();
	String ctype = resp.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue();

	if (respEntity != null && Utils.isJsonType(ctype)) {
		MappingIterator<Map<String, Object>> emails = jreader.readValues(respEntity.getContent());
		if (emails != null) {
			String email = null;
			while (emails.hasNext()) {
				Map<String, Object> next = emails.next();
				email = (String) next.get("email");
				if (next.containsKey("primary") && (Boolean) next.get("primary")) {
					break;
				}
			}
			return email;
		}
	}
	return githubId + "@github.com";
}
 
開發者ID:Erudika,項目名稱:para,代碼行數:25,代碼來源:GitHubAuthFilter.java

示例8: readFromCsv

import com.fasterxml.jackson.databind.MappingIterator; //導入方法依賴的package包/類
/**
 * Reads a CSV file into a list of the specified type.
 * @param csv The CSV file.
 * @param responseClass The type of the returned list's elements.
 * @param schema A schema representing the CSV file's structure.
 * @param <T> The type of the returned list's elements.
 * @return A list of parsed elements.
 * @throws IOException if parsing failed.
 */
public static <T> List<T> readFromCsv(String csv, Class<T> responseClass, CsvSchema schema) throws IOException {
    if (csv == null) {
        // Protect against NullPointerException
        csv = "";
    }

    ObjectReader reader = new CsvMapper().reader(responseClass).with(schema);
    MappingIterator<T> iterator = reader.readValues(csv);
    ArrayList<T> results = new ArrayList<>();
    try {
        while (iterator.hasNext()) {
            results.add(iterator.next());
        }
    } catch (RuntimeException e) {
        // ObjectReader throws (subclasses of) IOException, but MappingIterator wraps them in a RuntimeException.
        // We unwrap them for consistency.
        Throwable cause = e.getCause();
        if (cause != null && cause instanceof IOException) {
            throw (IOException) cause;
        }
        throw e;
    }
    return results;
}
 
開發者ID:SEEG-Oxford,項目名稱:ABRAID-MP,代碼行數:34,代碼來源:ParseUtils.java

示例9: loadState

import com.fasterxml.jackson.databind.MappingIterator; //導入方法依賴的package包/類
/**
 * Flushes all {@code key=>value} pairs and replaces them with
 * the values read from the given {@code snapshotInputStream}.
 * This implementation expects the {@code InputStream} to contain
 * a sequence of JSON {@link KeyValue} instances.
 *
 * @param lastAppliedIndex log index >= 0 of the last change contained in this snapshot
 * @param snapshotInputStream {@code InputStream} from which all {@code key=> value} pairs should be read
 * @throws IOException if valid {@code key=>value} pairs cannot be read from {@code snapshotInputStream}.
 * Since no internal state is modified until the {@code snapshotInputStream} is completely read and
 * parsed, {@code LocalStore} can still be used safely after an {@code IOException} is thrown
 * @throws RuntimeException if the {@code key=>value} pairs in {@code snapshotInputStream} cannot be converted to JSON
 */
synchronized void loadState(long lastAppliedIndex, InputStream snapshotInputStream) throws IOException {
    try {
        // read values from the snapshot into a temporary map
        Map<String, String> snapshotEntries = Maps.newHashMap();

        ObjectMapper mapper = new ObjectMapper();
        ObjectReader reader = mapper.reader(KeyValue.class);
        MappingIterator<KeyValue> it = reader.readValues(snapshotInputStream);
        while (it.hasNext()) {
            KeyValue keyValue = it.next();
            snapshotEntries.put(keyValue.getKey(), keyValue.getValue()); // values are read into this temporary map!
        }

        // update the index
        // NOTE: AFAIU, we should never get a snapshot which contains fewer entries than we've applied
        updateLastAppliedIndex(lastAppliedIndex);

        // replace the old entries map with the new one generated from the snapshot
        entries = snapshotEntries;
    } finally {
        Closeables.close(snapshotInputStream, true);
    }
}
 
開發者ID:allengeorge,項目名稱:libraft,代碼行數:37,代碼來源:LocalStore.java

示例10: main

import com.fasterxml.jackson.databind.MappingIterator; //導入方法依賴的package包/類
public static void main (String [] args) throws IOException{
	System.out.println("Reading Datasets and Categories...");
	URL file = Resources.getResource("datasetsAndCategories.tsv");
	CsvMapper mapper = new CsvMapper();
	mapper.enable(CsvParser.Feature.WRAP_AS_ARRAY);
	File csvFile = new File(file.getFile());
	CsvSchema schema = CsvSchema.emptySchema().withColumnSeparator('\t');
	MappingIterator<String[]> it = mapper.reader(String[].class).with(schema).readValues(csvFile);
	while (it.hasNext()){
		String[] arr = it.next();
		m.add(m.createStatement(m.createResource(arr[0]), m.createProperty(":hasDomain"), m.createTypedLiteral(arr[1])));
		m.add(m.createStatement(m.createResource(arr[0]), m.createProperty(":getFromLOV"), m.createTypedLiteral(true)));
	}
	System.out.println("Writing dump...");
	File f = new File("categories.ttl");
	f.createNewFile();
	FileOutputStream fos = new FileOutputStream(f);
	m.write(fos, "TURTLE");
}
 
開發者ID:diachron,項目名稱:quality,代碼行數:20,代碼來源:GenerateLODCategories.java

示例11: loadJsonValues

import com.fasterxml.jackson.databind.MappingIterator; //導入方法依賴的package包/類
/**
 * Saves the json object to the given file
 */
public static <T> List<T> loadJsonValues(File json, Class<T> clazz) throws IOException {
    List<T> answer = new ArrayList<>();
    if (json.exists() && json.isFile()) {
        MappingIterator<T> iter = objectMapper.readerFor(clazz).readValues(json);
        while (iter.hasNext()) {
            answer.add(iter.next());
        }
    }
    return answer;
}
 
開發者ID:fabric8io,項目名稱:fabric8-forge,代碼行數:14,代碼來源:Models.java

示例12: parseYamlValues

import com.fasterxml.jackson.databind.MappingIterator; //導入方法依賴的package包/類
static <T> List<T> parseYamlValues(File file, Class<T> clazz) throws IOException {
    ObjectMapper mapper = createObjectMapper();
    MappingIterator<T> iter = mapper.readerFor(clazz).readValues(file);
    List<T> answer = new ArrayList<>();
    while (iter.hasNext()) {
        answer.add(iter.next());
    }
    return answer;
}
 
開發者ID:funktionio,項目名稱:funktion-connectors,代碼行數:10,代碼來源:Funktions.java

示例13: read

import com.fasterxml.jackson.databind.MappingIterator; //導入方法依賴的package包/類
@Override
public List<T> read(JsonParser jsonParser) throws IOException {
    expectToken(jsonParser, JsonToken.START_ARRAY);
    jsonParser.clearCurrentToken();

    final MappingIterator<T> eventIterator = eventReader.readValues(jsonParser);

    final List<T> events = new ArrayList<>();
    while (true) {
        try {
            // MappingIterator#hasNext can theoretically also throw RuntimeExceptions, that's why we use this strange loop structure
            if (eventIterator.hasNext()) {
                events.add(eventClass.cast(eventIterator.next()));
            } else {
                break;
            }
        } catch (RuntimeException e) {
            final Throwable cause = e.getCause();
            if (cause instanceof JsonMappingException) {
                onMappingException((JsonMappingException) cause);
            } else if (cause instanceof IOException) {
                throw (IOException)cause;
            } else {
                throw e;
            }
        }
    }
    return events;

}
 
開發者ID:zalando-nakadi,項目名稱:fahrschein,代碼行數:31,代碼來源:MappingEventReader.java

示例14: parseCsv

import com.fasterxml.jackson.databind.MappingIterator; //導入方法依賴的package包/類
@Benchmark
public void parseCsv(Blackhole blackhole, CsvParam csvParam) throws IOException {

    try(Reader reader = csvParam.getReader()) {
        MappingIterator<String[]> iterator = csvMapperToStringArray.readerFor(String[].class).readValues(reader);

        while (iterator.hasNext()) {
            blackhole.consume(iterator.next());
        }
    }
}
 
開發者ID:arnaudroger,項目名稱:mapping-benchmark,代碼行數:12,代碼來源:JacksonCsvParserBenchmark.java

示例15: mapCsv

import com.fasterxml.jackson.databind.MappingIterator; //導入方法依賴的package包/類
@Benchmark
public void mapCsv(Blackhole blackhole, CsvParam csvParam) throws IOException {

    try(Reader reader = csvParam.getReader()) {
        MappingIterator<City> iterator = cityReader.readValues(reader);

        while (iterator.hasNext()) {
            blackhole.consume(iterator.next());
        }
    }
}
 
開發者ID:arnaudroger,項目名稱:mapping-benchmark,代碼行數:12,代碼來源:JacksonCsvParserBenchmark.java


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