/** * Constructs a new builder using the provided xcontent, an OutputStream and some filters. The * filters are used to filter fields that won't be written to the OutputStream. Make sure * to call {@link #close()} when the builder is done with. */ public XContentBuilder(XContent xContent, OutputStream bos, String[] filters) throws IOException { this.bos = bos; this.generator = xContent.createGenerator(bos, filters); }
/** * Creates a new builder using the provided XContent, output stream and some inclusive and/or exclusive filters. When both exclusive and * inclusive filters are provided, the underlying builder will first use exclusion filters to remove fields and then will check the * remaining fields against the inclusive filters. * <p> * Make sure to call {@link #close()} when the builder is done with. * * @param os the output stream * @param includes the inclusive filters: only fields and objects that match the inclusive filters will be written to the output. * @param excludes the exclusive filters: only fields and objects that don't match the exclusive filters will be written to the output. */ public XContentBuilder(XContent xContent, OutputStream os, Set<String> includes, Set<String> excludes) throws IOException { this.bos = os; this.generator = xContent.createGenerator(bos, includes, excludes); }
/** * Creates a new builder using the provided XContent, output stream and some inclusive and/or exclusive filters. When both exclusive and * inclusive filters are provided, the underlying builder will first use exclusion filters to remove fields and then will check the * remaining fields against the inclusive filters. * <p> * Make sure to call {@link #close()} when the builder is done with. * * @param os the output stream * @param includes the inclusive filters: only fields and objects that match the inclusive filters will be written to the output. * @param excludes the exclusive filters: only fields and objects that don't match the exclusive filters will be written to the output. */ public XContentBuilder(XContent xContent, OutputStream os, Set<String> includes, Set<String> excludes) throws IOException { this.bos = os; this.generator = xContent.createGenerator(bos, includes, excludes); }
/** * Creates a new builder using the provided XContent, output stream and some inclusive and/or exclusive filters. When both exclusive and * inclusive filters are provided, the underlying builder will first use exclusion filters to remove fields and then will check the * remaining fields against the inclusive filters. * <p> * Make sure to call {@link #close()} when the builder is done with. * * @param os the output stream * @param includes the inclusive filters: only fields and objects that match the inclusive filters will be written to the output. * @param excludes the exclusive filters: only fields and objects that don't match the exclusive filters will be written to the output. */ public XContentBuilder(XContent xContent, OutputStream os, Set<String> includes, Set<String> excludes) throws IOException { this.bos = os; this.generator = xContent.createGenerator(bos, includes, excludes); }
/** * Creates a new generator using the provided output stream. */ default XContentGenerator createGenerator(OutputStream os) throws IOException { return createGenerator(os, Collections.emptySet(), Collections.emptySet()); }
/** * Creates a new generator using the provided output stream. */ default XContentGenerator createGenerator(OutputStream os) throws IOException { return createGenerator(os, Collections.emptySet(), Collections.emptySet()); }
/** * Creates a new generator using the provided output stream. */ default XContentGenerator createGenerator(OutputStream os) throws IOException { return createGenerator(os, Collections.emptySet(), Collections.emptySet()); }
XContentGenerator generator = XContentType.JSON.xContent().createGenerator(out); XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, query); ) {