From bf78055b3e3d021782a727a8072682d64f1e2a4a Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Thu, 27 Feb 2014 13:37:22 +0100 Subject: Deprecate remaining Java-specific stuff --- .../main/java/org/sonar/api/resources/Java.java | 79 ++++++++++++++++++++++ .../java/org/sonar/api/resources/JavaTest.java | 40 +++++++++++ 2 files changed, 119 insertions(+) create mode 100644 sonar-deprecated/src/main/java/org/sonar/api/resources/Java.java create mode 100644 sonar-deprecated/src/test/java/org/sonar/api/resources/JavaTest.java (limited to 'sonar-deprecated/src') 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(); + } + +} -- cgit v1.2.3