From 5c05c7d812a97fd6ab07b5ae7449f5e95d0f6546 Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Thu, 27 Jan 2011 21:20:09 +0300 Subject: SONAR-2148: Add new properties to manage level of Java language * Use sonar-java-api in sonar-pmd-plugin and sonar-clover-plugin --- .../main/java/org/sonar/java/api/JavaUtils.java | 28 +++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'sonar-java-api/src') diff --git a/sonar-java-api/src/main/java/org/sonar/java/api/JavaUtils.java b/sonar-java-api/src/main/java/org/sonar/java/api/JavaUtils.java index 9fa234f5626..26ee5d17425 100644 --- a/sonar-java-api/src/main/java/org/sonar/java/api/JavaUtils.java +++ b/sonar-java-api/src/main/java/org/sonar/java/api/JavaUtils.java @@ -20,7 +20,11 @@ package org.sonar.java.api; import org.apache.commons.lang.StringUtils; +import org.sonar.api.resources.Project; +/** + * @since 2.6 + */ public final class JavaUtils { public static final String PACKAGE_SEPARATOR = "."; @@ -37,6 +41,16 @@ public final class JavaUtils { */ public static final String BARRIER_AFTER_SQUID = "squid"; + /** + * To determine value of this property use {@link #getSourceVersion(Project)}. + */ + public static final String JAVA_SOURCE_PROPERTY = "sonar.java.source"; + + /** + * To determine value of this property use {@link #getTargetVersion(Project)}. + */ + public static final String JAVA_TARGET_PROPERTY = "sonar.java.target"; + private JavaUtils() { // only static methods } @@ -44,12 +58,20 @@ public final class JavaUtils { public static String abbreviatePackage(String packageName) { String[] parts = StringUtils.split(packageName, PACKAGE_SEPARATOR); StringBuilder sb = new StringBuilder(); - if (parts.length>=1) { + if (parts.length >= 1) { sb.append(parts[0]); } - for (int index=1 ; index