Package org.elasticsearch.xcontent.json
Class JsonXContentGenerator
java.lang.Object
org.elasticsearch.xcontent.json.JsonXContentGenerator
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,XContentGenerator
- Direct Known Subclasses:
CborXContentGenerator,SmileXContentGenerator,YamlXContentGenerator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final com.fasterxml.jackson.core.JsonGeneratorGenerator used to write content -
Constructor Summary
ConstructorsConstructorDescriptionJsonXContentGenerator(com.fasterxml.jackson.core.JsonGenerator baseJsonGenerator, OutputStream os, Set<String> includes, Set<String> excludes) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidcopyCurrentStructure(XContentParser parser) protected voidcopyRawValue(InputStream stream, XContent xContent) voidflush()booleanisClosed()Returnstrueif this XContentGenerator has been closed.booleanprotected booleanWhether this generator supports writing raw data directlyfinal voidvoidvoidwriteBinary(byte[] value) voidwriteBinary(byte[] value, int offset, int len) voidwriteBinaryField(String name, byte[] value) voidwriteBoolean(boolean value) voidwriteBooleanField(String name, boolean value) voidwriteDirectField(String name, CheckedConsumer<OutputStream, IOException> writer) Write a field whose value is written directly to the output stream.voidvoidvoidvoidwriteFieldName(String name) voidvoidwriteNullField(String name) voidwriteNumber(double value) voidwriteNumber(float value) voidwriteNumber(int value) voidwriteNumber(long value) voidwriteNumber(short value) voidwriteNumber(BigDecimal value) voidwriteNumber(BigInteger value) voidwriteNumberField(String name, double value) voidwriteNumberField(String name, float value) voidwriteNumberField(String name, int value) voidwriteNumberField(String name, long value) voidwriteNumberField(String name, BigDecimal value) voidwriteNumberField(String name, BigInteger value) voidwriteRawField(String name, InputStream content) Writes a raw field with the value taken from the bytes in the streamvoidwriteRawField(String name, InputStream content, XContentType contentType) Writes a raw field with the value taken from the bytes in the streamvoidwriteRawValue(InputStream stream, XContentType xContentType) Writes a raw value taken from the bytes in the streamvoidvoidvoidwriteString(char[] value, int offset, int len) voidwriteString(String value) voidwriteStringField(String name, 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, waitMethods inherited from interface org.elasticsearch.xcontent.XContentGenerator
copyCurrentEvent
-
Field Details
-
generator
protected final com.fasterxml.jackson.core.JsonGenerator generatorGenerator used to write content
-
-
Constructor Details
-
JsonXContentGenerator
public JsonXContentGenerator(com.fasterxml.jackson.core.JsonGenerator baseJsonGenerator, OutputStream os, Set<String> includes, Set<String> excludes)
-
-
Method Details
-
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
- Specified by:
writeStartObjectin interfaceXContentGenerator- Throws:
IOException
-
writeEndObject
- Specified by:
writeEndObjectin interfaceXContentGenerator- Throws:
IOException
-
writeStartArray
- Specified by:
writeStartArrayin interfaceXContentGenerator- Throws:
IOException
-
writeEndArray
- Specified by:
writeEndArrayin interfaceXContentGenerator- Throws:
IOException
-
writeFieldName
- Specified by:
writeFieldNamein interfaceXContentGenerator- Throws:
IOException
-
writeNull
- Specified by:
writeNullin interfaceXContentGenerator- Throws:
IOException
-
writeNullField
- Specified by:
writeNullFieldin interfaceXContentGenerator- Throws:
IOException
-
writeBooleanField
- Specified by:
writeBooleanFieldin interfaceXContentGenerator- Throws:
IOException
-
writeBoolean
- Specified by:
writeBooleanin interfaceXContentGenerator- Throws:
IOException
-
writeNumberField
- Specified by:
writeNumberFieldin interfaceXContentGenerator- Throws:
IOException
-
writeNumber
- Specified by:
writeNumberin interfaceXContentGenerator- Throws:
IOException
-
writeNumberField
- Specified by:
writeNumberFieldin interfaceXContentGenerator- Throws:
IOException
-
writeNumber
- Specified by:
writeNumberin interfaceXContentGenerator- Throws:
IOException
-
writeNumberField
- Specified by:
writeNumberFieldin interfaceXContentGenerator- Throws:
IOException
-
writeNumberField
- Specified by:
writeNumberFieldin interfaceXContentGenerator- Throws:
IOException
-
writeNumberField
- Specified by:
writeNumberFieldin interfaceXContentGenerator- Throws:
IOException
-
writeNumber
- Specified by:
writeNumberin interfaceXContentGenerator- Throws:
IOException
-
writeNumberField
- Specified by:
writeNumberFieldin interfaceXContentGenerator- Throws:
IOException
-
writeNumber
- Specified by:
writeNumberin interfaceXContentGenerator- Throws:
IOException
-
writeNumber
- Specified by:
writeNumberin interfaceXContentGenerator- Throws:
IOException
-
writeNumber
- Specified by:
writeNumberin interfaceXContentGenerator- Throws:
IOException
-
writeNumber
- Specified by:
writeNumberin interfaceXContentGenerator- Throws:
IOException
-
writeStringField
- Specified by:
writeStringFieldin interfaceXContentGenerator- Throws:
IOException
-
writeString
- Specified by:
writeStringin interfaceXContentGenerator- Throws:
IOException
-
writeString
- Specified by:
writeStringin interfaceXContentGenerator- Throws:
IOException
-
writeUTF8String
- Specified by:
writeUTF8Stringin interfaceXContentGenerator- Throws:
IOException
-
writeBinaryField
- Specified by:
writeBinaryFieldin interfaceXContentGenerator- Throws:
IOException
-
writeBinary
- Specified by:
writeBinaryin interfaceXContentGenerator- Throws:
IOException
-
writeBinary
- Specified by:
writeBinaryin interfaceXContentGenerator- Throws:
IOException
-
writeEndRaw
public void writeEndRaw() -
writeRawField
Description copied from interface:XContentGeneratorWrites a raw field with the value taken from the bytes in the stream- Specified by:
writeRawFieldin interfaceXContentGenerator- Throws:
IOException
-
writeRawField
public void writeRawField(String name, InputStream content, XContentType contentType) throws IOException Description copied from interface:XContentGeneratorWrites a raw field with the value taken from the bytes in the stream- Specified by:
writeRawFieldin interfaceXContentGenerator- Throws:
IOException
-
writeRawValue
Description copied from interface:XContentGeneratorWrites a raw value taken from the bytes in the stream- Specified by:
writeRawValuein interfaceXContentGenerator- Throws:
IOException
-
supportsRawWrites
protected boolean supportsRawWrites()Whether this generator supports writing raw data directly -
copyRawValue
- Throws:
IOException
-
copyCurrentStructure
- Specified by:
copyCurrentStructurein interfaceXContentGenerator- Throws:
IOException
-
writeDirectField
public void writeDirectField(String name, CheckedConsumer<OutputStream, IOException> writer) throws IOExceptionDescription copied from interface:XContentGeneratorWrite a field whose value is written directly to the output stream. As the content is copied as is, the writer must a valid XContent value (e.g., string is properly escaped and quoted)- Specified by:
writeDirectFieldin interfaceXContentGenerator- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
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
-