public <C extends Collection<?>> SequenceWriter writeAll(C container) throws IOException { for (Object value : container) { write(value); } return this; }
/** * Overridable factory method called by {@link #writeValues(OutputStream)} * method (and its various overrides), and initializes it as necessary. * * @since 2.5 */ @SuppressWarnings("resource") protected SequenceWriter _newSequenceWriter(boolean wrapInArray, JsonGenerator gen, boolean managedInput) throws IOException { _configureGenerator(gen); return new SequenceWriter(_serializerProvider(), gen, managedInput, _prefetch) .init(wrapInArray); }
/** * Method for writing given value into output, as part of sequence * to write. If root type was specified for {@link ObjectWriter}, * value must be of compatible type (same or subtype). */ public SequenceWriter write(Object value) throws IOException { if (value == null) { _provider.serializeValue(_generator, null); return this; } if (_cfgCloseCloseable && (value instanceof Closeable)) { return _writeCloseableValue(value); } JsonSerializer<Object> ser = _rootSerializer; if (ser == null) { Class<?> type = value.getClass(); ser = _dynamicSerializers.serializerFor(type); if (ser == null) { ser = _findAndAddDynamic(type); } } _provider.serializeValue(_generator, value, null, ser); if (_cfgFlush) { _generator.flush(); } return this; }
private void writeJsonFS(OutputStream output) throws IOException { SequenceWriter seqWriter = writer.writeValues(output); boolean first = true; output.write((byte)'['); for (FileDescriptor desc : rootFileDescriptor.getChildFiles()) { if (!first) { output.write((byte)','); } first = false; seqWriter.write(desc); } output.write((byte)']'); seqWriter.flush(); } }
private void persistLicenseMap() throws IOException { if (licenseMapOutputFile != null) { licenseMapOutputFile.getParentFile().mkdirs(); SequenceWriter sw = new ObjectMapper().writerWithDefaultPrettyPrinter().writeValues(licenseMapOutputFile).init(true); for (LicensedProjects entry : licenseMap.values()) { sw.write(entry); } sw.close(); } }
SequenceWriter sequenceWriterExplicit = objectWriterExplicit.writeValues(outputStream); sequenceWriterExplicit.write(testObjectIn1); sequenceWriterExplicit.flush(); assertEquals(testObjectIn1.s, testObjectOut1.s); sequenceWriterExplicit.close(); SequenceWriter sequenceWriterImplicit = objectWriterImplicit.writeValues(outputStream); sequenceWriterImplicit.write(testObjectIn2); assertEquals(testObjectIn2.s, testObjectOut2.s); sequenceWriterImplicit.close();
@Override public boolean close() { try { sequenceWriter.close(); } catch (IOException e) { throw new RuntimeException(e); } return true; } }
private void annotationMetadata() throws VariantAnnotatorException, StorageEngineException, IOException { StorageVariantCommandOptions.AnnotationMetadataCommandOptions cliOptions = variantCommandOptions.annotationMetadataCommandOptions; QueryResult<ProjectMetadata.VariantAnnotationMetadata> result = variantStorageEngine.getAnnotationMetadata(cliOptions.annotationId); // WRITE ObjectMapper objectMapper = new ObjectMapper(); objectMapper.addMixIn(GenericRecord.class, GenericRecordAvroJsonMixin.class); objectMapper.configure(SerializationFeature.CLOSE_CLOSEABLE, false); ObjectWriter writer = objectMapper.writer(); // ObjectWriter writer = objectMapper.writerWithDefaultPrettyPrinter(); SequenceWriter sequenceWriter = writer.writeValues(System.out); for (ProjectMetadata.VariantAnnotationMetadata metadata : result.getResult()) { sequenceWriter.write(metadata); sequenceWriter.flush(); // writer.writeValue(System.out, annotation); System.out.println(); } }
protected SequenceWriter _writeCloseableValue(Object value) throws IOException { Closeable toClose = (Closeable) value; try { JsonSerializer<Object> ser = _rootSerializer; if (ser == null) { Class<?> type = value.getClass(); ser = _dynamicSerializers.serializerFor(type); if (ser == null) { ser = _findAndAddDynamic(type); } } _provider.serializeValue(_generator, value, null, ser); if (_cfgFlush) { _generator.flush(); } Closeable tmpToClose = toClose; toClose = null; tmpToClose.close(); } finally { if (toClose != null) { try { toClose.close(); } catch (IOException ioe) { } } } return this; }
public SequenceWriter writeAll(Object[] value) throws IOException { for (int i = 0, len = value.length; i < len; ++i) { write(value[i]); } return this; }
/** * Overridable factory method called by {@link #createSequenceWriter(JsonGenerator)} * method (and its various overrides), and initializes it as necessary. * * @since 2.5 */ @SuppressWarnings("resource") protected SequenceWriter _newSequenceWriter(boolean wrapInArray, JsonGenerator gen, boolean managedInput) throws IOException { return new SequenceWriter(_serializerProvider(_config), _configureGenerator(gen), managedInput, _prefetch) .init(wrapInArray); }
_provider.serializeValue(_generator, null); return this; return _writeCloseableValue(value, type); JsonSerializer<Object> ser = _dynamicSerializers.serializerFor(type.getRawClass()); if (ser == null) { ser = _findAndAddDynamic(type); _provider.serializeValue(_generator, value, type, ser); if (_cfgFlush) { _generator.flush();
/** * @since 2.7 */ public SequenceWriter writeAll(Iterable<?> iterable) throws IOException { for (Object value : iterable) { write(value); } return this; }
/** * Overridable factory method called by {@link #createSequenceWriter(JsonGenerator)} * method (and its various overrides), and initializes it as necessary. * * @since 2.5 */ @SuppressWarnings("resource") protected SequenceWriter _newSequenceWriter(boolean wrapInArray, JsonGenerator gen, boolean managedInput) throws IOException { return new SequenceWriter(_serializerProvider(_config), _configureGenerator(gen), managedInput, _prefetch) .init(wrapInArray); }
protected SequenceWriter _writeCloseableValue(Object value, JavaType type) throws IOException { Closeable toClose = (Closeable) value; try { // 15-Dec-2014, tatu: As per above, could be problem that we do not pass generic type JsonSerializer<Object> ser = _dynamicSerializers.serializerFor(type.getRawClass()); if (ser == null) { ser = _findAndAddDynamic(type); } _provider.serializeValue(_generator, value, type, ser); if (_cfgFlush) { _generator.flush(); } Closeable tmpToClose = toClose; toClose = null; tmpToClose.close(); } finally { if (toClose != null) { try { toClose.close(); } catch (IOException ioe) { } } } return this; }
predict, rmse, r.getTimestamp() - buildTime, rank, buildsCount); if (extWriter != null) { extWriter.write(json);
/** * Overridable factory method called by {@link #writeValues(OutputStream)} * method (and its various overrides), and initializes it as necessary. * * @since 2.5 */ @SuppressWarnings("resource") protected SequenceWriter _newSequenceWriter(boolean wrapInArray, JsonGenerator gen, boolean managedInput) throws IOException { _configureGenerator(gen); return new SequenceWriter(_serializerProvider(), gen, managedInput, _prefetch) .init(wrapInArray); }
/** * Method for writing given value into output, as part of sequence * to write. If root type was specified for {@link ObjectWriter}, * value must be of compatible type (same or subtype). */ public SequenceWriter write(Object value) throws IOException { if (value == null) { _provider.serializeValue(_generator, null); return this; } if (_cfgCloseCloseable && (value instanceof Closeable)) { return _writeCloseableValue(value); } JsonSerializer<Object> ser = _rootSerializer; if (ser == null) { Class<?> type = value.getClass(); ser = _dynamicSerializers.serializerFor(type); if (ser == null) { ser = _findAndAddDynamic(type); } } _provider.serializeValue(_generator, value, null, ser); if (_cfgFlush) { _generator.flush(); } return this; }
public SequenceWriter writeAll(Object[] value) throws IOException { for (int i = 0, len = value.length; i < len; ++i) { write(value[i]); } return this; }