MCPcopy Create free account
hub / github.com/MariaDB/server / GetFieldObject

Method GetFieldObject

storage/connect/Mongo3Interface.java:387–435  ·  view source on GitHub ↗
(String path)

Source from the content-addressed store, hash-verified

385 } // end of ColDescName
386
387 protected BsonValue GetFieldObject(String path) {
388 BsonValue o = doc;
389 BsonDocument dob = null;
390 BsonArray ary = null;
391 String[] names = null;
392
393 if (path == null || path.equals("") || path.equals("*"))
394 return doc;
395 else if (o instanceof BsonDocument)
396 dob = doc;
397 else if (o instanceof BsonArray)
398 ary = (BsonArray) o;
399 else
400 return doc;
401
402 try {
403 names = path.split("\\.");
404
405 for (String name : names) {
406 if (ary != null) {
407 o = ary.get(Integer.parseInt(name));
408 } else
409 o = dob.get(name);
410
411 if (o == null)
412 break;
413
414 if (DEBUG)
415 System.out.println("Class o = " + o.getClass());
416
417 if (o instanceof BsonDocument) {
418 dob = (BsonDocument) o;
419 ary = null;
420 } else if (o instanceof BsonArray) {
421 ary = (BsonArray) o;
422 } else
423 break;
424
425 } // endfor name
426
427 } catch (IndexOutOfBoundsException x) {
428 o = null;
429 } catch (MongoException me) {
430 SetErrmsg(me);
431 o = null;
432 } // end try/catch
433
434 return o;
435 } // end of GetFieldObject
436
437 public String GetField(String path) {
438 BsonValue o = GetFieldObject(path);

Callers 1

GetFieldMethod · 0.95

Calls 4

SetErrmsgMethod · 0.95
splitMethod · 0.80
equalsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected