Пример #1
0
 /**
  * Sets the reference to a {@link DynamicRealmList} on the given field.
  *
  * @param fieldName the field name.
  * @param list the list of references.
  * @throws IllegalArgumentException if field name doesn't exists, it doesn't contain a list of
  *     links or the type of the object represented by the DynamicRealmObject doesn't match.
  */
 public void setList(String fieldName, DynamicRealmList list) {
   long columnIndex = row.getColumnIndex(fieldName);
   LinkView links = row.getLinkList(columnIndex);
   links.clear();
   for (DynamicRealmObject obj : list) {
     links.add(obj.row.getIndex());
   }
 }
Пример #2
0
 @Override
 public String toString() {
   if (row == null || !row.isAttached()) {
     return "Invalid object";
   }
   StringBuilder sb = new StringBuilder(row.getTable().getName() + " = [");
   String[] fields = getFieldNames();
   for (String field : fields) {
     long columnIndex = row.getColumnIndex(field);
     ColumnType type = row.getColumnType(columnIndex);
     sb.append("{");
     switch (type) {
       case BOOLEAN:
         sb.append(field + ": " + row.getBoolean(columnIndex));
         break;
       case INTEGER:
         sb.append(field + ": " + row.getLong(columnIndex));
         break;
       case FLOAT:
         sb.append(field + ": " + row.getFloat(columnIndex));
         break;
       case DOUBLE:
         sb.append(field + ": " + row.getDouble(columnIndex));
         break;
       case STRING:
         sb.append(field + ": " + row.getString(columnIndex));
         break;
       case BINARY:
         sb.append(field + ": " + row.getBinaryByteArray(columnIndex));
         break;
       case DATE:
         sb.append(field + ": " + row.getDate(columnIndex));
         break;
       case LINK:
         if (row.isNullLink(columnIndex)) {
           sb.append("null");
         } else {
           sb.append(field + ": " + row.getTable().getLinkTarget(columnIndex).getName());
         }
         break;
       case LINK_LIST:
         String targetType = row.getTable().getLinkTarget(columnIndex).getName();
         sb.append(
             String.format(
                 "%s: RealmList<%s>[%s]", field, targetType, row.getLinkList(columnIndex).size()));
         break;
       case TABLE:
       case MIXED:
       default:
         sb.append(field + ": ?");
     }
     sb.append("}, ");
   }
   sb.replace(sb.length() - 2, sb.length(), "");
   sb.append("]");
   return sb.toString();
 }
Пример #3
0
 /**
  * Returns the {@link io.realm.RealmList} of objects being linked to from this field. This list is
  * returned as a {@link DynamicRealmList}.
  *
  * @param fieldName the name of field.
  * @return the {@link DynamicRealmList} representation of the RealmList.
  * @throws IllegalArgumentException if field name doesn't exists or it doesn't contain a list of
  *     links.
  */
 public DynamicRealmList getList(String fieldName) {
   long columnIndex = row.getColumnIndex(fieldName);
   return new DynamicRealmList(row.getLinkList(columnIndex), realm);
 }