Package org.bson

Examples of org.bson.BasicBSONDecoder.readObject()


            out.write( b );
       
        ByteArrayInputStream in = new ByteArrayInputStream( out.toByteArray() );
        BSONDecoder d = new BasicBSONDecoder();
        for ( int i=0; i<n; i++ ){
            BSONObject x = d.readObject( in );
            assertEquals( orig , x );
        }
        assertEquals( -1 , in.read() );
    }
View Full Code Here


    byte[] r = baos.toByteArray();
    ByteArrayInputStream bais = new ByteArrayInputStream(r);

    BSONDecoder decoder = new BasicBSONDecoder();
    BSONObject bo = decoder.readObject(bais);
   
    return bo.get("data");
  }
 
  /**
 
View Full Code Here

  }
 
  private void assertRaw(byte[] r) throws Exception {
    ByteArrayInputStream bais = new ByteArrayInputStream(r);
    BSONDecoder decoder = new BasicBSONDecoder();
    BSONObject obj = decoder.readObject(bais);
    byte[] o = (byte[])obj.get("Test");
    CharBuffer buf = ByteBuffer.wrap(o).order(ByteOrder.LITTLE_ENDIAN).asCharBuffer();
    assertEquals(2, buf.remaining());
    char a = buf.get();
    char b = buf.get();
View Full Code Here

    gen.close();
   
    byte[] r = baos.toByteArray();
    ByteArrayInputStream bais = new ByteArrayInputStream(r);
    BSONDecoder decoder = new BasicBSONDecoder();
    BSONObject obj = decoder.readObject(bais);
    byte[] o = (byte[])obj.get("Test");
    assertEquals(2, o.length);
    assertEquals((byte)1, o[0]);
    assertEquals((byte)2, o[1]);
  }
View Full Code Here

    gen.writeEndObject();
    gen.close();
   
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    BSONDecoder decoder = new BasicBSONDecoder();
    BSONObject obj = decoder.readObject(bais);
    String s = (String)obj.get("a\u20AC\u00A2\u00A2bb");
    assertEquals("a\u20AC\u00A2\u00A2bb", s);
  }
 
  @Test
View Full Code Here

    byte[] r = baos.toByteArray();
    ByteArrayInputStream bais = new ByteArrayInputStream(r);

    BSONDecoder decoder = new BasicBSONDecoder();
    return decoder.readObject(bais);
  }
 
  @Test
  public void writeBigDecimalsAsStrings() throws Exception {
    Map<String, Object> data = new LinkedHashMap<String, Object>();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.