better support for "embedded" token types (binaries) when parsing

This commit is contained in:
Shay Banon 2011-12-19 15:51:05 +02:00
parent e827c56be4
commit 1f250ede50
3 changed files with 10 additions and 0 deletions

View File

@ -187,6 +187,8 @@ public class XContentHelper {
case VALUE_NULL:
generator.writeNull();
break;
case VALUE_EMBEDDED_OBJECT:
generator.writeBinary(parser.binaryValue());
}
}

View File

@ -107,6 +107,8 @@ public class XContentMapConverter {
return readMap(parser, mapFactory);
} else if (t == XContentParser.Token.START_ARRAY) {
return readList(parser, mapFactory, t);
} else if (t == XContentParser.Token.VALUE_EMBEDDED_OBJECT) {
return parser.binaryValue();
}
return null;
}

View File

@ -736,6 +736,12 @@ public class ObjectMapper implements Mapper, AllFieldMapper.IncludeInAll {
builder = booleanField(currentFieldName);
}
mapper = builder.build(builderContext);
} else if (token == XContentParser.Token.VALUE_EMBEDDED_OBJECT) {
Mapper.Builder builder = context.root().findTemplateBuilder(context, currentFieldName, "binary");
if (builder == null) {
builder = binaryField(currentFieldName);
}
mapper = builder.build(builderContext);
} else {
Mapper.Builder builder = context.root().findTemplateBuilder(context, currentFieldName, null);
if (builder != null) {