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.JsonGenerator
generator
Generator 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
Modifier and Type Method Description void
close()
XContentType
contentType()
void
copyCurrentStructure(XContentParser parser)
protected void
copyRawValue(java.io.InputStream stream, XContent xContent)
void
flush()
boolean
isClosed()
Returnstrue
if this XContentGenerator has been closed.boolean
isPrettyPrint()
protected boolean
supportsRawWrites()
Whether this generator supports writing raw data directlyvoid
usePrettyPrint()
void
usePrintLineFeedAtEnd()
void
writeBinary(byte[] value)
void
writeBinary(byte[] value, int offset, int len)
void
writeBinaryField(java.lang.String name, byte[] value)
void
writeBoolean(boolean value)
void
writeBooleanField(java.lang.String name, boolean value)
void
writeEndArray()
void
writeEndObject()
void
writeEndRaw()
void
writeFieldName(java.lang.String name)
void
writeNull()
void
writeNullField(java.lang.String name)
void
writeNumber(double value)
void
writeNumber(float value)
void
writeNumber(int value)
void
writeNumber(long value)
void
writeNumber(short value)
void
writeNumber(java.math.BigDecimal value)
void
writeNumber(java.math.BigInteger value)
void
writeNumberField(java.lang.String name, double value)
void
writeNumberField(java.lang.String name, float value)
void
writeNumberField(java.lang.String name, int value)
void
writeNumberField(java.lang.String name, long value)
void
writeNumberField(java.lang.String name, java.math.BigDecimal value)
void
writeNumberField(java.lang.String name, java.math.BigInteger value)
void
writeRawField(java.lang.String name, java.io.InputStream content)
Writes a raw field with the value taken from the bytes in the streamvoid
writeRawField(java.lang.String name, java.io.InputStream content, XContentType contentType)
Writes a raw field with the value taken from the bytes in the streamvoid
writeRawValue(java.io.InputStream stream, XContentType xContentType)
Writes a raw value taken from the bytes in the streamvoid
writeStartArray()
void
writeStartObject()
void
writeString(char[] value, int offset, int len)
void
writeString(java.lang.String value)
void
writeStringField(java.lang.String name, java.lang.String value)
void
writeUTF8String(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:
contentType
in interfaceXContentGenerator
-
usePrettyPrint
public final void usePrettyPrint()
- Specified by:
usePrettyPrint
in interfaceXContentGenerator
-
isPrettyPrint
public boolean isPrettyPrint()
- Specified by:
isPrettyPrint
in interfaceXContentGenerator
-
usePrintLineFeedAtEnd
public void usePrintLineFeedAtEnd()
- Specified by:
usePrintLineFeedAtEnd
in interfaceXContentGenerator
-
writeStartObject
public void writeStartObject() throws java.io.IOException
- Specified by:
writeStartObject
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeEndObject
public void writeEndObject() throws java.io.IOException
- Specified by:
writeEndObject
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeStartArray
public void writeStartArray() throws java.io.IOException
- Specified by:
writeStartArray
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeEndArray
public void writeEndArray() throws java.io.IOException
- Specified by:
writeEndArray
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeFieldName
public void writeFieldName(java.lang.String name) throws java.io.IOException
- Specified by:
writeFieldName
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeNull
public void writeNull() throws java.io.IOException
- Specified by:
writeNull
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeNullField
public void writeNullField(java.lang.String name) throws java.io.IOException
- Specified by:
writeNullField
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeBooleanField
public void writeBooleanField(java.lang.String name, boolean value) throws java.io.IOException
- Specified by:
writeBooleanField
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeBoolean
public void writeBoolean(boolean value) throws java.io.IOException
- Specified by:
writeBoolean
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeNumberField
public void writeNumberField(java.lang.String name, double value) throws java.io.IOException
- Specified by:
writeNumberField
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeNumber
public void writeNumber(double value) throws java.io.IOException
- Specified by:
writeNumber
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeNumberField
public void writeNumberField(java.lang.String name, float value) throws java.io.IOException
- Specified by:
writeNumberField
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeNumber
public void writeNumber(float value) throws java.io.IOException
- Specified by:
writeNumber
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeNumberField
public void writeNumberField(java.lang.String name, int value) throws java.io.IOException
- Specified by:
writeNumberField
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeNumberField
public void writeNumberField(java.lang.String name, java.math.BigInteger value) throws java.io.IOException
- Specified by:
writeNumberField
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeNumberField
public void writeNumberField(java.lang.String name, java.math.BigDecimal value) throws java.io.IOException
- Specified by:
writeNumberField
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeNumber
public void writeNumber(int value) throws java.io.IOException
- Specified by:
writeNumber
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeNumberField
public void writeNumberField(java.lang.String name, long value) throws java.io.IOException
- Specified by:
writeNumberField
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeNumber
public void writeNumber(long value) throws java.io.IOException
- Specified by:
writeNumber
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeNumber
public void writeNumber(short value) throws java.io.IOException
- Specified by:
writeNumber
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeNumber
public void writeNumber(java.math.BigInteger value) throws java.io.IOException
- Specified by:
writeNumber
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeNumber
public void writeNumber(java.math.BigDecimal value) throws java.io.IOException
- Specified by:
writeNumber
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeStringField
public void writeStringField(java.lang.String name, java.lang.String value) throws java.io.IOException
- Specified by:
writeStringField
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeString
public void writeString(java.lang.String value) throws java.io.IOException
- Specified by:
writeString
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeString
public void writeString(char[] value, int offset, int len) throws java.io.IOException
- Specified by:
writeString
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeUTF8String
public void writeUTF8String(byte[] value, int offset, int length) throws java.io.IOException
- Specified by:
writeUTF8String
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeBinaryField
public void writeBinaryField(java.lang.String name, byte[] value) throws java.io.IOException
- Specified by:
writeBinaryField
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeBinary
public void writeBinary(byte[] value) throws java.io.IOException
- Specified by:
writeBinary
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeBinary
public void writeBinary(byte[] value, int offset, int len) throws java.io.IOException
- Specified by:
writeBinary
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeEndRaw
public void writeEndRaw()
-
writeRawField
public void writeRawField(java.lang.String name, java.io.InputStream content) throws java.io.IOException
Description copied from interface:XContentGenerator
Writes a raw field with the value taken from the bytes in the stream- Specified by:
writeRawField
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeRawField
public void writeRawField(java.lang.String name, java.io.InputStream content, XContentType contentType) throws java.io.IOException
Description copied from interface:XContentGenerator
Writes a raw field with the value taken from the bytes in the stream- Specified by:
writeRawField
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
writeRawValue
public void writeRawValue(java.io.InputStream stream, XContentType xContentType) throws java.io.IOException
Description copied from interface:XContentGenerator
Writes a raw value taken from the bytes in the stream- Specified by:
writeRawValue
in 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:
copyCurrentStructure
in interfaceXContentGenerator
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException
- Specified by:
flush
in interfacejava.io.Flushable
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
isClosed
public boolean isClosed()
Description copied from interface:XContentGenerator
Returnstrue
if this XContentGenerator has been closed. A closed generator can not do any more output.- Specified by:
isClosed
in interfaceXContentGenerator
-
-