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


Java MappingIterator類代碼示例

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


MappingIterator類屬於com.fasterxml.jackson.databind包,在下文中一共展示了MappingIterator類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: readTruckEventsFromCsv

import com.fasterxml.jackson.databind.MappingIterator; //導入依賴的package包/類
private MappingIterator<TruckEvent> readTruckEventsFromCsv(InputStream csvStream) throws IOException {
        CsvSchema bootstrap = CsvSchema.builder()
// driverId,truckId,eventTime,eventType,longitude,latitude,eventKey,correlationId,driverName,routeId,routeName,eventDate
                .addColumn("driverId", CsvSchema.ColumnType.NUMBER)
                .addColumn("truckId", CsvSchema.ColumnType.NUMBER)
                .addColumn("eventTime", CsvSchema.ColumnType.STRING)
                .addColumn("eventType", CsvSchema.ColumnType.STRING)
                .addColumn("longitude", CsvSchema.ColumnType.NUMBER)
                .addColumn("latitude", CsvSchema.ColumnType.NUMBER)
                .addColumn("eventKey", CsvSchema.ColumnType.STRING)
                .addColumn("correlationId", CsvSchema.ColumnType.NUMBER)
                .addColumn("driverName", CsvSchema.ColumnType.STRING)
                .addColumn("routeId", CsvSchema.ColumnType.NUMBER)
                .addColumn("routeName", CsvSchema.ColumnType.STRING)
                .addColumn("eventDate", CsvSchema.ColumnType.STRING)
//                .addColumn("miles", CsvSchema.ColumnType.NUMBER)
                .build().withHeader();

        CsvMapper csvMapper = new CsvMapper();
        return csvMapper.readerFor(TruckEvent.class).with(bootstrap).readValues(csvStream);
    }
 
開發者ID:hortonworks,項目名稱:registry,代碼行數:22,代碼來源:TruckEventsCsvConverter.java

示例3: deserializeFromIndexFiles

