本文整理汇总了Java中org.bson.BsonWriter.writeEndArray方法的典型用法代码示例。如果您正苦于以下问题:Java BsonWriter.writeEndArray方法的具体用法?Java BsonWriter.writeEndArray怎么用?Java BsonWriter.writeEndArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bson.BsonWriter
的用法示例。
在下文中一共展示了BsonWriter.writeEndArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encodeDimension
import org.bson.BsonWriter; //导入方法依赖的package包/类
private void encodeDimension(BsonWriter writer, Object array, EncoderContext encoderContext, Class<?> componentType) {
boolean encodeLastDimension;
Class<?> childComponentType = componentType.getComponentType();
encodeLastDimension = !childComponentType.isArray();
if (childComponentType == byte.class) {
arrayElementCodec.encode(writer, array, encoderContext);
} else {
writer.writeStartArray();
if (encodeLastDimension) {
if (isPrimitive) {
arrayElementCodec.encode(writer, array, encoderContext);
} else {
for (int i = 0; i < Array.getLength(array); i++) {
arrayElementCodec.encode(writer, Array.get(array, i), encoderContext);
}
}
} else {
for (int i = 0; i < Array.getLength(array); i++) {
encodeDimension(writer, Array.get(array, i), encoderContext, childComponentType);
}
}
writer.writeEndArray();
}
}
示例2: encode
import org.bson.BsonWriter; //导入方法依赖的package包/类
@Override
public void encode(BsonWriter writer, Map<K, V> map, EncoderContext encoderContext) {
writer.writeStartArray();
for (Map.Entry<K, V> entry : map.entrySet()) {
writer.writeStartDocument();
writer.writeName("key");
keyTypeCodec.encode(writer, entry.getKey(), encoderContext);
writer.writeName("value");
valueTypeCodec.encode(writer, entry.getValue(), encoderContext);
writer.writeEndDocument();
}
writer.writeEndArray();
}
示例3: encode
import org.bson.BsonWriter; //导入方法依赖的package包/类
@Override
public void encode(BsonWriter writer, C value, EncoderContext encoderContext) {
writer.writeStartArray();
for (V o : value) {
typeCodec.encode(writer, o, encoderContext);
}
writer.writeEndArray();
}
示例4: encode
import org.bson.BsonWriter; //导入方法依赖的package包/类
public void encode(BsonWriter bsonWriter, Field field, Object fieldValue) {
bsonWriter.writeStartArray();
Class<?> fieldType = field.getType();
if (fieldType.isArray()) {
handleArrayForEncodeWriter(bsonWriter, field, (Object[]) fieldValue);
} else if (Collection.class.isAssignableFrom(fieldType)) {
handleCollectionForEncodeWriter(bsonWriter, field, (Collection) fieldValue);
} else {
throw new BsonMapperConverterException("exception should be never happen.the field:" + Utils.getBsonName(field) + "should be array or Collection");
}
bsonWriter.writeEndArray();
}