Package org.bson.types

Examples of org.bson.types.Code


    public Object getValue() {
        String code = getStringFieldValue(Item.value);
        String scope = getStringFieldValue(Item.scope);
        if (!scope.isEmpty())
            return new CodeWScope(code, (BSONObject) JSON.parse(scope));
        return new Code(code);
    }
View Full Code Here


        return new Code(code);
    }

    @Override
    public void setValue(Object value) {
        Code code = (Code) value;
        setStringFieldValue(Item.value, code.getCode());
        if (code instanceof CodeWScope) {
            BasicDBObject scope = (BasicDBObject) ((CodeWScope)code).getScope();
            setStringFieldValue(Item.scope, scope.toString());
        }
    }
View Full Code Here

        new DbJob() {

            @Override
            public Object doRun() throws Exception {
                DBObject obj = new BasicDBObject("_id", name);
                obj.put("value", new Code(code));
                return col.insert(obj);
            }

            @Override
            public String getNS() {
View Full Code Here

        } else if (type.startsWith("ObjectId")) {
            val = new ObjectId();
        } else if (type.equals("Boolean")) {
            val = new Boolean(true);
        } else if (type.equals("Code")) {
            val = new Code("");
        } else if (type.equals("Date")) {
            val = new Date();
        } else if (type.startsWith("Double")) {
            val = new Double(0.0);
        } else if (type.equals("Pattern")) {
View Full Code Here

    break;
  case 7://ObjectId
    newValue = new ObjectId( value );
    break;
  case 8://Code
    newValue = new Code( value );
    break;
  case 9://Binary not implemented
    break;
  case 10://Boolean
    newValue = new Boolean( value );
View Full Code Here

    {
    return new Long( value );
    }
  else if( currentType == Code.class )
    {
    return new Code( value );
    }
  else if( currentType == java.util.regex.Pattern.class )
    {
    try
      {
View Full Code Here


        c.drop();
        BasicDBObject in = new BasicDBObject();
        in.put( "_id" , 1 );
        in.put( "a" , new Code("x=5") );
        in.put( "b" , new CodeWScope( "x=5" , new BasicDBObject( "x" , 2 ) ) );
        c.insert( in );

        DBObject out = c.findOne();
View Full Code Here

        _put( name , new UUID(part1, part2) );
    }

    @Override
    public void gotCode(final String name, final String code) {
        _put( name , new Code( code ) );
    }
View Full Code Here

        b.append( "double245_6289", 245.6289 );
        b.append( "oid", test_oid );
        // Symbol wonky
        b.append( "symbol", new Symbol( "foobar" ) );
        // Code wonky
        b.append( "code", new Code( "var x = 12345;"  ) );
        // TODO - Shell doesn't work with Code W/ Scope, return to this test later
        /*
        b.append( "code_scoped", new CodeWScope( "return x * 500;", test_doc ) );*/
        b.append( "str", "foobarbaz" );
        b.append( "ref", new DBRef( getDatabase(), "testRef", test_ref_id ) );
View Full Code Here

                                     _input.getIntBE( record.valueOffset + 4 ),
                                     _input.getIntBE( record.valueOffset + 8 ) );
            case BSON.SYMBOL:
                return new Symbol( _input.getUTF8String( record.valueOffset ) );
            case BSON.CODE:
                return new Code( _input.getUTF8String( record.valueOffset ) );
            case BSON.STRING:
                return _input.getUTF8String( record.valueOffset );
            case BSON.CODE_W_SCOPE:
                int strsize = _input.getInt( record.valueOffset + 4 );
                String code = _input.getUTF8String( record.valueOffset + 4 );
View Full Code Here

TOP

Related Classes of org.bson.types.Code

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.