本文整理汇总了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}");
}
示例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);
}
}
示例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);
}
示例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);
}
示例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() + "'.");
}
}