aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-deprecated/src
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2014-02-27 13:37:22 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2014-02-27 13:38:19 +0100
commitbf78055b3e3d021782a727a8072682d64f1e2a4a (patch)
treecc402792322b9cd75038a533c89b65a3b40742c0 /sonar-deprecated/src
parent462f3c3a33e6f2f85b068ce4c164a14d2569ed5d (diff)
downloadsonarqube-bf78055b3e3d021782a727a8072682d64f1e2a4a.tar.gz
sonarqube-bf78055b3e3d021782a727a8072682d64f1e2a4a.zip
Deprecate remaining Java-specific stuff
Diffstat (limited to 'sonar-deprecated/src')
-rw-r--r--sonar-deprecated/src/main/java/org/sonar/api/resources/Java.java79
-rw-r--r--sonar-deprecated/src/test/java/org/sonar/api/resources/JavaTest.java40
2 files changed, 119 insertions, 0 deletions
diff --git a/sonar-deprecated/src/main/java/org/sonar/api/resources/Java.java b/sonar-deprecated/src/main/java/org/sonar/api/resources/Java.java
new file mode 100644
index 00000000000..917c0ad7dc5
--- /dev/null
+++ b/sonar-deprecated/src/main/java/org/sonar/api/resources/Java.java
@@ -0,0 +1,79 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.api.resources;
+
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * Java language implementation
+ * This class have been moved in the plugin sonar-java
+ *
+ * @since 1.10
+ * @deprecated in 3.6
+ */
+@Deprecated
+public class Java extends AbstractLanguage {
+
+ public static final Java INSTANCE = new Java();
+
+ /**
+ * Java key
+ */
+ public static final String KEY = "java";
+
+ /**
+ * Java name
+ */
+ public static final String NAME = "Java";
+
+ /**
+ * Default package name for classes without package def
+ */
+ public static final String DEFAULT_PACKAGE_NAME = "[default]";
+
+ /**
+ * Java files knows suffixes
+ */
+ public static final String[] SUFFIXES = {".java", ".jav"};
+
+ /**
+ * Default constructor
+ */
+ public Java() {
+ super(KEY, NAME);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractLanguage#getFileSuffixes()
+ */
+ public String[] getFileSuffixes() {
+ return SUFFIXES;
+ }
+
+ public static boolean isJavaFile(java.io.File file) {
+ String suffix = "." + StringUtils.lowerCase(StringUtils.substringAfterLast(file.getName(), "."));
+ return ArrayUtils.contains(SUFFIXES, suffix);
+ }
+
+}
diff --git a/sonar-deprecated/src/test/java/org/sonar/api/resources/JavaTest.java b/sonar-deprecated/src/test/java/org/sonar/api/resources/JavaTest.java
new file mode 100644
index 00000000000..94c42354649
--- /dev/null
+++ b/sonar-deprecated/src/test/java/org/sonar/api/resources/JavaTest.java
@@ -0,0 +1,40 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.api.resources;
+
+import org.junit.Test;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class JavaTest {
+
+ @Test
+ public void test() {
+ Java language = new Java();
+ assertThat(language.getFileSuffixes()).isEqualTo(new String[] {".java", ".jav"});
+
+ assertThat(Java.isJavaFile(new java.io.File("Example.java"))).isTrue();
+ assertThat(Java.isJavaFile(new java.io.File("Example.JAVA"))).isTrue();
+ assertThat(Java.isJavaFile(new java.io.File("Example.jav"))).isTrue();
+ assertThat(Java.isJavaFile(new java.io.File("Example.Jav"))).isTrue();
+ assertThat(Java.isJavaFile(new java.io.File("Example.notjava"))).isFalse();
+ }
+
+}