本文整理了Java中org.codehaus.jettison.json.JSONObject.optInt()
方法的一些代码示例,展示了JSONObject.optInt()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONObject.optInt()
方法的具体详情如下:
包路径:org.codehaus.jettison.json.JSONObject
类名称:JSONObject
方法名:optInt
[英]Get an optional int value associated with a key, or zero if there is no such key or if the value is not a number. If the value is a string, an attempt will be made to evaluate it as a number.
[中]获取与键关联的可选int值,如果没有此类键或该值不是数字,则获取零。如果该值是字符串,将尝试将其作为数字计算。
代码示例来源:origin: org.codehaus.jettison/jettison
/**
* Get an optional int value associated with a key,
* or zero if there is no such key or if the value is not a number.
* If the value is a string, an attempt will be made to evaluate it as
* a number.
*
* @param key A key string.
* @return An object which is the value.
*/
public int optInt(String key) {
return optInt(key, 0);
}
代码示例来源:origin: org.codehaus.jettison/com.springsource.org.codehaus.jettison
/**
* Get an optional int value associated with a key,
* or zero if there is no such key or if the value is not a number.
* If the value is a string, an attempt will be made to evaluate it as
* a number.
*
* @param key A key string.
* @return An object which is the value.
*/
public int optInt(String key) {
return optInt(key, 0);
}
代码示例来源:origin: org.apache.tez/tez-api
@VisibleForTesting
protected Map<String, VertexTaskStats> parseTaskStatsForVertexes()
throws TezException, JSONException {
if (vertexTaskStatsCache == null) {
final String url = String.format("%s/%s?primaryFilter=%s:%s&fields=%s", baseUri,
ATSConstants.TEZ_VERTEX_ID, ATSConstants.TEZ_DAG_ID, dagId, FILTER_BY_FIELDS);
final JSONObject jsonRoot = getJsonRootEntity(url);
final JSONArray vertexNodes = jsonRoot.optJSONArray(ATSConstants.ENTITIES);
if (vertexNodes != null) {
final int numVertexNodes = vertexNodes.length();
Map<String, VertexTaskStats> vertexTaskStatsMap =
new HashMap<String, VertexTaskStats>(numVertexNodes);
for (int i = 0; i < numVertexNodes; i++) {
final JSONObject vertexNode = vertexNodes.getJSONObject(i);
final JSONObject otherInfoNode = vertexNode.getJSONObject(ATSConstants.OTHER_INFO);
final String vertexName = otherInfoNode.getString(ATSConstants.VERTEX_NAME);
final VertexTaskStats vertexTaskStats =
new VertexTaskStats(otherInfoNode.optInt(ATSConstants.NUM_TASKS),
otherInfoNode.optInt(ATSConstants.NUM_COMPLETED_TASKS),
otherInfoNode.optInt(ATSConstants.NUM_SUCCEEDED_TASKS),
otherInfoNode.optInt(ATSConstants.NUM_KILLED_TASKS),
otherInfoNode.optInt(ATSConstants.NUM_FAILED_TASKS));
vertexTaskStatsMap.put(vertexName, vertexTaskStats);
}
vertexTaskStatsCache = vertexTaskStatsMap;
}
}
return vertexTaskStatsCache;
}
代码示例来源:origin: org.apache.tez/tez-api
.addAllDiagnostics(Collections.singleton(diagnostics));
int numRunningTasks = otherInfoNode.optInt(ATSConstants.NUM_TASKS) -
otherInfoNode.optInt(ATSConstants.NUM_COMPLETED_TASKS);
ProgressProto.Builder progressBuilder = ProgressProto.newBuilder();
progressBuilder.setTotalTaskCount(otherInfoNode.optInt(ATSConstants.NUM_TASKS));
progressBuilder.setRunningTaskCount(numRunningTasks);
progressBuilder.setSucceededTaskCount(otherInfoNode.optInt(ATSConstants.NUM_SUCCEEDED_TASKS));
progressBuilder.setKilledTaskCount(otherInfoNode.optInt(ATSConstants.NUM_KILLED_TASKS));
progressBuilder.setFailedTaskCount(otherInfoNode.optInt(ATSConstants.NUM_FAILED_TASKS));
vertexStatusBuilder.setProgress(progressBuilder);
代码示例来源:origin: com.atlassian.jira/jira-rest-java-client
@Override
public LoginInfo parse(JSONObject json) throws JSONException {
final int failedLoginCount = json.optInt("failedLoginCount");
final int loginCount = json.getInt("loginCount");
final DateTime lastFailedLoginTime = JsonParseUtil.parseOptionalDateTime(json, "lastFailedLoginTime");
final DateTime previousLoginTime = JsonParseUtil.parseOptionalDateTime(json, "previousLoginTime");
return new LoginInfo(failedLoginCount, loginCount, lastFailedLoginTime, previousLoginTime);
}
}
代码示例来源:origin: com.atlassian.jira/jira-rest-java-client-core
@Override
public LoginInfo parse(JSONObject json) throws JSONException {
final int failedLoginCount = json.optInt("failedLoginCount");
final int loginCount = json.getInt("loginCount");
final DateTime lastFailedLoginTime = JsonParseUtil.parseOptionalDateTime(json, "lastFailedLoginTime");
final DateTime previousLoginTime = JsonParseUtil.parseOptionalDateTime(json, "previousLoginTime");
return new LoginInfo(failedLoginCount, loginCount, lastFailedLoginTime, previousLoginTime);
}
}
代码示例来源:origin: com.atlassian.jira/jira-rest-java-client-p3
@Override
public LoginInfo parse(JSONObject json) throws JSONException {
final int failedLoginCount = json.optInt("failedLoginCount");
final int loginCount = json.getInt("loginCount");
final DateTime lastFailedLoginTime = JsonParseUtil.parseOptionalDateTime(json, "lastFailedLoginTime");
final DateTime previousLoginTime = JsonParseUtil.parseOptionalDateTime(json, "previousLoginTime");
return new LoginInfo(failedLoginCount, loginCount, lastFailedLoginTime, previousLoginTime);
}
}
代码示例来源:origin: org.openengsb.wrapped/jira-rest-java-client-core
@Override
public LoginInfo parse(JSONObject json) throws JSONException {
final int failedLoginCount = json.optInt("failedLoginCount");
final int loginCount = json.getInt("loginCount");
final DateTime lastFailedLoginTime = JsonParseUtil.parseOptionalDateTime(json, "lastFailedLoginTime");
final DateTime previousLoginTime = JsonParseUtil.parseOptionalDateTime(json, "previousLoginTime");
return new LoginInfo(failedLoginCount, loginCount, lastFailedLoginTime, previousLoginTime);
}
}
代码示例来源:origin: apache/stanbol
public static enum TYPE_STRICT {any,all,should};
代码示例来源:origin: org.apache.tez/tez-history-parser
numTasks = otherInfoNode.optInt(Constants.NUM_TASKS);
failedTasks = otherInfoNode.optInt(Constants.NUM_FAILED_TASKS);
succeededTasks =
otherInfoNode.optInt(Constants.NUM_SUCCEEDED_TASKS);
completedTasks =
otherInfoNode.optInt(Constants.NUM_COMPLETED_TASKS);
killedTasks = otherInfoNode.optInt(Constants.NUM_KILLED_TASKS);
numFailedTaskAttempts =
otherInfoNode.optInt(Constants.NUM_FAILED_TASKS_ATTEMPTS);
vertexName = StringInterner.weakIntern(otherInfoNode.optString(Constants.VERTEX_NAME));
processorClass = StringInterner.weakIntern(otherInfoNode.optString(Constants.PROCESSOR_CLASS_NAME));
代码示例来源:origin: org.apache.tez/tez-history-parser
private void parseDAGPlan(JSONObject dagPlan) throws JSONException {
int version = dagPlan.optInt(Constants.VERSION, 1);
parseEdges(dagPlan.optJSONArray(Constants.EDGES));
JSONArray verticesInfo = dagPlan.optJSONArray(Constants.VERTICES);
parseBasicVertexInfo(verticesInfo);
if (version > 1) {
parseDAGContext(dagPlan.optJSONObject(Constants.DAG_CONTEXT));
}
}
代码示例来源:origin: org.apache.tez/tez-history-parser
failedTasks = otherInfoNode.optInt(Constants.NUM_FAILED_TASKS);
JSONObject dagPlan = otherInfoNode.optJSONObject(Constants.DAG_PLAN);
name = StringInterner.weakIntern((dagPlan != null) ? (dagPlan.optString(Constants.DAG_NAME)) : null);
代码示例来源:origin: org.apache.tez/tez-history-parser
Integer edgeId = edge.optInt(Constants.EDGE_ID);
String inputVertexName =
edge.optString(Constants.INPUT_VERTEX_NAME);
代码示例来源:origin: com.atlassian.jira/jira-rest-java-client-p3
@Override
public Worklog parse(JSONObject json) throws JSONException {
final URI self = JsonParseUtil.getSelfUri(json);
final BasicUser author = JsonParseUtil.parseBasicUser(json.optJSONObject("author"));
final BasicUser updateAuthor = JsonParseUtil.parseBasicUser(json.optJSONObject("updateAuthor"));
final String comment = json.optString("comment");
final DateTime creationDate = JsonParseUtil.parseDateTime(json, "created");
final DateTime updateDate = JsonParseUtil.parseDateTime(json, "updated");
final DateTime startDate = JsonParseUtil.parseDateTime(json, "started");
// timeSpentSeconds is not required due to bug: JRADEV-8825 (fixed in 5.0, Iteration 14).
final int secondsSpent = json.optInt("timeSpentSeconds", 0);
final Visibility visibility = new VisibilityJsonParser().parseVisibility(json);
return new Worklog(self, issue, author, updateAuthor, comment, creationDate, updateDate, startDate, secondsSpent / 60, visibility);
}
}
代码示例来源:origin: com.atlassian.jira/jira-rest-java-client
@Override
public Worklog parse(JSONObject json) throws JSONException {
final URI self = JsonParseUtil.getSelfUri(json);
final BasicUser author = JsonParseUtil.parseBasicUser(json.optJSONObject("author"));
final BasicUser updateAuthor = JsonParseUtil.parseBasicUser(json.optJSONObject("updateAuthor"));
final String comment = json.optString("comment");
final DateTime creationDate = JsonParseUtil.parseDateTime(json, "created");
final DateTime updateDate = JsonParseUtil.parseDateTime(json, "updated");
final DateTime startDate = JsonParseUtil.parseDateTime(json, "started");
// timeSpentSeconds is not required due to bug: JRADEV-8825 (fixed in 5.0, Iteration 14).
final int secondsSpent = json.optInt("timeSpentSeconds", 0);
final Visibility visibility = new VisibilityJsonParser().parseVisibility(json);
return new Worklog(self, issue, author, updateAuthor, comment, creationDate, updateDate, startDate, secondsSpent / 60, visibility);
}
}
代码示例来源:origin: com.atlassian.jira/jira-rest-java-client-core
@Override
public Worklog parse(JSONObject json) throws JSONException {
final URI self = JsonParseUtil.getSelfUri(json);
final BasicUser author = JsonParseUtil.parseBasicUser(json.optJSONObject("author"));
final BasicUser updateAuthor = JsonParseUtil.parseBasicUser(json.optJSONObject("updateAuthor"));
// comment is optional due to JRJC-49: JIRA can return worklog without comment
final String comment = json.optString("comment");
final DateTime creationDate = JsonParseUtil.parseDateTime(json, "created");
final DateTime updateDate = JsonParseUtil.parseDateTime(json, "updated");
final DateTime startDate = JsonParseUtil.parseDateTime(json, "started");
// timeSpentSeconds is not required due to bug: JRADEV-8825 (fixed in 5.0, Iteration 14).
final int secondsSpent = json.optInt("timeSpentSeconds", 0);
final Visibility visibility = new VisibilityJsonParser().parseVisibility(json);
return new Worklog(self, issue, author, updateAuthor, comment, creationDate, updateDate, startDate,
secondsSpent / 60, visibility);
}
}
代码示例来源:origin: org.openengsb.wrapped/jira-rest-java-client-core
@Override
public Worklog parse(JSONObject json) throws JSONException {
final URI self = JsonParseUtil.getSelfUri(json);
final BasicUser author = JsonParseUtil.parseBasicUser(json.optJSONObject("author"));
final BasicUser updateAuthor = JsonParseUtil.parseBasicUser(json.optJSONObject("updateAuthor"));
// comment is optional due to JRJC-49: JIRA can return worklog without comment
final String comment = json.optString("comment");
final DateTime creationDate = JsonParseUtil.parseDateTime(json, "created");
final DateTime updateDate = JsonParseUtil.parseDateTime(json, "updated");
final DateTime startDate = JsonParseUtil.parseDateTime(json, "started");
// timeSpentSeconds is not required due to bug: JRADEV-8825 (fixed in 5.0, Iteration 14).
final int secondsSpent = json.optInt("timeSpentSeconds", 0);
final Visibility visibility = new VisibilityJsonParser().parseVisibility(json);
return new Worklog(self, issue, author, updateAuthor, comment, creationDate, updateDate, startDate,
secondsSpent / 60, visibility);
}
}
内容来源于网络,如有侵权,请联系作者删除!