import com.fasterxml.jackson.databind.MappingIterator; //導入依賴的package包/類
protected List<PackageMetadata> deserializeFromIndexFiles(List<File> indexFiles) {
	List<PackageMetadata> packageMetadataList = new ArrayList<>();
	YAMLMapper yamlMapper = new YAMLMapper();
	yamlMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
	for (File indexFile : indexFiles) {
		try {
			MappingIterator<PackageMetadata> it = yamlMapper.readerFor(PackageMetadata.class).readValues(indexFile);
			while (it.hasNextValue()) {
				PackageMetadata packageMetadata = it.next();
				packageMetadataList.add(packageMetadata);
			}
		}
		catch (IOException e) {
			throw new IllegalArgumentException("Can't parse Release manifest YAML", e);
		}
	}
	return packageMetadataList;
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-skipper,代碼行數:19,代碼來源:PackageMetadataService.java

示例4: checkCaptcha

import com.fasterxml.jackson.databind.MappingIterator; //導入依賴的package包/類
public boolean checkCaptcha(String captcha) {
    if (isBlank(captcha)) {
        throw new ErrorCheckCaptcha("error.captcha.required", "Captcha is blank");
    }

    String url = getReCaptcha().getUrl() + "?secret=" + getReCaptcha().getSecretKey() + "&response=" + captcha;
    log.debug("Check captcha by url {}", url);

    final ObjectReader reader = new ObjectMapper().readerFor(Map.class);
    try {
        final MappingIterator<Map<String, Object>> result = reader.readValues(new URL(url));
        Map<String, Object> resultMap = result.nextValue();
        log.info("Captacha result map {}", resultMap);
        Boolean success = (Boolean) resultMap.get("success");
        return success;
    } catch (IOException e) {
        throw new ErrorCheckCaptcha(e);
    }
}
 
開發者ID:xm-online,項目名稱:xm-uaa,代碼行數:20,代碼來源:CaptchaService.java

示例5: processForkFile

import com.fasterxml.jackson.databind.MappingIterator; //導入依賴的package包/類
private void processForkFile(File f, Set<String> users, Set<String> projects) {
	logger.info("Processing "+f);

	try(InputStream in = new FileInputStream(f);) {
		CsvMapper mapper = new CsvMapper();
		CsvSchema schema = mapper.schemaWithHeader().withNullValue("None");
		MappingIterator<GitHubForkEvent> it = mapper.readerFor(GitHubForkEvent.class).with(schema).readValues(in);
		while (it.hasNextValue()) {
			GitHubForkEvent cde = it.next();
			converterService.mapUserForkEvent(cde,
					users, projects);
		}
	}catch(Exception e){
		logger.error("Could not parse data file "+f, e);
	}    		
	
	
}
 
開發者ID:DiscourseDB,項目名稱:discoursedb-core,代碼行數:19,代碼來源:GithubConverter.java

示例6: processCreateDeleteEntity

import com.fasterxml.jackson.databind.MappingIterator; //導入依賴的package包/類
private void processCreateDeleteEntity(File f, Set<String> users, Set<String> projects) {
	logger.info("Processing "+f);

	try(InputStream in = new FileInputStream(f);) {
		CsvMapper mapper = new CsvMapper();
		CsvSchema schema = mapper.schemaWithHeader().withNullValue("None");
		MappingIterator<GitHubCreateDeleteEvent> it = mapper.readerFor(GitHubCreateDeleteEvent.class).with(schema).readValues(in);
		while (it.hasNextValue()) {
			GitHubCreateDeleteEvent cde = it.next();
			converterService.mapUserCreateDeleteEvent(cde,
					users, projects);
		}
	}catch(Exception e){
		logger.error("Could not parse data file "+f, e);
	}    		
	
}
 
開發者ID:DiscourseDB,項目名稱:discoursedb-core,代碼行數:18,代碼來源:GithubConverter.java

示例7: processPushEvents

import com.fasterxml.jackson.databind.MappingIterator; //導入依賴的package包/類
private void processPushEvents(File f, Set<String> users, Set<String> projects) {
	try(InputStream in = new FileInputStream(f);) {
		CsvMapper mapper = new CsvMapper();
		CsvSchema schema = mapper.schemaWithHeader().withNullValue("None");
		long rows = 0;
		MappingIterator<GitHubPushEvent> it = mapper.readerFor(GitHubPushEvent.class).with(schema).readValues(in);
		while (it.hasNextValue()) {
			GitHubPushEvent pe = it.next();
			if (pe.getShas() != null && pe.getShas().length() > 0) {
				String [] shas = pe.getShas().split(";");
				converterService.mapPushEvent(pe, users, projects, commit_shas, shas);
			}
			rows += 1;
			if (rows%10000 == 0) {
				logger.info("....read " + rows + " rows of push_events.csv");
				
			}
		}
	}catch(Exception e){
		logger.error("Could not parse data file "+f, e);
	}    	
			
}
 
開發者ID:DiscourseDB,項目名稱:discoursedb-core,代碼行數:24,代碼來源:GithubConverter.java

示例8: processCommitCommentEvents

import com.fasterxml.jackson.databind.MappingIterator; //導入依賴的package包/類
private void processCommitCommentEvents(File f, Set<String> users, Set<String> projects, Map<String,Long> commit_shas) {
	logger.info("Processing "+f + ", first for Commit messages... ");

	try(InputStream in = new FileInputStream(f);) {
		CsvMapper mapper = new CsvMapper();
		CsvSchema schema = mapper.schemaWithHeader().withNullValue("None");
		MappingIterator<GitHubCommitCommentEvent> it = mapper.readerFor(GitHubCommitCommentEvent.class).with(schema).readValues(in);
		while (it.hasNextValue()) {
			GitHubCommitCommentEvent cde = it.next();
			converterService.mapCommitCommentEvent(cde,
					users, projects, commit_shas.get(cde.getProject() + "#" + cde.getSha()));
		}
	}catch(Exception e){
		logger.error("Could not parse data file "+f, e);
	}    		
}
 
開發者ID:DiscourseDB,項目名稱:discoursedb-core,代碼行數:17,代碼來源:GithubConverter.java

示例9: processVersionHistoryFile

import com.fasterxml.jackson.databind.MappingIterator; //導入依賴的package包/類
/**
 * Parses a pypi_versions.csv file and calls converterService to process it.  
 * 
 * Example header plus one row:
 * 
 * project_owner,project_name,pypi_name,pypi_rawname,version,upload_time,python_version,filename
 * skwashd,python-acquia-cloud,acapi,acapi,0.4.1,2015-11-21 09:30:17,source,acapi-0.4.1.tar.gz
 * 
 * @param filename to process
 */
private void processVersionHistoryFile(File file) {
	logger.info("Processing " + file);
	try(InputStream in = new FileInputStream(file);) {
		CsvMapper mapper = new CsvMapper();
		CsvSchema schema = mapper.schemaWithHeader().withNullValue("None");
		MappingIterator<RevisionEvent> it = mapper.readerFor(RevisionEvent.class).with(schema).readValues(in);
		boolean first = true;
		while (it.hasNextValue()) {
			RevisionEvent revision = it.next();
			//logger.info("Version: " + revision.getProjectFullName() + ", " + revision.getPypiName() + "/" + revision.getVersion() + " " + revision.getUploadTime());
			converterService.mapVersionInfo(
					revision.getProjectFullName(),
					revision.getPypiName(),
					revision.getVersion(), revision.getFilename() + "?" + revision.getPythonVersion(),
					revision.getUploadTime()
					);
		}
	} catch(Exception e){
		logger.error("Could not parse data file "+file, e);
	}  
}
 
開發者ID:DiscourseDB,項目名稱:discoursedb-core,代碼行數:32,代碼來源:GithubConverter.java

示例10: processWatchEvent

import com.fasterxml.jackson.databind.MappingIterator; //導入依賴的package包/類
/**
 * Parses a CSV file listing who watched what project when, 
 * binds its contents to a GitHubWatcherList object,
 * and passes it on to the DiscourseDB converter
 *
 * File format example:
 * 
 * actor,project,created_at
 * F21,danielstjules/Stringy,2015-01-01T00:01:53Z
    * radlws,tomchristie/django-rest-framework,2015-01-01T00:05:29Z
    * 
 * @param file a dataset file to process
 */
private void processWatchEvent(File file, Set<String> users, Set<String> projects){
	logger.info("Processing "+file);

	try(InputStream in = new FileInputStream(file);) {
		CsvMapper mapper = new CsvMapper();
		CsvSchema schema = mapper.schemaWithHeader().withNullValue("None");
		MappingIterator<GitHubWatchEvent> it = mapper.readerFor(GitHubWatchEvent.class).with(schema).readValues(in);
		while (it.hasNextValue()) {
			GitHubWatchEvent gwl = it.next();
			converterService.mapUserRepoEvent(
					gwl.getActor(), gwl.getProject(), gwl.getCreatedAt(),
					DiscoursePartInteractionTypes.WATCH,
					users, projects);
		}
	}catch(Exception e){
		logger.error("Could not parse data file "+file, e);
	}    		
	
}
 
開發者ID:DiscourseDB,項目名稱:discoursedb-core,代碼行數:33,代碼來源:GithubConverter.java

示例11: processPullShasFile

import com.fasterxml.jackson.databind.MappingIterator; //導入依賴的package包/類
/**
 * Parses a CSV file listing which pull requests contained which
 * commits (by SHA),
 * and passes it on to the DiscourseDB converter
 *
 * File format example:
 * 
 * (fix me)
    * 
 * @param file a dataset file to process
 */
private void processPullShasFile(File file, Set<String> users, Set<String> projects, Map<String,Long> commit_shas){
	logger.info("Processing "+file);

	try(InputStream in = new FileInputStream(file);) {
		CsvMapper mapper = new CsvMapper();
		CsvSchema schema = mapper.schemaWithHeader().withNullValue("None");
		MappingIterator<GitHubPullReqCommits> it = mapper.readerFor(GitHubPullReqCommits.class).with(schema).readValues(in);
		long row=0;
		while (it.hasNextValue()) {
			GitHubPullReqCommits prc = it.next();
			converterService.mapPullRequestCommits(prc, users, projects, commit_shas);
			row += 1;
			if (row%10000 == 0) {
				logger.info("pullShasFile row " + row + " out of about 46,000,000");
			}					
		}
	}catch(Exception e){
		logger.error("Could not parse data file "+file, e);
	}    		
	
}
 
開發者ID:DiscourseDB,項目名稱:discoursedb-core,代碼行數:33,代碼來源:GithubConverter.java

示例12: reprocessForumFileForRelationships

import com.fasterxml.jackson.databind.MappingIterator; //導入依賴的package包/類
/**
 * Parses a dataset file, binds its contents to a POJO and passes it on to the DiscourseDB converter
 * 
 * @param file an dataset file to process
 */
private void reprocessForumFileForRelationships(File file){
	// project_owner,project_name,outside_forum_id,unique_message_id,date,author_email,author_name,
	//    title,body,response_to_message_id,thread_path,message_path

	logger.info("Processing "+file);

	CsvMapper mapper = new CsvMapper();
	CsvSchema schema = mapper.schemaWithHeader().withNullValue("None");
	try(InputStream in = new FileInputStream(file);) {

		MappingIterator<MailingListComment> it = mapper.readerFor(MailingListComment.class).with(schema).readValues(in);
		while (it.hasNextValue()) {
			MailingListComment currentPost = it.next();	
			converterService.mapForumPostRelation(currentPost, "GOOGLE_GROUPS");        			
		}

	}catch(Exception e){
		logger.error("Could not parse data file "+file, e);
	}    		
}
 
開發者ID:DiscourseDB,項目名稱:discoursedb-core,代碼行數:26,代碼來源:GithubConverter.java

示例13: 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

示例14: 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

示例15: 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


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