Package org.bson

Examples of org.bson.BSONObject.containsField()


    Assert.assertEquals(100, response.getNumberReturned());
    Assert.assertEquals(100, response.getDocuments().size());
   
    for (int i = 0; i < 100; i++) {
      BSONObject doc = response.getDocuments().get(i);
      Assert.assertTrue(doc.containsField("_id"));
      Assert.assertTrue(doc.containsField("name"));
      Assert.assertFalse(doc.containsField("value"));
    }
  }
 
View Full Code Here


    Assert.assertEquals(100, response.getDocuments().size());
   
    for (int i = 0; i < 100; i++) {
      BSONObject doc = response.getDocuments().get(i);
      Assert.assertTrue(doc.containsField("_id"));
      Assert.assertTrue(doc.containsField("name"));
      Assert.assertFalse(doc.containsField("value"));
    }
  }
 
  @Test
View Full Code Here

   
    for (int i = 0; i < 100; i++) {
      BSONObject doc = response.getDocuments().get(i);
      Assert.assertTrue(doc.containsField("_id"));
      Assert.assertTrue(doc.containsField("name"));
      Assert.assertFalse(doc.containsField("value"));
    }
  }
 
  @Test
  public void testCursor() throws Exception {
View Full Code Here

    if (response == null) {
      return null;
    }
    BSONObject reply = (BSONObject) response.getReply();
    if (reply.containsField("Result")) {
      BSONObject result = (BSONObject) reply.get("Result");
      return Bsonify.bsonToQueryResult(result, fields);
    }
    return null;
  }
View Full Code Here

    BSONObject bsonHeader = goRpcBsonDecoder.readObject(inputStream);
    if (LOGGER.isDebugEnabled()) {
      String joinedBsonHeader = Joiner.on(',').withKeyValueSeparator("=").join(bsonHeader.toMap());
      LOGGER.debug("bsonHeader: {}", joinedBsonHeader);
    }
    if (bsonHeader.containsField("Error")) {
      Object error = bsonHeader.get("Error");
      if (error instanceof byte[] && ((byte[]) error).length != 0) {
        throw new IOException(new String((byte[]) error, StandardCharsets.UTF_8));
      }
    }
View Full Code Here

  public void ReadResponseHeader(Response response) throws IOException {
    BSONObject headerBson = decoder.readObject(socket.getInputStream());
    response.setServiceMethod(new String((byte[]) headerBson.get(Constants.SERVICE_METHOD)));
    response.setSeq((UnsignedLong) headerBson.get(Constants.SEQ));
    if (headerBson.containsField(Constants.ERROR)) {
      Object error = headerBson.get(Constants.ERROR);
      if (error instanceof byte[] && ((byte[]) error).length != 0) {
        String errorMsg = new String((byte[]) error, CharEncoding.UTF_8);
        response.setError(errorMsg);
      }
View Full Code Here

    }
  }

  public void ReadResponseBody(Response response) throws IOException {
    BSONObject bodyBson = decoder.readObject(socket.getInputStream());
    if (bodyBson.containsField(MAGIC_TAG)) {
      response.setReply(bodyBson.get(MAGIC_TAG));
    } else {
      response.setReply(bodyBson);
    }
  }
View Full Code Here

    private boolean checkMatchesValue(Object queryValue, Object value, boolean valueExists) throws MongoServerException {
        if (queryValue instanceof BSONObject) {
            BSONObject queryObject = (BSONObject) queryValue;

            if (queryObject.containsField("$regex")) {
                String options = "";
                if (queryObject.containsField("$options")) {
                    options = queryObject.get("$options").toString();
                }
View Full Code Here

        if (queryValue instanceof BSONObject) {
            BSONObject queryObject = (BSONObject) queryValue;

            if (queryObject.containsField("$regex")) {
                String options = "";
                if (queryObject.containsField("$options")) {
                    options = queryObject.get("$options").toString();
                }

                Pattern pattern = Utils.createPattern(queryObject.get("$regex").toString(), options);
                return pattern.matcher(value.toString()).find();
View Full Code Here

            BSONObject update = (BSONObject) updateObj.get("u");
            boolean multi = Utils.isTrue(updateObj.get("multi"));
            boolean upsert = Utils.isTrue(updateObj.get("upsert"));
            final BSONObject result = updateDocuments(channel, collectionName, selector, update, multi, upsert);
            updatedExisting |= Utils.isTrue(result.get("updatedExisting"));
            if (result.containsField("upserted")) {
                final Object id = result.get("upserted");
                final BSONObject upserted = new BasicBSONObject("index", upserts.size());
                upserted.put("_id", id);
                upserts.add(upserted);
            }
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.