Exemplo n.º 1
0
 public List<Object> extractDBRefValue(DBRefBase ref, String refKey) {
   if ("$id".equals(refKey)) {
     return Collections.singletonList(ref.getId());
   } else if ("$ref".equals(refKey)) {
     return Collections.<Object>singletonList(ref.getRef());
   } else if ("$db".equals(refKey)) {
     return Collections.<Object>singletonList(ref.getDB());
   } else return Collections.emptyList();
 }
Exemplo n.º 2
0
  protected void putDBRef(String name, DBRefBase ref) {
    _put(OBJECT, name);
    final int sizePos = _buf.getPosition();
    _buf.writeInt(0);

    _putObjectField("$ref", ref.getRef());
    _putObjectField("$id", ref.getId());

    _buf.write(EOO);
    _buf.writeInt(sizePos, _buf.getPosition() - sizePos);
  }