/** * Overloaded version of {@link #readValue(InputStream)}. */ public final <T> MappingIterator<T> readValues(byte[] src) throws IOException { return readValues(src, 0, src.length); }
/** * Convenience method that is equivalent to: *<pre> * withType(valueType).readValues(p); *</pre> *<p> * Method reads a sequence of Objects from parser stream. * Sequence can be either root-level "unwrapped" sequence (without surrounding * JSON array), or a sequence contained in a JSON Array. * In either case {@link JsonParser} <b>MUST</b> point to the first token of * the first element, OR not point to any token (in which case it is advanced * to the next token). This means, specifically, that for wrapped sequences, * parser MUST NOT point to the surrounding <code>START_ARRAY</code> (one that * contains values to read) but rather to the token following it which is the first * token of the first value to read. *<p> * NOTE: this method never tries to auto-detect format, since actual * (data-format specific) parser is given. */ @Override public <T> Iterator<T> readValues(JsonParser p, ResolvedType valueType) throws IOException { return readValues(p, (JavaType) valueType); }
/** * Convenience method that is equivalent to: *<pre> * withType(valueTypeRef).readValues(p); *</pre> *<p> * Method reads a sequence of Objects from parser stream. * Sequence can be either root-level "unwrapped" sequence (without surrounding * JSON array), or a sequence contained in a JSON Array. * In either case {@link JsonParser} <b>MUST</b> point to the first token of * the first element, OR not point to any token (in which case it is advanced * to the next token). This means, specifically, that for wrapped sequences, * parser MUST NOT point to the surrounding <code>START_ARRAY</code> (one that * contains values to read) but rather to the token following it which is the first * token of the first value to read. *<p> * NOTE: this method never tries to auto-detect format, since actual * (data-format specific) parser is given. */ @Override public <T> Iterator<T> readValues(JsonParser p, TypeReference<?> valueTypeRef) throws IOException { return forType(valueTypeRef).readValues(p); }
/** * Convenience method that is equivalent to: *<pre> * withType(valueType).readValues(p); *</pre> *<p> * Method reads a sequence of Objects from parser stream. * Sequence can be either root-level "unwrapped" sequence (without surrounding * JSON array), or a sequence contained in a JSON Array. * In either case {@link JsonParser} <b>MUST</b> point to the first token of * the first element, OR not point to any token (in which case it is advanced * to the next token). This means, specifically, that for wrapped sequences, * parser MUST NOT point to the surrounding <code>START_ARRAY</code> (one that * contains values to read) but rather to the token following it which is the first * token of the first value to read. *<p> * NOTE: this method never tries to auto-detect format, since actual * (data-format specific) parser is given. */ public <T> Iterator<T> readValues(JsonParser p, JavaType valueType) throws IOException { return forType(valueType).readValues(p); }
/** * Convenience method that is equivalent to: *<pre> * withType(valueType).readValues(p); *</pre> *<p> * Method reads a sequence of Objects from parser stream. * Sequence can be either root-level "unwrapped" sequence (without surrounding * JSON array), or a sequence contained in a JSON Array. * In either case {@link JsonParser} <b>MUST</b> point to the first token of * the first element, OR not point to any token (in which case it is advanced * to the next token). This means, specifically, that for wrapped sequences, * parser MUST NOT point to the surrounding <code>START_ARRAY</code> (one that * contains values to read) but rather to the token following it which is the first * token of the first value to read. *<p> * NOTE: this method never tries to auto-detect format, since actual * (data-format specific) parser is given. */ @Override public <T> Iterator<T> readValues(JsonParser p, Class<T> valueType) throws IOException { return forType(valueType).readValues(p); }
@Override public List<LogResult> deserialize( JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { List<LogResult> logResults = new ArrayList<>(); JsonToken nextToken = jsonParser.nextToken(); if (nextToken == JsonToken.START_OBJECT) { Iterator<LogObject> logObjectIterator = objectReader.readValues(jsonParser, LogObject.class); while (logObjectIterator.hasNext()) { logResults.add(logObjectIterator.next()); } } else if (nextToken == JsonToken.VALUE_STRING) { jsonParser.getValueAsString(); Iterator<Hash> transactionHashIterator = objectReader.readValues(jsonParser, Hash.class); while (transactionHashIterator.hasNext()) { logResults.add(transactionHashIterator.next()); } } return logResults; } }
@Override public List<TransactionResult> deserialize( JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { List<TransactionResult> transactionResults = new ArrayList<>(); JsonToken nextToken = jsonParser.nextToken(); if (nextToken == JsonToken.START_OBJECT) { Iterator<TransactionObject> transactionObjectIterator = objectReader.readValues(jsonParser, TransactionObject.class); while (transactionObjectIterator.hasNext()) { transactionResults.add(transactionObjectIterator.next()); } } else if (nextToken == JsonToken.VALUE_STRING) { jsonParser.getValueAsString(); Iterator<TransactionHash> transactionHashIterator = objectReader.readValues(jsonParser, TransactionHash.class); while (transactionHashIterator.hasNext()) { transactionResults.add(transactionHashIterator.next()); } } return transactionResults; } }
@Override public void run() { try { try (final Socket socket = serverSocket.accept()) { if (socket != null) { final InputStream is = socket.getInputStream(); while (!shutdown) { final MappingIterator<LogEvent> mappingIterator = objectMapper.readerFor(Log4jLogEvent.class).readValues(is); while (mappingIterator.hasNextValue()) { queue.add(mappingIterator.nextValue()); ++count; } } } } } catch (final EOFException eof) { // Socket is closed. } catch (final Exception e) { if (!shutdown) { Throwables.rethrow(e); } } }
.withFeatures(features.toArray(new CsvParser.Feature[features.size()])); recordStream = objReader.readValues(reader);
return reader.readValues(p);
/** * Overloaded version of {@link #readValue(InputStream)}. */ public final <T> MappingIterator<T> readValues(byte[] src) throws IOException { return readValues(src, 0, src.length); }
private void initialize() throws IOException { this.parser = new JsonFactory().createParser(new InputStreamReader(inputStream, "utf-8")); //$NON-NLS-1$ initializer.execute(this.parser); this.iterator = new ObjectMapper().readerFor(clazz).readValues(this.parser); } };
/** * 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; }
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; }
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; }
public List<GraphQLRequest> readBatchedGraphQLRequest(InputStream inputStream) throws IOException { MappingIterator<GraphQLRequest> iterator = getGraphQLRequestMapper().readValues(inputStream); List<GraphQLRequest> requests = new ArrayList<>(); while (iterator.hasNext()) { requests.add(iterator.next()); } return requests; }
public List<GraphQLRequest> readBatchedGraphQLRequest(InputStream inputStream) throws IOException { MappingIterator<GraphQLRequest> iterator = getGraphQLRequestMapper().readValues(inputStream); List<GraphQLRequest> requests = new ArrayList<>(); while (iterator.hasNext()) { requests.add(iterator.next()); } return requests; }
public List<GraphQLRequest> readBatchedGraphQLRequest(String query) throws IOException { MappingIterator<GraphQLRequest> iterator = getGraphQLRequestMapper().readValues(query); List<GraphQLRequest> requests = new ArrayList<>(); while (iterator.hasNext()) { requests.add(iterator.next()); } return requests; }
MappingIterator<Map> it = mapper.readerFor(Map.class).with(schema.build()).readValues(csvFile); while (it.hasNext()) { Map<String, Object> row = it.next();
private static <T> List<T> importCsvRules(Class<T> type, Class<?> mixin, String rulesString) throws Exception { CsvSchema csvSchema = CsvSchema.emptySchema().withHeader().withColumnSeparator(';'); CsvMapper mapper = new CsvMapper(); mapper.addMixIn(type, mixin); mapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true); MappingIterator<T> readValues = mapper.readerFor(type).with(csvSchema).readValues(rulesString); return readValues.readAll(); }