List of usage examples for org.apache.commons.lang ObjectUtils toString
public static String toString(Object obj)
Gets the toString
of an Object
returning an empty string ("") if null
input.
ObjectUtils.toString(null) = "" ObjectUtils.toString("") = "" ObjectUtils.toString("bat") = "bat" ObjectUtils.toString(Boolean.TRUE) = "true"
From source file:org.sipfoundry.sipxconfig.components.ExtraOptionModelDecorator.java
public String getValue(int index) { if (index == 0) { return ObjectUtils.toString(m_extraOption); }/* w w w.j a va2 s. c om*/ return m_model.getValue(index - 1); }
From source file:org.sipfoundry.sipxconfig.components.ExtraOptionModelDecorator.java
public Object translateValue(String value) { if (ObjectUtils.equals(value, ObjectUtils.toString(m_extraOption))) { return m_extraOption; }// ww w .jav a 2 s . c om return m_model.translateValue(value); }
From source file:org.sonar.api.resources.DuplicatedSourceException.java
public DuplicatedSourceException(Resource<?> resource) { super("Duplicate source for resource: " + ObjectUtils.toString(resource)); }
From source file:org.sonar.ide.eclipse.core.internal.jobs.AnalyseProjectJob.java
@VisibleForTesting public void createMarkersFromReportOutputBefore4_2(final IProgressMonitor monitor, File outputFile) { FileReader fileReader = null; try {// w ww. j a v a 2s .co m fileReader = new FileReader(outputFile); Object obj = JSONValue.parse(fileReader); JSONObject sonarResult = (JSONObject) obj; // Start by resolving all components in a cache Map<String, IResource> resourcesByKey = Maps.newHashMap(); final JSONArray components = (JSONArray) sonarResult.get("components"); for (Object component : components) { String key = ObjectUtils.toString(((JSONObject) component).get("key")); IResource resource = ResourceUtils.findResource(sonarProject, key); if (resource != null) { resourcesByKey.put(key, resource); if (incremental) { MarkerUtils.deleteIssuesMarkers(resource); } MarkerUtils.markResourceAsLocallyAnalysed(resource); } } // Now read all rules name in a cache Map<String, String> ruleByKey = readRules(sonarResult); // Now read all users name in a cache Map<String, String> userNameByLogin = readUserNameByLogin(sonarResult); // Now iterate over all issues and create markers MarkerUtils.createMarkersForJSONIssues(resourcesByKey, ruleByKey, userNameByLogin, (JSONArray) sonarResult.get("issues")); } catch (Exception e) { LOG.error(e.getMessage(), e); throw new SonarEclipseException("Unable to create markers", e); } finally { IOUtils.closeQuietly(fileReader); } }
From source file:org.sonar.ide.eclipse.core.internal.jobs.AnalyseProjectJob.java
@VisibleForTesting public void createMarkersFromReportOutput(final IProgressMonitor monitor, File outputFile) { FileReader fileReader = null; try {//from w w w.j ava 2 s .c o m fileReader = new FileReader(outputFile); Object obj = JSONValue.parse(fileReader); JSONObject sonarResult = (JSONObject) obj; // Start by resolving all components in a cache Map<String, IResource> resourcesByKey = Maps.newHashMap(); final JSONArray components = (JSONArray) sonarResult.get("components"); for (Object component : components) { String key = ObjectUtils.toString(((JSONObject) component).get("key")); String path = ObjectUtils.toString(((JSONObject) component).get("path")); String moduleKey = ObjectUtils.toString(((JSONObject) component).get("moduleKey")); String status = ObjectUtils.toString(((JSONObject) component).get("status")); IResource resource = ResourceUtils.findResource(sonarProject, key, moduleKey, path); if (resource != null) { resourcesByKey.put(key, resource); if (incremental // Status is blank for modules && StringUtils.isNotBlank(status) && !"SAME".equals(status)) { MarkerUtils.deleteIssuesMarkers(resource); } MarkerUtils.markResourceAsLocallyAnalysed(resource); } } // Now read all rules name in a cache Map<String, String> ruleByKey = readRules(sonarResult); // Now read all users name in a cache Map<String, String> userNameByLogin = readUserNameByLogin(sonarResult); // Now iterate over all issues and create markers MarkerUtils.createMarkersForJSONIssues(resourcesByKey, ruleByKey, userNameByLogin, (JSONArray) sonarResult.get("issues")); } catch (Exception e) { LOG.error(e.getMessage(), e); throw new SonarEclipseException("Unable to create markers", e); } finally { IOUtils.closeQuietly(fileReader); } }
From source file:org.sonar.ide.eclipse.core.internal.jobs.AnalyseProjectJob.java
private Map<String, String> readRules(JSONObject sonarResult) { Map<String, String> ruleByKey = Maps.newHashMap(); final JSONArray rules = (JSONArray) sonarResult.get("rules"); for (Object rule : rules) { String key = ObjectUtils.toString(((JSONObject) rule).get("key")); String name = ObjectUtils.toString(((JSONObject) rule).get("name")); ruleByKey.put(key, name);/*from w w w.j a v a 2 s. c o m*/ } return ruleByKey; }
From source file:org.sonar.ide.eclipse.core.internal.jobs.AnalyseProjectJob.java
private Map<String, String> readUserNameByLogin(JSONObject sonarResult) { Map<String, String> userNameByLogin = Maps.newHashMap(); final JSONArray users = (JSONArray) sonarResult.get("users"); if (users != null) { for (Object user : users) { String login = ObjectUtils.toString(((JSONObject) user).get("login")); String name = ObjectUtils.toString(((JSONObject) user).get("name")); userNameByLogin.put(login, name); }/*w w w .j av a 2s .com*/ } return userNameByLogin; }
From source file:org.sonar.ide.eclipse.core.internal.markers.MarkerUtils.java
public static void createMarkersForJSONIssues(Map<String, IResource> resourcesByKey, Map<String, String> ruleByKey, Map<String, String> userNameByLogin, JSONArray issues) { for (Object issueObj : issues) { JSONObject jsonIssue = (JSONObject) issueObj; String componentKey = ObjectUtils.toString(jsonIssue.get("component")); if (resourcesByKey.containsKey(componentKey)) { boolean isNew = Boolean.TRUE.equals(jsonIssue.get("isNew")); //$NON-NLS-1$ try { SonarMarker.create(resourcesByKey.get(componentKey), isNew, new SonarIssueFromJsonReport(jsonIssue, ruleByKey, userNameByLogin)); } catch (CoreException e) { LOG.error(e.getMessage(), e); }// w w w .j ava2s . c o m } } }
From source file:org.sonar.ide.eclipse.ui.internal.views.IssueEditorWebView.java
@Override protected void open(IMarker marker) { String issueId;// w w w .j a v a 2s .co m try { if (SonarCorePlugin.NEW_ISSUE_MARKER_ID.equals(marker.getType())) { showMessage("It is not possible to edit a new issue."); return; } issueId = ObjectUtils.toString(marker.getAttribute(MarkerUtils.SONAR_MARKER_ISSUE_ID_ATTR)); } catch (CoreException e) { throw new IllegalStateException(e); } resource = marker.getResource(); SonarProject sonarProject = SonarProject.getInstance(marker.getResource().getProject()); String url = new SonarUrls().issueUrl(issueId, sonarProject.getUrl()); super.open(sonarProject, url); }
From source file:org.sonar.ide.intellij.inspection.SonarIssueFromJsonReport.java
@Override public String key() { return ObjectUtils.toString(jsonIssue.get("key")); }