/** * Reconfigures this JsonEncoder to use the output stream provided. * <p/> * If the OutputStream provided is null, a NullPointerException is thrown. * <p/> * Otherwise, this JsonEncoder will flush its current output and then * reconfigure its output to use a default UTF8 JsonGenerator that writes * to the provided OutputStream. * * @param out * The OutputStream to direct output to. Cannot be null. * @throws IOException * @return this JsonEncoder */ public JsonEncoder configure(OutputStream out) throws IOException { this.configure(getJsonGenerator(out, false)); return this; }
/** * Reconfigures this JsonEncoder to use the output stream provided. * <p/> * If the OutputStream provided is null, a NullPointerException is thrown. * <p/> * Otherwise, this JsonEncoder will flush its current output and then * reconfigure its output to use a default UTF8 JsonGenerator that writes * to the provided OutputStream. * * @param out * The OutputStream to direct output to. Cannot be null. * @throws IOException * @return this JsonEncoder */ public JsonEncoder configure(OutputStream out) throws IOException { this.configure(getJsonGenerator(out, false)); return this; }
JsonEncoder(Schema sc, JsonGenerator out) throws IOException { configure(out); this.parser = new Parser(new JsonGrammarGenerator().generate(sc), this); }
JsonEncoder(Schema sc, JsonGenerator out) throws IOException { configure(out); this.parser = new Parser(new JsonGrammarGenerator().generate(sc), this); }
@Test public void testJsonEncoderInit() throws IOException { Schema s = Schema.parse("\"int\""); OutputStream out = new ByteArrayOutputStream(); factory.jsonEncoder(s, out); JsonEncoder enc = factory.jsonEncoder(s, new JsonFactory().createJsonGenerator(out, JsonEncoding.UTF8)); enc.configure(out); }
/** * Reconfigures this JsonEncoder to use the output stream provided. * <p/> * If the OutputStream provided is null, a NullPointerException is thrown. * <p/> * Otherwise, this JsonEncoder will flush its current output and then * reconfigure its output to use a default UTF8 JsonGenerator that writes * to the provided OutputStream. * * @param out * The OutputStream to direct output to. Cannot be null. * @throws IOException * @return this JsonEncoder */ public JsonEncoder configure(OutputStream out) throws IOException { this.configure(getJsonGenerator(out)); return this; }
/** * Reconfigures this JsonEncoder to use the output stream provided. * <p/> * If the OutputStream provided is null, a NullPointerException is thrown. * <p/> * Otherwise, this JsonEncoder will flush its current output and then * reconfigure its output to use a default UTF8 JsonGenerator that writes * to the provided OutputStream. * * @param out * The OutputStream to direct output to. Cannot be null. * @throws IOException * @return this JsonEncoder */ public JsonEncoder configure(OutputStream out) throws IOException { this.configure(getJsonGenerator(out, false)); return this; }
JsonEncoder encoder = EncoderFactory.get().jsonEncoder(schema, output); for (Object datum: fileReader) { encoder.configure(output); writer.write(datum, encoder); encoder.flush();
JsonEncoder(Schema sc, JsonGenerator out) throws IOException { configure(out); this.parser = new Parser(new JsonGrammarGenerator().generate(sc), this); }
JsonEncoder(Schema sc, JsonGenerator out) throws IOException { configure(out); this.parser = new Parser(new JsonGrammarGenerator().generate(sc), this); }
JsonEncoder encoder = EncoderFactory.get().jsonEncoder(reader.getSchema(), new JsonFactory().createJsonGenerator(baos)).configure(baos); writer.write(record, encoder); encoder.flush();