コード例 #1
0
  /**
   * This method process the settings portion of the <code>Document</code>.
   *
   * @param root The root <code>Node</code> of the <code>Document</code> we are building. This
   *     <code>Node</code> should be a TAG_OFFICE_SETTINGS tag.
   */
  protected void processSettings(Node root) {

    Element configItemSetEntry = settings.createElement(TAG_CONFIG_ITEM_SET);
    configItemSetEntry.setAttribute(ATTRIBUTE_CONFIG_NAME, "view-settings");
    Element configItemMapIndexed = settings.createElement(TAG_CONFIG_ITEM_MAP_INDEXED);
    configItemMapIndexed.setAttribute(ATTRIBUTE_CONFIG_NAME, "Views");
    Element configItemMapEntry = settings.createElement(TAG_CONFIG_ITEM_MAP_ENTRY);
    BookSettings bs = decoder.getSettings();
    bs.writeNode(settings, configItemMapEntry);

    configItemMapIndexed.appendChild(configItemMapEntry);
    configItemSetEntry.appendChild(configItemMapIndexed);
    root.appendChild(configItemSetEntry);
  }
コード例 #2
0
 @Override
 public JSONObject backup() {
   final BookBackupType backupType = BackupSettings.current().bookBackup;
   final JSONObject root = new JSONObject();
   if (backupType == BookBackupType.NONE) {
     return root;
   }
   try {
     final JSONArray books = new JSONArray();
     root.put("books", books);
     final Map<String, BookSettings> m =
         backupType == BookBackupType.RECENT ? getRecentBooks(true) : getAllBooks();
     for (final BookSettings bs : m.values()) {
       final JSONObject obj = bs.toJSON();
       books.put(obj);
     }
   } catch (final JSONException ex) {
     SettingsManager.LCTX.e("Error on recent book backup: " + ex.getMessage());
   }
   return root;
 }