/** * Parse the values from the CSVReader. * @param mapper Mapping strategy for the bean. * @param csv CSVReader * @param throwExceptions If false, exceptions internal to opencsv will not * be thrown, but can be accessed after processing is finished through * {@link #getCapturedExceptions()}. * @return List of Objects. * @deprecated Please use {@link CsvToBeanBuilder} instead. */ @Deprecated public List<T> parse(MappingStrategy<T> mapper, CSVReader csv, boolean throwExceptions) { setMappingStrategy(mapper); setCsvReader(csv); this.setThrowExceptions(throwExceptions); return parse(); }
CsvToBean<T> bean = new CsvToBean<>(); CSVParser parser = buildParser(); bean.setCsvReader(buildReader(parser)); bean.setThrowExceptions(throwExceptions); bean.setOrderedResults(orderedResults); if(filter != null) { bean.setFilter(filter); } bean.setVerifiers(verifiers); mappingStrategy = OpencsvUtils.determineMappingStrategy(type, errorLocale); bean.setMappingStrategy(mappingStrategy); bean.setErrorLocale(errorLocale);
/** * Parse the values from the CSVReader. * @param mapper Mapping strategy for the bean. * @param csv CSVReader * @return List of Objects. * @deprecated Please use {@link CsvToBeanBuilder} instead. */ @Deprecated public List<T> parse(MappingStrategy<T> mapper, CSVReader csv) { setMappingStrategy(mapper); setCsvReader(csv); return parse(); }
@Override public void parse(InputStream in) throws QueryResultParseException, TupleQueryResultHandlerException { if(handler != null) { SPARQLResultsTSVMappingStrategy strategy = new SPARQLResultsTSVMappingStrategy(valueFactory); Reader reader = new InputStreamReader(in, StandardCharsets.UTF_8); CsvToBean csvToBean = new CsvToBeanBuilder<BindingSet>(reader) .withType(BindingSet.class) .withMappingStrategy(strategy) .withSeparator('\t') .build(); csvToBean.setCsvReader(new SPARQLResultsTSVReader(reader)); // We need our reader List<BindingSet> bindingSets = csvToBean.parse(); List<String> bindingNames = strategy.getBindingNames(); handler.startQueryResult(bindingNames); for(BindingSet bs : bindingSets) { handler.handleSolution(bs); } handler.endQueryResult(); } } }
prepareToReadInput(); prepareForParallelProcessing(); submitAllBeans(); } catch(RejectedExecutionException e) { return prepareResults();
@Override public void parse(InputStream in) throws QueryResultParseException, TupleQueryResultHandlerException { SPARQLResultsCSVMappingStrategy strategy = new SPARQLResultsCSVMappingStrategy(valueFactory); List<BindingSet> bindingSets = new CsvToBeanBuilder<BindingSet>(new InputStreamReader(in, StandardCharsets.UTF_8)) .withType(BindingSet.class) .withMappingStrategy(strategy) .build().parse(); if(handler != null) { List<String> bindingNames = strategy.getBindingNames(); handler.startQueryResult(bindingNames); for(BindingSet bs : bindingSets) { handler.handleSolution(bs); } handler.endQueryResult(); } } }
/** * The iterator returned by this method takes one line of input at a time * and returns one bean at a time. * <p>The advantage to this method is saving memory. The cost is the loss of * parallel processing, reducing throughput.</p> * <p>The iterator respects all aspects of {@link CsvToBean}, including * filters and capturing exceptions.</p> * @return An iterator over the beans created from the input */ @Override public Iterator<T> iterator() { prepareToReadInput(); return new CsvToBeanIterator(); }
/** * Parse the values from a CSVReader constructed from the Reader passed in. * @param mapper Mapping strategy for the bean. * @param reader Reader used to construct a CSVReader * @return List of Objects. * @deprecated Please use {@link CsvToBeanBuilder} instead. */ @Deprecated public List<T> parse(MappingStrategy<T> mapper, Reader reader) { setMappingStrategy(mapper); setCsvReader(new CSVReaderBuilder(reader).withErrorLocale(errorLocale).build()); return parse(); }
@Override public void parse(InputStream in) throws QueryResultParseException, TupleQueryResultHandlerException { if(handler != null) { SPARQLResultsCSVMappingStrategy strategy = new SPARQLResultsCSVMappingStrategy(valueFactory); List<BindingSet> bindingSets = new CsvToBeanBuilder<BindingSet>(new InputStreamReader(in, StandardCharsets.UTF_8)) .withType(BindingSet.class) .withMappingStrategy(strategy) .build().parse(); List<String> bindingNames = strategy.getBindingNames(); handler.startQueryResult(bindingNames); for(BindingSet bs : bindingSets) { handler.handleSolution(bs); } handler.endQueryResult(); } } }
/** * Parse the values from the CSVReader. * Throws exceptions for bad data and other sorts of problems relating * directly to opencsv, as well as general exceptions from external code * used. * * @param mapper Mapping strategy for the bean. * @param csv CSVReader * @param filter CsvToBeanFilter to apply - null if no filter. * @return List of Objects. * @deprecated Please use {@link CsvToBeanBuilder} instead. */ @Deprecated public List<T> parse(MappingStrategy<T> mapper, CSVReader csv, CsvToBeanFilter filter) { setMappingStrategy(mapper); setCsvReader(csv); this.setFilter(filter); return parse(); }
/** * Parse the values from the CSVReader. * Only throws general exceptions from external code used. Problems related * to opencsv and the data provided to it are captured for later processing * by user code and can be accessed through {@link #getCapturedExceptions()}. * * @param mapper Mapping strategy for the bean. * @param csv CSVReader * @param filter CsvToBeanFilter to apply - null if no filter. * @param throwExceptions If false, exceptions internal to opencsv will not * be thrown, but can be accessed after processing is finished through * {@link #getCapturedExceptions()}. * @return List of Objects. * @deprecated Please use {@link CsvToBeanBuilder} instead. */ @Deprecated public List<T> parse(MappingStrategy<T> mapper, CSVReader csv, CsvToBeanFilter filter, boolean throwExceptions) { setMappingStrategy(mapper); setCsvReader(csv); this.setFilter(filter); this.setThrowExceptions(throwExceptions); return parse(); }
/** * Parse the values from a CSVReader constructed from the Reader passed in. * * @param mapper Mapping strategy for the bean. * @param reader Reader used to construct a CSVReader * @param filter CsvToBeanFilter to apply - null if no filter. * @return List of Objects. * @deprecated Please use {@link CsvToBeanBuilder} instead. */ @Deprecated public List<T> parse(MappingStrategy<T> mapper, Reader reader, CsvToBeanFilter filter) { setMappingStrategy(mapper); setCsvReader(new CSVReaderBuilder(reader).withErrorLocale(errorLocale).build()); this.setFilter(filter); return parse(); }
/** * Parse the values from a CSVReader constructed from the Reader passed in. * @param mapper Mapping strategy for the bean. * @param reader Reader used to construct a CSVReader * @param throwExceptions If false, exceptions internal to opencsv will not * be thrown, but can be accessed after processing is finished through * {@link #getCapturedExceptions()}. * @return List of Objects. * @deprecated Please use {@link CsvToBeanBuilder} instead. */ @Deprecated public List<T> parse(MappingStrategy<T> mapper, Reader reader, boolean throwExceptions) { setMappingStrategy(mapper); setCsvReader(new CSVReaderBuilder(reader).withErrorLocale(errorLocale).build()); this.setThrowExceptions(throwExceptions); return parse(); }
/** * Parse the values from a CSVReader constructed from the Reader passed in. * @param mapper Mapping strategy for the bean. * @param reader Reader used to construct a CSVReader * @param filter CsvToBeanFilter to apply - null if no filter. * @param throwExceptions If false, exceptions internal to opencsv will not * be thrown, but can be accessed after processing is finished through * {@link #getCapturedExceptions()}. * @return List of Objects. * @deprecated Please use {@link CsvToBeanBuilder} instead. */ @Deprecated public List<T> parse(MappingStrategy<T> mapper, Reader reader, CsvToBeanFilter filter, boolean throwExceptions) { setMappingStrategy(mapper); setCsvReader(new CSVReaderBuilder(reader).withErrorLocale(errorLocale).build()); this.setFilter(filter); this.setThrowExceptions(throwExceptions); return parse(); }