本文整理汇总了Java中org.bson.BsonBinary.getData方法的典型用法代码示例。如果您正苦于以下问题:Java BsonBinary.getData方法的具体用法?Java BsonBinary.getData怎么用?Java BsonBinary.getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bson.BsonBinary
的用法示例。
在下文中一共展示了BsonBinary.getData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decode
import org.bson.BsonBinary; //导入方法依赖的package包/类
@Override
protected Collection<Byte> decode(BsonBinary bsonValue) {
final Collection<Byte> value = getInstance();
for(byte bsonByte : bsonValue.getData()) {
value.add(bsonByte);
}
return value;
}
示例2: decode
import org.bson.BsonBinary; //导入方法依赖的package包/类
@Override
public Binary decode(BsonValue bsonValue) {
BsonBinary bsonBinary = bsonValue.asBinary();
return new Binary(bsonBinary.getType(), bsonBinary.getData());
}
示例3: decode
import org.bson.BsonBinary; //导入方法依赖的package包/类
@Override
protected byte[] decode(BsonBinary value) {
return value.getData();
}
示例4: writeBinary
import org.bson.BsonBinary; //导入方法依赖的package包/类
private void writeBinary(BsonReader reader, final MapOrListWriterImpl writer, String fieldName, boolean isList) {
final VarBinaryHolder vb = new VarBinaryHolder();
BsonBinary readBinaryData = reader.readBinaryData();
byte[] data = readBinaryData.getData();
Byte type = (Byte) readBinaryData.getType();
// Based on specified binary type, cast it accordingly
switch (type.intValue()) {
case 1:
// Double 1
writeDouble(ByteBuffer.wrap(data).getDouble(), writer, fieldName, isList);
break;
case 2:
// String 2
writeString(new String(data), writer, fieldName, isList);
break;
case 8:
// Boolean 8
boolean boolValue = (data == null || data.length == 0) ? false : data[0] != 0x00;
writeBoolean(boolValue, writer, fieldName, isList);
break;
case 9:
// Date 9
writeDateTime(ByteBuffer.wrap(data).getLong(), writer, fieldName, isList);
break;
case 13:
// JavaScript 13
writeString(new String(data), writer, fieldName, isList);
break;
case 14:
// Symbol 14
writeString(new String(data), writer, fieldName, isList);
break;
case 15:
// JavaScript (with scope) 15
writeString(new String(data), writer, fieldName, isList);
break;
case 16:
// 32-bit integer 16
writeInt32(ByteBuffer.wrap(data).getInt(), writer, fieldName, isList);
break;
case 17:
// Timestamp 17
writeTimeStamp(ByteBuffer.wrap(data).getInt(), writer, fieldName, isList);
break;
case 18:
// 64-bit integer 18
writeInt64(ByteBuffer.wrap(data).getInt(), writer, fieldName, isList);
break;
default:
// In case of Object(3)/Binary data (5)/Object id (7) or in other case
// considering as VarBinary
final byte[] bytes = readBinaryData.getData();
writeBinary(writer, fieldName, isList, vb, bytes);
break;
}
}