本文整理了Java中com.couchbase.client.java.document.json.JsonObject.getInt()
方法的一些代码示例,展示了JsonObject.getInt()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonObject.getInt()
方法的具体详情如下:
包路径:com.couchbase.client.java.document.json.JsonObject
类名称:JsonObject
方法名:getInt
[英]Retrieves the value from the field name and casts it to Integer. Note that if value was stored as another numerical type, some truncation or rounding may occur.
[中]从字段名中检索值并将其强制转换为整数。请注意,若值存储为另一个数字类型,则可能会发生某些截断或舍入。
代码示例来源:origin: com.couchbase.client/java-client
@Override
public int replicaCount() {
return raw.getInt("replicaNumber");
}
代码示例来源:origin: com.couchbase.client/java-client
private static boolean shouldRetry(final JsonObject errorJson) {
if (errorJson == null) return false;
Integer code = errorJson.getInt(ERROR_FIELD_CODE);
// The following error codes have been identified as being
// retryable.
switch (code) {
case 21002:
case 23000:
case 23003:
case 23007:
return true;
default:
return false;
}
}
代码示例来源:origin: com.couchbase.client/java-client
/**
* Tests a N1QL error JSON for conditions warranting a prepared statement retry.
*/
private static boolean shouldRetry(JsonObject errorJson) {
if (errorJson == null) return false;
Integer code = errorJson.getInt(ERROR_FIELD_CODE);
String msg = errorJson.getString(ERROR_FIELD_MSG);
if (code == null || msg == null) return false;
if (code == 4050 || code == 4070 ||
(code == 5000 && msg.contains(ERROR_5000_SPECIFIC_MESSAGE))) {
return true;
}
return false;
}
代码示例来源:origin: com.couchbase.client/java-client
public N1qlMetrics(JsonObject rawMetrics) {
this.rawMetrics = rawMetrics;
if (rawMetrics.getString("elapsedTime") == null) {
this.elapsedTime = NO_TIME;
} else {
this.elapsedTime = rawMetrics.getString("elapsedTime");
}
if (rawMetrics.getString("executionTime") == null) {
this.executionTime = NO_TIME;
} else {
this.executionTime = rawMetrics.getString("executionTime");
}
Integer resultCount = rawMetrics.getInt("resultCount");
this.resultCount = resultCount == null ? 0 : resultCount;
Integer errorCount = rawMetrics.getInt("errorCount");
this.errorCount = errorCount == null ? 0 : errorCount;
Integer warningCount = rawMetrics.getInt("warningCount");
this.warningCount = warningCount == null ? 0 : warningCount;
Integer mutationCount = rawMetrics.getInt("mutationCount");
this.mutationCount = mutationCount == null ? 0 : mutationCount;
Integer sortCount = rawMetrics.getInt("sortCount");
this.sortCount = sortCount == null ? 0 : sortCount;
Long resultSize = rawMetrics.getLong("resultSize");
this.resultSize = resultSize == null ? 0L : resultSize;
}
代码示例来源:origin: lordofthejars/nosql-unit
public static Map<String, Document> getDocuments(final InputStream dataScript) {
try {
final JsonObject jsonObject = JsonObject.fromJson(IOUtils.readFullStream(dataScript));
final JsonArray data = jsonObject.getArray("data");
return StreamSupport.stream(data.spliterator(), false)
.map(o -> (JsonObject) o)
.collect(Collectors.toMap(o -> o.getString("key"),
o -> new Document(o.getObject("document"), o.getInt("expirationSecs"))));
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
代码示例来源:origin: com.couchbase.client/java-client
@Override
public AnalyticsDeferredResultHandle importAnalyticsDeferredResultHandle(byte[] b) {
try {
JsonObject jsonObj = CouchbaseAsyncBucket.JSON_OBJECT_TRANSCODER.stringToJsonObject(new String(b, StandardCharsets.UTF_8));
if (jsonObj.getInt("v") != 1) {
throw new IllegalArgumentException("Version is not supported");
}
return new DefaultAnalyticsDeferredResultHandle(new DefaultAsyncAnalyticsDeferredResultHandle(jsonObj.getString("uri"), this.environment(), this.core(), this.name(), username, password, environment.analyticsTimeout(), TimeUnit.MILLISECONDS));
} catch (Exception e) {
throw new IllegalStateException("Cannot import", e);
}
}
代码示例来源:origin: simonbasle/practicalRx
public static User fromJsonObject(JsonObject jso){
return new User(jso.getInt("id"), jso.getString("nickname"), jso.getString("displayName"), jso.getString("bio"),
jso.getString("avatarId"));
}
代码示例来源:origin: com.couchbase.client/java-client
Integer trows = jsonInfo.getInt("total_rows");
if (trows != null) {
totalRows = trows;
内容来源于网络,如有侵权,请联系作者删除!