當前位置: 首頁>>代碼示例>>Java>>正文


Java ExtendedJSONObject.getLong方法代碼示例

本文整理匯總了Java中org.mozilla.gecko.sync.ExtendedJSONObject.getLong方法的典型用法代碼示例。如果您正苦於以下問題:Java ExtendedJSONObject.getLong方法的具體用法?Java ExtendedJSONObject.getLong怎麽用?Java ExtendedJSONObject.getLong使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.mozilla.gecko.sync.ExtendedJSONObject的用法示例。


在下文中一共展示了ExtendedJSONObject.getLong方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fromJSONObject

import org.mozilla.gecko.sync.ExtendedJSONObject; //導入方法依賴的package包/類
public static State fromJSONObject(StateLabel stateLabel, ExtendedJSONObject o) throws InvalidKeySpecException, NoSuchAlgorithmException, NonObjectJSONException {
  Long version = o.getLong("version");
  if (version == null) {
    throw new IllegalStateException("version must not be null");
  }

  final int v = version.intValue();
  if (v == 3) {
    // The most common case is the most recent version.
    return fromJSONObjectV3(stateLabel, o);
  }
  if (v == 2) {
    return fromJSONObjectV2(stateLabel, o);
  }
  if (v == 1) {
    final State state = fromJSONObjectV1(stateLabel, o);
    return migrateV1toV2(stateLabel, state);
  }
  throw new IllegalStateException("version must be in {1, 2}");
}
 
開發者ID:mozilla-mobile,項目名稱:FirefoxData-android,代碼行數:21,代碼來源:StateFactory.java

示例2: decrementObsoleteId

import org.mozilla.gecko.sync.ExtendedJSONObject; //導入方法依賴的package包/類
protected void decrementObsoleteId(ExtendedJSONObject ids, String id) {
  if (!ids.containsKey(id)) {
    return;
  }
  try {
    Long attempts = ids.getLong(id);
    if (attempts == null || --attempts < 1) {
      ids.remove(id);
    } else {
      ids.put(id, attempts);
    }
  } catch (ClassCastException e) {
    ids.remove(id);
    Logger.info(LOG_TAG, "Got exception decrementing obsolete ids counter.", e);
  }
}
 
開發者ID:jrconlin,項目名稱:mc_backup,代碼行數:17,代碼來源:ObsoleteDocumentTracker.java

示例3: ServerMetadata

import org.mozilla.gecko.sync.ExtendedJSONObject; //導入方法依賴的package包/類
/**
 * From server record.
 */
public ServerMetadata(ExtendedJSONObject obj) {
  this(obj.getString("id"), obj.containsKey("last_modified") ? obj.getLong("last_modified") : -1L);
}
 
開發者ID:jrconlin,項目名稱:mc_backup,代碼行數:7,代碼來源:ReadingListRecord.java

示例4: fromCursorRow

import org.mozilla.gecko.sync.ExtendedJSONObject; //導入方法依賴的package包/類
/**
 * TODO: optionally produce a partial record by examining SYNC_CHANGE_FLAGS/SYNC_STATUS.
 */
public ClientReadingListRecord fromCursorRow() {
  final ExtendedJSONObject object = new ExtendedJSONObject();
  for (int i = 0; i < this.fields.length; ++i) {
    final String field = fields[i];
    if (field == null) {
      continue;
    }
    final int column = this.columns[i];
    if (Versions.feature11Plus) {
      fillHoneycomb(object, this.cursor, field, column);
    } else {
      fillGingerbread(object, this.cursor, field, column);
    }
  }

  // Apply cross-field constraints.
  if (object.containsKey("unread") && object.getBoolean("unread")) {
    object.remove("marked_read_by");
    object.remove("marked_read_on");
  }

  // Construct server metadata and client metadata from the object.
  final long serverLastModified = object.getLong("last_modified", -1L);
  final String guid = object.containsKey("guid") ? object.getString("guid") : null;
  final ServerMetadata sm = new ServerMetadata(guid, serverLastModified);

  final long clientLastModified = object.getLong("client_last_modified", -1L);

  // This has already been translated...
  final boolean isArchived = object.getBoolean("archived");

  // ... but this is a client-only field, so it needs to be converted.
  final boolean isDeleted = object.getLong("is_deleted", 0L) == 1L;
  final long localID = object.getLong("_id", -1L);
  final ClientMetadata cm = new ClientMetadata(localID, clientLastModified, isDeleted, isArchived);

  // Remove things that aren't part of the spec.
  object.remove("last_modified");
  object.remove("guid");
  object.remove("client_last_modified");
  object.remove("is_deleted");

  // We never want to upload stored_on; for new items it'll be null (and cause Bug 1153358),
  // and for existing items it should never change.
  object.remove("stored_on");

  object.remove(ReadingListItems.CONTENT_STATUS);
  object.remove(ReadingListItems.SYNC_STATUS);
  object.remove(ReadingListItems.SYNC_CHANGE_FLAGS);
  object.remove(ReadingListItems.CLIENT_LAST_MODIFIED);

  return new ClientReadingListRecord(sm, cm, object);
}
 
開發者ID:jrconlin,項目名稱:mc_backup,代碼行數:57,代碼來源:ReadingListClientRecordFactory.java

示例5: throwIfParametersAreBad

import org.mozilla.gecko.sync.ExtendedJSONObject; //導入方法依賴的package包/類
/**
 * Expect object like:
 * "passwordStretching": {
 *   "type": "PBKDF2/scrypt/PBKDF2/v1",
 *   "PBKDF2_rounds_1": 20000,
 *   "scrypt_N": 65536,
 *   "scrypt_r": 8,
 *   "scrypt_p": 1,
 *   "PBKDF2_rounds_2": 20000,
 *   "salt": "996bc6b1aa63cd69856a2ec81cbf19d5c8a604713362df9ee15c2bf07128efab"
 * }
 * @param params to verify.
 * @throws FxAccountClientMalformedAuthException
 */
protected void throwIfParametersAreBad(ExtendedJSONObject params) throws FxAccountClientMalformedAuthException {
  if (params == null ||
      params.size() != 7 ||
      params.getString("salt") == null ||
      !("PBKDF2/scrypt/PBKDF2/v1".equals(params.getString("type"))) ||
      20000 != params.getLong("PBKDF2_rounds_1") ||
      65536 != params.getLong("scrypt_N") ||
      8 != params.getLong("scrypt_r") ||
      1 != params.getLong("scrypt_p") ||
      20000 != params.getLong("PBKDF2_rounds_2")) {
    throw new FxAccountClientMalformedAuthException("malformed passwordStretching parameters: '" + params.toJSONString() + "'.");
  }
}
 
開發者ID:jrconlin,項目名稱:mc_backup,代碼行數:28,代碼來源:FxAccount10AuthDelegate.java


注:本文中的org.mozilla.gecko.sync.ExtendedJSONObject.getLong方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。