Java 类org.bson.BsonBinarySubType 实例源码

项目:BsonMapper    文件:DefaultBsonMapperTest.java   
private BsonTest getObject() {
    BsonTest bsonTest = new BsonTest();
    bsonTest.setTestDouble(20.00);
    bsonTest.setTestString("测试一下");
    byte[] bytes = new byte[3];
    bytes[0] = 3;
    bytes[1] = 4;
    bytes[2] = 1;
    bsonTest.setTestBinary(new Binary(BsonBinarySubType.USER_DEFINED, bytes));
    ArrayList<BsonTest> testArray = new ArrayList<BsonTest>();
    BsonTest test1 = new BsonTest();
    test1.setTestDouble(30.00);
    testArray.add(test1);
    bsonTest.setTestArray(testArray);
    bsonTest.setBsonTest(test1);
    bsonTest.setTestObjectId(new ObjectId());
    bsonTest.setTestStringObjectId("59074307568fad36808ff0c5");
    bsonTest.setTestBoolean(true);
    bsonTest.setTestDate(new Date());
    bsonTest.setTestNull(null);
    bsonTest.setTestInt(2333);
    bsonTest.setTestLong(2222L);
    return bsonTest;
}
项目:BsonMapper    文件:BsonDocumentConverterTest.java   
private BsonTest getObject() {
    BsonTest bsonTest = new BsonTest();
    bsonTest.setTestDouble(20.00);
    bsonTest.setTestString("测试一下");
    byte[] bytes = new byte[3];
    bytes[0] = 3;
    bytes[1] = 4;
    bytes[2] = 1;
    bsonTest.setTestBinary(new Binary(BsonBinarySubType.USER_DEFINED, bytes));
    ArrayList<BsonTest> testArray = new ArrayList<BsonTest>();
    BsonTest test1 = new BsonTest();
    test1.setTestDouble(30.00);
    testArray.add(test1);
    bsonTest.setTestArray(testArray);
    bsonTest.setBsonTest(test1);
    ObjectId testObjectId = new ObjectId();
    bsonTest.setTestObjectId(testObjectId);
    bsonTest.setTestStringObjectId(testObjectId.toHexString());
    bsonTest.setTestBoolean(true);
    bsonTest.setTestDate(new Date());
    bsonTest.setTestNull(null);
    bsonTest.setTestInt(2333);
    bsonTest.setTestLong(2222L);
    return bsonTest;
}
项目:bsoneer    文件:DefaultReader.java   
@SuppressWarnings("unchecked")
public <U> U readValue(final BsonReader reader,
        final DecoderContext decoderContext) {
    BsonType bsonType = reader.getCurrentBsonType();
    if (bsonType == BsonType.NULL) {
        reader.readNull();
        return null;
    } else if (bsonType == BsonType.ARRAY) {
        return (U) readList(reader, decoderContext);
    } else if (bsonType == BsonType.BINARY) {
        byte bsonSubType = reader.peekBinarySubType();
        if (bsonSubType == BsonBinarySubType.UUID_STANDARD.getValue()
                || bsonSubType == BsonBinarySubType.UUID_LEGACY.getValue()) {
            return (U) registry.get().get(UUID.class).decode(reader,
                    decoderContext);
        }
    }
    return (U) registry.get().get(bsonTypeClassMap.get(bsonType)).decode(reader,
            decoderContext);
}
项目:polymorphia    文件:SpecialFieldsMapCodec.java   
private Object readValue(final BsonReader reader, final DecoderContext decoderContext) {
    BsonType bsonType = reader.getCurrentBsonType();
    if (bsonType == BsonType.NULL) {
        reader.readNull();
        return null;
    } else if (bsonType == BsonType.ARRAY) {
        return readList(reader, decoderContext);
    } else if (bsonType == BsonType.BINARY && BsonBinarySubType.isUuid(reader.peekBinarySubType()) && reader.peekBinarySize() == 16) {
        return codecRegistry.get(UUID.class).decode(reader, decoderContext);
    }
    return bsonTypeCodecMap.get(bsonType).decode(reader, decoderContext);
}