Java Code Examples for net.sf.json.JSONObject#getLong()

The following examples show how to use net.sf.json.JSONObject#getLong() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: YarnJobCrawlerTask.java    From Hue-Ctrip-DI with MIT License 6 votes vote down vote up
private List<YarnJobsDo> getJobList(long maxStartTime)
		throws HttpException, IOException {
	List<YarnJobsDo> jobsList = new ArrayList<YarnJobsDo>();

	JSONObject json = getJson();
	JSONObject jobs = (JSONObject) json.get("jobs");
	JSONArray jobArray = (JSONArray) jobs.get("job");
	@SuppressWarnings("unchecked")
	ListIterator<JSONObject> iterator = jobArray.listIterator();
	while (iterator.hasNext()) {
		JSONObject jobObject = iterator.next();
		long startTime = jobObject.getLong("startTime");
		if (startTime > maxStartTime) {
			YarnJobsDo yarnJobsDo = toYarnJobsDo(jobObject);
			jobsList.add(yarnJobsDo);
		}
	}
	return jobsList;
}
 
Example 2
Source File: DefaultPointer.java    From logsniffer with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static DefaultPointer fromJSON(final String data) {
	JSONObject json = JSONObject.fromObject(data);
	if (json.has("o") && json.has("s")) {
		return new DefaultPointer(json.getLong("o"), json.getLong("s"));
	} else {
		return null;
	}
}
 
Example 3
Source File: CompoundLogPointer.java    From logsniffer with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static PointerPart fromJson(final JSONObject jsonObject, final LogInstanceResolver lir)
		throws IOException {
	if (jsonObject.has("s") && jsonObject.has("p") && jsonObject.has("o")) {
		final long ls = jsonObject.getLong("s");
		final int ph = jsonObject.getInt("p");
		LogPointer offset = null;
		final LogInstance li = lir.resolveForPathHash(ls, ph);
		if (li != null) {
			offset = li.getLogAccess().getFromJSON(jsonObject.getString("o"));
		}
		return new PointerPart(ls, ph, offset);
	}
	return null;
}
 
Example 4
Source File: UberallsClient.java    From phabricator-jenkins-plugin with MIT License 5 votes vote down vote up
public CodeCoverageMetrics getParentCoverage(String sha) {
    if (sha == null) {
        return null;
    }
    try {
        String coverageJSON = getCoverage(sha);
        JsonSlurper jsonParser = new JsonSlurper();
        JSON responseJSON = jsonParser.parseText(coverageJSON);
        if (responseJSON instanceof JSONNull) {
            return null;
        }
        JSONObject coverage = (JSONObject) responseJSON;

        return new CodeCoverageMetrics(
                ((Double) coverage.getDouble(PACKAGE_COVERAGE_KEY)).floatValue(),
                ((Double) coverage.getDouble(FILES_COVERAGE_KEY)).floatValue(),
                ((Double) coverage.getDouble(CLASSES_COVERAGE_KEY)).floatValue(),
                ((Double) coverage.getDouble(METHOD_COVERAGE_KEY)).floatValue(),
                ((Double) coverage.getDouble(LINE_COVERAGE_KEY)).floatValue(),
                ((Double) coverage.getDouble(CONDITIONAL_COVERAGE_KEY)).floatValue(),
                (coverage.getLong(LINES_COVERED_KEY)),
                (coverage.getLong(LINES_TESTED_KEY)));
    } catch (Exception e) {
        e.printStackTrace(logger.getStream());
    }

    return null;
}