Java Code Examples for org.elasticsearch.common.xcontent.XContentGenerator#writeEndArray()
The following examples show how to use
org.elasticsearch.common.xcontent.XContentGenerator#writeEndArray() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XmlXContentGenerator.java From elasticsearch-xml with Apache License 2.0 | 5 votes |
public static void copyCurrentStructure(XContentGenerator generator, XContentParser parser) throws IOException { XContentParser.Token t = parser.currentToken(); // Let's handle field-name separately first if (t == XContentParser.Token.FIELD_NAME) { generator.writeFieldName(parser.currentName()); t = parser.nextToken(); // fall-through to copy the associated value } switch (t) { case START_ARRAY: generator.writeStartArray(); while (parser.nextToken() != XContentParser.Token.END_ARRAY) { copyCurrentStructure(generator, parser); } generator.writeEndArray(); break; case START_OBJECT: generator.writeStartObject(); while (parser.nextToken() != XContentParser.Token.END_OBJECT) { copyCurrentStructure(generator, parser); } generator.writeEndObject(); break; default: // others are simple: copyCurrentEvent(generator, parser); } }
Example 2
Source File: DocumentContentBuilder.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
private void writeMultiReference( XContentGenerator generator, int depth, int maxDepth, Iterable<Entity> mrefEntities) throws IOException { if (!Iterables.isEmpty(mrefEntities)) { generator.writeStartArray(); for (Entity mrefEntity : mrefEntities) { createRecReferenceAttribute(generator, depth, maxDepth, mrefEntity); } generator.writeEndArray(); } else { generator.writeNull(); } }
Example 3
Source File: JsonXContentGenerator.java From crate with Apache License 2.0 | 5 votes |
/** * Low level implementation detail of {@link XContentGenerator#copyCurrentStructure(XContentParser)}. */ private static void copyCurrentStructure(XContentGenerator destination, XContentParser parser) throws IOException { XContentParser.Token token = parser.currentToken(); // Let's handle field-name separately first if (token == XContentParser.Token.FIELD_NAME) { destination.writeFieldName(parser.currentName()); token = parser.nextToken(); // fall-through to copy the associated value } switch (token) { case START_ARRAY: destination.writeStartArray(); while (parser.nextToken() != XContentParser.Token.END_ARRAY) { copyCurrentStructure(destination, parser); } destination.writeEndArray(); break; case START_OBJECT: destination.writeStartObject(); while (parser.nextToken() != XContentParser.Token.END_OBJECT) { copyCurrentStructure(destination, parser); } destination.writeEndObject(); break; default: // others are simple: destination.copyCurrentEvent(parser); } }
Example 4
Source File: XmlXContentGenerator.java From elasticsearch-xml with Apache License 2.0 | 4 votes |
public static void copyCurrentEvent(XContentGenerator generator, XContentParser parser) throws IOException { switch (parser.currentToken()) { case START_OBJECT: generator.writeStartObject(); break; case END_OBJECT: generator.writeEndObject(); break; case START_ARRAY: generator.writeStartArray(); break; case END_ARRAY: generator.writeEndArray(); break; case FIELD_NAME: generator.writeFieldName(parser.currentName()); break; case VALUE_STRING: if (parser.hasTextCharacters()) { generator.writeString(parser.textCharacters(), parser.textOffset(), parser.textLength()); } else { generator.writeString(parser.text()); } break; case VALUE_NUMBER: switch (parser.numberType()) { case INT: generator.writeNumber(parser.intValue()); break; case LONG: generator.writeNumber(parser.longValue()); break; case FLOAT: generator.writeNumber(parser.floatValue()); break; case DOUBLE: generator.writeNumber(parser.doubleValue()); break; } break; case VALUE_BOOLEAN: generator.writeBoolean(parser.booleanValue()); break; case VALUE_NULL: generator.writeNull(); break; case VALUE_EMBEDDED_OBJECT: generator.writeBinary(parser.binaryValue()); } }