Package org.bson.types

Examples of org.bson.types.BasicBSONList


        {
            json = new BasicDBObject();
        }
        else if (base instanceof BasicBSONList)
        {
            json = new BasicBSONList();
        }
        else
        {
            log.warning( "Error, can only process BasicDBObject (JSON) or BasicBSONList (Array), base is a "
                    + base.getClass() );
            return new BasicBSONObject();
        }

        for (String propKey : propMap.keySet())
        {
            if (!propKey.contains( "." ))
            {
                // ignore nulls
                if (propMap.get( propKey ) != null)
                {
                    // check for nested JSON or Array (BasicDBObject or BasicBSONList)
                    if (propMap.get( propKey ).equals( "com.mongodb.BasicDBObject" ))
                    {
                        BasicDBObject subJSON = new BasicDBObject();
                        json.put( propKey, recreateJson( propKey, subJSON, propMap ) );
                    }
                    else if (propMap.get( propKey ).equals( "com.mongodb.BasicDBList" ))
                    {
                        BasicBSONList subArray = new BasicBSONList();
                        json.put( propKey, recreateJson( propKey, subArray, propMap ) );
                    }
                    else
                    {
                        try
View Full Code Here


     * Factory method for creating a new BSON List.
     *
     * @return a new BasicBSONList.
     */
    protected BSONObject createList() {
        return new BasicBSONList();
    }
View Full Code Here

        assertEquals(m.get("z"), "a");
    }

    @Test
    public void testBasicBSONList() {
        BasicBSONList l = new BasicBSONList();
        l.put(10, "x");
        assertEquals(l.get("10"), "x");
        assertEquals(l.get(3), null);
        l.put("10", "y");
        assertEquals(l.get("10"), "y");

        DBCollection c = collection;
        c.insert(BasicDBObjectBuilder.start().add("array", l).get());
        DBObject obj = c.findOne();
        assertEquals(obj.get("array") instanceof List, true);
View Full Code Here

        buf = new StringBuilder();
        serializer.serialize(dbref, buf);
        assertEquals(buf.toString(), "{ \"$ref\" : \"test.test\" , \"$id\" : \"4d83ab59a39562db9c1ae2af\"}");
       
        // test  ITERABLE
        BasicBSONList testList = new BasicBSONList();
        testList.add(new BasicDBObject("key1", "val1"));
        testList.add(new BasicDBObject("key2", "val2"));
        buf = new StringBuilder();
        serializer.serialize(testList, buf);
        assertEquals(buf.toString(), "[ { \"key1\" : \"val1\"} , { \"key2\" : \"val2\"}]");
       
        // test  MAP
View Full Code Here

    public static DBObject large;

    private static void setup() {
        small = new BasicDBObject();

        BasicBSONList a = new BasicBSONList();
        a.put("0", "test");
        a.put("1", "benchmark");
        medium = BasicDBObjectBuilder.start()
            .add("integer", 5)
            .add("number", 5.05)
            .add("boolean", false)
            .add("array", a)
            .get();

        BasicBSONList harvest = new BasicBSONList();
        for (int i=0; i<20; i++) {
            harvest.put(i*14+0, "10gen");
            harvest.put(i*14+1, "web");
            harvest.put(i*14+2, "open");
            harvest.put(i*14+3, "source");
            harvest.put(i*14+4, "application");
            harvest.put(i*14+5, "paas");
            harvest.put(i*14+6, "platform-as-a-service");
            harvest.put(i*14+7, "technology");
            harvest.put(i*14+8, "helps");
            harvest.put(i*14+9, "developers");
            harvest.put(i*14+10, "focus");
            harvest.put(i*14+11, "building");
            harvest.put(i*14+12, "mongodb");
            harvest.put(i*14+13, "mongo");
        }
        large = BasicDBObjectBuilder.start()
            .add("base_url", "http://www.example.com/test-me")
            .add("total_word_count", 6743)
            .add("access_time", new Date())
View Full Code Here

      return null;
    }

    BasicDBObject capabilitiesObj = new BasicDBObject();
    for (Capability capability : capabilities.getCapabilitiesMap().values()) {
      BasicBSONList contexts = new BasicBSONList();
      for (Context c : capability.getContexts()) {
        contexts.add(c.name());
      }
      capabilitiesObj.put(capability.getEventType().name(),
          new BasicDBObject()
              .append(CAPABILITY_CONTEXTS_FIELD, contexts)
              .append(CAPABILITY_FILTER_FIELD, capability.getFilter()));
View Full Code Here

TOP

Related Classes of org.bson.types.BasicBSONList

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.