Java tutorial
/** * SonarView - A SonarQube/Eclipse integration plugin * Copyright (c) 2016 Leonardo Pessoa * http://lmpessoa.com * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.lmpessoa.sonarview.core; import org.json.JSONObject; public class Issue { private String projectId; private String sourceFile; private String ruleId; private Severity severity; private String message; private Integer startLine; private Integer endLine; private Integer startOffset; private Integer endOffset; private String author; private String debt; public Issue(JSONObject source) { author = source.getString("author"); message = source.getString("message"); ruleId = source.getString("rule"); severity = Severity.valueOf(source.getString("severity")); String[] subProject = source.getString("subProject").split(":", 2); projectId = subProject[subProject.length - 1]; sourceFile = source.getString("component").substring(source.getString("subProject").length() + 1); JSONObject range = source.optJSONObject("textRange"); if (range != null) { startLine = range.getInt("startLine"); endLine = range.getInt("endLine"); startOffset = range.getInt("startOffset"); endOffset = range.getInt("endOffset"); } debt = source.optString("debt"); } public String getProjectId() { return projectId; } public String getSourceFile() { return sourceFile; } public String getRuleId() { return ruleId; } public Severity getSeverity() { return severity; } public String getMessage() { return message; } public Integer getStartLine() { return startLine; } public Integer getEndLine() { return endLine; } public Integer getStartOffset() { return startOffset; } public Integer getEndOffset() { return endOffset; } public String getAuthor() { return author; } public String getTechnicalDebt() { return debt; } }