当前位置: 首页>>代码示例>>Java>>正文


Java ExtendedJSONObject.parseJSONObject方法代码示例

本文整理汇总了Java中org.mozilla.gecko.sync.ExtendedJSONObject.parseJSONObject方法的典型用法代码示例。如果您正苦于以下问题:Java ExtendedJSONObject.parseJSONObject方法的具体用法?Java ExtendedJSONObject.parseJSONObject怎么用?Java ExtendedJSONObject.parseJSONObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mozilla.gecko.sync.ExtendedJSONObject的用法示例。


在下文中一共展示了ExtendedJSONObject.parseJSONObject方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getObsoleteIds

import org.mozilla.gecko.sync.ExtendedJSONObject; //导入方法依赖的package包/类
protected ExtendedJSONObject getObsoleteIds() {
  String s = sharedPrefs.getString(HealthReportConstants.PREF_OBSOLETE_DOCUMENT_IDS_TO_DELETION_ATTEMPTS_REMAINING, null);
  if (s == null) {
    // It's possible we're migrating an old profile forward.
    String lastId = sharedPrefs.getString(HealthReportConstants.PREF_LAST_UPLOAD_DOCUMENT_ID, null);
    if (lastId == null) {
      return new ExtendedJSONObject();
    }
    ExtendedJSONObject ids = new ExtendedJSONObject();
    ids.put(lastId, HealthReportConstants.DELETION_ATTEMPTS_PER_OBSOLETE_DOCUMENT_ID);
    setObsoleteIds(ids);
    return ids;
  }
  try {
    return ExtendedJSONObject.parseJSONObject(s);
  } catch (Exception e) {
    Logger.warn(LOG_TAG, "Got exception getting obsolete ids.", e);
    return new ExtendedJSONObject();
  }
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:21,代码来源:ObsoleteDocumentTracker.java

示例2: jsonObjectBody

import org.mozilla.gecko.sync.ExtendedJSONObject; //导入方法依赖的package包/类
/**
 * Return the body as a <b>non-null</b> <code>ExtendedJSONObject</code>.
 *
 * @return A non-null <code>ExtendedJSONObject</code>.
 *
 * @throws IllegalStateException
 * @throws IOException
 * @throws ParseException
 * @throws NonObjectJSONException
 */
public ExtendedJSONObject jsonObjectBody() throws IllegalStateException, IOException,
                               ParseException, NonObjectJSONException {
  if (body != null) {
    // Do it from the cached String.
    return ExtendedJSONObject.parseJSONObject(body);
  }

  HttpEntity entity = this.response.getEntity();
  if (entity == null) {
    throw new IOException("no entity");
  }

  InputStream content = entity.getContent();
  try {
    Reader in = new BufferedReader(new InputStreamReader(content, "UTF-8"));
    return ExtendedJSONObject.parseJSONObject(in);
  } finally {
    content.close();
  }
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:31,代码来源:MozResponse.java

示例3: testPersist

import org.mozilla.gecko.sync.ExtendedJSONObject; //导入方法依赖的package包/类
public void testPersist() throws Exception {
  context.deleteFile(TEST_FILENAME);
  assertFileNotPresent(context, TEST_FILENAME);

  AccountPickler.pickle(context, TEST_FILENAME, params, true);

  final String s = Utils.readFile(context, TEST_FILENAME);
  assertNotNull(s);

  final ExtendedJSONObject o = ExtendedJSONObject.parseJSONObject(s);
  assertEquals(TEST_USERNAME,  o.getString(Constants.JSON_KEY_ACCOUNT));
  assertEquals(TEST_PASSWORD,  o.getString(Constants.JSON_KEY_PASSWORD));
  assertEquals(TEST_SERVER_URL, o.getString(Constants.JSON_KEY_SERVER));
  assertEquals(TEST_SYNCKEY,   o.getString(Constants.JSON_KEY_SYNCKEY));
  assertEquals(TEST_CLUSTER_URL, o.getString(Constants.JSON_KEY_CLUSTER));
  assertEquals(TEST_CLIENT_NAME, o.getString(Constants.JSON_KEY_CLIENT_NAME));
  assertEquals(TEST_CLIENT_GUID, o.getString(Constants.JSON_KEY_CLIENT_GUID));
  assertEquals(Boolean.valueOf(true), o.get(Constants.JSON_KEY_SYNC_AUTOMATICALLY));
  assertEquals(Long.valueOf(AccountPickler.VERSION), o.getLong(Constants.JSON_KEY_VERSION));
  assertTrue(o.containsKey(Constants.JSON_KEY_TIMESTAMP));
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:22,代码来源:TestAccountPickler.java

示例4: testMakeSyncAccountDeletedIntent

import org.mozilla.gecko.sync.ExtendedJSONObject; //导入方法依赖的package包/类
public void testMakeSyncAccountDeletedIntent() throws Throwable {
  syncAccount = new SyncAccountParameters(context, null,
      TEST_USERNAME, TEST_SYNCKEY, TEST_PASSWORD, TEST_SERVERURL, TEST_CLUSTERURL, null, null);
  try {
    account = SyncAccounts.createSyncAccount(syncAccount);
    assertNotNull(account);

    Intent intent = SyncAccounts.makeSyncAccountDeletedIntent(context, accountManager, account);
    assertEquals(SyncConstants.SYNC_ACCOUNT_DELETED_ACTION, intent.getAction());
    assertEquals(SyncConstants.SYNC_ACCOUNT_DELETED_INTENT_VERSION, intent.getLongExtra(Constants.JSON_KEY_VERSION, 0));
    assertEquals(TEST_USERNAME, intent.getStringExtra(Constants.JSON_KEY_ACCOUNT));
    assertTrue(Math.abs(intent.getLongExtra(Constants.JSON_KEY_TIMESTAMP, 0) - System.currentTimeMillis()) < 1000);

    String payload = intent.getStringExtra(Constants.JSON_KEY_PAYLOAD);
    assertNotNull(payload);

    SyncAccountParameters params = new SyncAccountParameters(context, accountManager, ExtendedJSONObject.parseJSONObject(payload));
    // Can't use assertParams because Sync key is deleted.
    assertNotNull(params);
    assertEquals(context, params.context);
    assertEquals(Utils.usernameFromAccount(TEST_USERNAME), params.username);
    assertEquals(TEST_PASSWORD, params.password);
    assertEquals(TEST_SERVERURL, params.serverURL);
    assertEquals("", params.syncKey);
  } finally {
    if (account != null) {
      deleteAccount(this, accountManager, account);
      account = null;
    }
  }
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:32,代码来源:TestSyncAccounts.java

示例5: RepositorySessionBundle

import org.mozilla.gecko.sync.ExtendedJSONObject; //导入方法依赖的package包/类
public RepositorySessionBundle(String jsonString) throws IOException, ParseException, NonObjectJSONException {
  object = ExtendedJSONObject.parseJSONObject(jsonString);
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:4,代码来源:RepositorySessionBundle.java

示例6: onHandleIntent

import org.mozilla.gecko.sync.ExtendedJSONObject; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
  // Intent can, in theory, be null. Bug 1025937.
  if (intent == null) {
    Logger.debug(LOG_TAG, "Short-circuiting on null intent.");
    return;
  }

  final Context context = this;

  long intentVersion = intent.getLongExtra(Constants.JSON_KEY_VERSION, 0);
  long expectedVersion = SyncConstants.SYNC_ACCOUNT_DELETED_INTENT_VERSION;
  if (intentVersion != expectedVersion) {
    Logger.warn(LOG_TAG, "Intent malformed: version " + intentVersion + " given but version " + expectedVersion + "expected. " +
        "Not cleaning up after deleted Account.");
    return;
  }

  String accountName = intent.getStringExtra(Constants.JSON_KEY_ACCOUNT); // Android Account name, not Sync encoded account name.
  if (accountName == null) {
    Logger.warn(LOG_TAG, "Intent malformed: no account name given. Not cleaning up after deleted Account.");
    return;
  }

  // Delete the Account pickle.
  Logger.info(LOG_TAG, "Sync account named " + accountName + " being removed; " +
      "deleting saved pickle file '" + Constants.ACCOUNT_PICKLE_FILENAME + "'.");
  deletePickle(context);

  SyncAccountParameters params;
  try {
    String payload = intent.getStringExtra(Constants.JSON_KEY_PAYLOAD);
    if (payload == null) {
      Logger.warn(LOG_TAG, "Intent malformed: no payload given. Not deleting client record.");
      return;
    }
    ExtendedJSONObject o = ExtendedJSONObject.parseJSONObject(payload);
    params = new SyncAccountParameters(context, AccountManager.get(context), o);
  } catch (Exception e) {
    Logger.warn(LOG_TAG, "Got exception fetching account parameters from intent data; not deleting client record.");
    return;
  }

  // Bug 770785: delete the Account's client record.
  Logger.info(LOG_TAG, "Account named " + accountName + " being removed; " +
      "deleting client record from server.");
  deleteClientRecord(context, accountName, params.password, params.serverURL);

  // Delete client database and non-local tabs.
  Logger.info(LOG_TAG, "Deleting the entire clients database and non-local tabs");
  FennecTabsRepository.deleteNonLocalClientsAndTabs(context);
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:53,代码来源:SyncAccountDeletedService.java


注:本文中的org.mozilla.gecko.sync.ExtendedJSONObject.parseJSONObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。