Class JsonXContentGenerator
- java.lang.Object
-
- org.elasticsearch.common.xcontent.json.JsonXContentGenerator
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable,XContentGenerator
- Direct Known Subclasses:
CborXContentGenerator,SmileXContentGenerator,YamlXContentGenerator
public class JsonXContentGenerator extends java.lang.Object implements XContentGenerator
-
-
Field Summary
Fields Modifier and Type Field Description protected com.fasterxml.jackson.core.JsonGeneratorgeneratorGenerator used to write content
-
Constructor Summary
Constructors Constructor Description JsonXContentGenerator(com.fasterxml.jackson.core.JsonGenerator jsonGenerator, java.io.OutputStream os, java.util.Set<java.lang.String> includes, java.util.Set<java.lang.String> excludes)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()XContentTypecontentType()voidcopyCurrentStructure(XContentParser parser)protected voidcopyRawValue(java.io.InputStream stream, XContent xContent)voidflush()booleanisClosed()Returnstrueif this XContentGenerator has been closed.booleanisPrettyPrint()protected booleansupportsRawWrites()Whether this generator supports writing raw data directlyvoidusePrettyPrint()voidusePrintLineFeedAtEnd()voidwriteBinary(byte[] value)voidwriteBinary(byte[] value, int offset, int len)voidwriteBinaryField(java.lang.String name, byte[] value)voidwriteBoolean(boolean value)voidwriteBooleanField(java.lang.String name, boolean value)voidwriteEndArray()voidwriteEndObject()voidwriteEndRaw()voidwriteFieldName(java.lang.String name)voidwriteNull()voidwriteNullField(java.lang.String name)voidwriteNumber(double value)voidwriteNumber(float value)voidwriteNumber(int value)voidwriteNumber(long value)voidwriteNumber(short value)voidwriteNumberField(java.lang.String name, double value)voidwriteNumberField(java.lang.String name, float value)voidwriteNumberField(java.lang.String name, int value)voidwriteNumberField(java.lang.String name, long value)voidwriteRawField(java.lang.String name, java.io.InputStream content)Writes a raw field with the value taken from the bytes in the streamvoidwriteRawField(java.lang.String name, java.io.InputStream content, XContentType contentType)Writes a raw field with the value taken from the bytes in the streamvoidwriteRawValue(java.io.InputStream stream, XContentType xContentType)Writes a raw value taken from the bytes in the streamvoidwriteStartArray()voidwriteStartObject()voidwriteString(char[] value, int offset, int len)voidwriteString(java.lang.String value)voidwriteStringField(java.lang.String name, java.lang.String value)voidwriteUTF8String(byte[] value, int offset, int length)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.common.xcontent.XContentGenerator
copyCurrentEvent
-
-
-
-
Method Detail
-
contentType
public XContentType contentType()
- Specified by:
contentTypein interfaceXContentGenerator
-
usePrettyPrint
public final void usePrettyPrint()
- Specified by:
usePrettyPrintin interfaceXContentGenerator
-
isPrettyPrint
public boolean isPrettyPrint()
- Specified by:
isPrettyPrintin interfaceXContentGenerator
-
usePrintLineFeedAtEnd
public void usePrintLineFeedAtEnd()
- Specified by:
usePrintLineFeedAtEndin interfaceXContentGenerator
-
writeStartObject
public void writeStartObject() throws java.io.IOException- Specified by:
writeStartObjectin interfaceXContentGenerator- Throws:
java.io.IOException
-
writeEndObject
public void writeEndObject() throws java.io.IOException- Specified by:
writeEndObjectin interfaceXContentGenerator- Throws:
java.io.IOException
-
writeStartArray
public void writeStartArray() throws java.io.IOException- Specified by:
writeStartArrayin interfaceXContentGenerator- Throws:
java.io.IOException
-
writeEndArray
public void writeEndArray() throws java.io.IOException- Specified by:
writeEndArrayin interfaceXContentGenerator- Throws:
java.io.IOException
-
writeFieldName
public void writeFieldName(java.lang.String name) throws java.io.IOException- Specified by:
writeFieldNamein interfaceXContentGenerator- Throws:
java.io.IOException
-
writeNull
public void writeNull() throws java.io.IOException- Specified by:
writeNullin interfaceXContentGenerator- Throws:
java.io.IOException
-
writeNullField
public void writeNullField(java.lang.String name) throws java.io.IOException- Specified by:
writeNullFieldin interfaceXContentGenerator- Throws:
java.io.IOException
-
writeBooleanField
public void writeBooleanField(java.lang.String name, boolean value) throws java.io.IOException- Specified by:
writeBooleanFieldin interfaceXContentGenerator- Throws:
java.io.IOException
-
writeBoolean
public void writeBoolean(boolean value) throws java.io.IOException- Specified by:
writeBooleanin interfaceXContentGenerator- Throws:
java.io.IOException
-
writeNumberField
public void writeNumberField(java.lang.String name, double value) throws java.io.IOException- Specified by:
writeNumberFieldin interfaceXContentGenerator- Throws:
java.io.IOException
-
writeNumber
public void writeNumber(double value) throws java.io.IOException- Specified by:
writeNumberin interfaceXContentGenerator- Throws:
java.io.IOException
-
writeNumberField
public void writeNumberField(java.lang.String name, float value) throws java.io.IOException- Specified by:
writeNumberFieldin interfaceXContentGenerator- Throws:
java.io.IOException
-
writeNumber
public void writeNumber(float value) throws java.io.IOException- Specified by:
writeNumberin interfaceXContentGenerator- Throws:
java.io.IOException
-
writeNumberField
public void writeNumberField(java.lang.String name, int value) throws java.io.IOException- Specified by:
writeNumberFieldin interfaceXContentGenerator- Throws:
java.io.IOException
-
writeNumber
public void writeNumber(int value) throws java.io.IOException- Specified by:
writeNumberin interfaceXContentGenerator- Throws:
java.io.IOException
-
writeNumberField
public void writeNumberField(java.lang.String name, long value) throws java.io.IOException- Specified by:
writeNumberFieldin interfaceXContentGenerator- Throws:
java.io.IOException
-
writeNumber
public void writeNumber(long value) throws java.io.IOException- Specified by:
writeNumberin interfaceXContentGenerator- Throws:
java.io.IOException
-
writeNumber
public void writeNumber(short value) throws java.io.IOException- Specified by:
writeNumberin interfaceXContentGenerator- Throws:
java.io.IOException
-
writeStringField
public void writeStringField(java.lang.String name, java.lang.String value) throws java.io.IOException- Specified by:
writeStringFieldin interfaceXContentGenerator- Throws:
java.io.IOException
-
writeString
public void writeString(java.lang.String value) throws java.io.IOException- Specified by:
writeStringin interfaceXContentGenerator- Throws:
java.io.IOException
-
writeString
public void writeString(char[] value, int offset, int len) throws java.io.IOException- Specified by:
writeStringin interfaceXContentGenerator- Throws:
java.io.IOException
-
writeUTF8String
public void writeUTF8String(byte[] value, int offset, int length) throws java.io.IOException- Specified by:
writeUTF8Stringin interfaceXContentGenerator- Throws:
java.io.IOException
-
writeBinaryField
public void writeBinaryField(java.lang.String name, byte[] value) throws java.io.IOException- Specified by:
writeBinaryFieldin interfaceXContentGenerator- Throws:
java.io.IOException
-
writeBinary
public void writeBinary(byte[] value) throws java.io.IOException- Specified by:
writeBinaryin interfaceXContentGenerator- Throws:
java.io.IOException
-
writeBinary
public void writeBinary(byte[] value, int offset, int len) throws java.io.IOException- Specified by:
writeBinaryin interfaceXContentGenerator- Throws:
java.io.IOException
-
writeEndRaw
public void writeEndRaw()
-
writeRawField
public void writeRawField(java.lang.String name, java.io.InputStream content) throws java.io.IOExceptionDescription copied from interface:XContentGeneratorWrites a raw field with the value taken from the bytes in the stream- Specified by:
writeRawFieldin interfaceXContentGenerator- Throws:
java.io.IOException
-
writeRawField
public void writeRawField(java.lang.String name, java.io.InputStream content, XContentType contentType) throws java.io.IOExceptionDescription copied from interface:XContentGeneratorWrites a raw field with the value taken from the bytes in the stream- Specified by:
writeRawFieldin interfaceXContentGenerator- Throws:
java.io.IOException
-
writeRawValue
public void writeRawValue(java.io.InputStream stream, XContentType xContentType) throws java.io.IOExceptionDescription copied from interface:XContentGeneratorWrites a raw value taken from the bytes in the stream- Specified by:
writeRawValuein interfaceXContentGenerator- Throws:
java.io.IOException
-
supportsRawWrites
protected boolean supportsRawWrites()
Whether this generator supports writing raw data directly
-
copyRawValue
protected void copyRawValue(java.io.InputStream stream, XContent xContent) throws java.io.IOException- Throws:
java.io.IOException
-
copyCurrentStructure
public void copyCurrentStructure(XContentParser parser) throws java.io.IOException
- Specified by:
copyCurrentStructurein interfaceXContentGenerator- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException- Specified by:
flushin interfacejava.io.Flushable- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
isClosed
public boolean isClosed()
Description copied from interface:XContentGeneratorReturnstrueif this XContentGenerator has been closed. A closed generator can not do any more output.- Specified by:
isClosedin interfaceXContentGenerator
-
-