From 3e7476f0c2e6cfaacad5939cf77a30779801344d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Prante?= Date: Fri, 19 Aug 2016 11:04:46 +0200 Subject: [PATCH] fixing findbug error, pom descriptor --- build.gradle | 1 + gradle.properties | 8 +--- gradle/ext.gradle | 8 ++++ gradle/publish.gradle | 38 ++++++++++++++++++- .../charset/BibliographicCharsetProvider.java | 22 ++--------- .../charset/BibliographicCharsetsTest.java | 9 +++++ 6 files changed, 59 insertions(+), 27 deletions(-) create mode 100644 gradle/ext.gradle diff --git a/build.gradle b/build.gradle index 2a3bf46..8be1c86 100644 --- a/build.gradle +++ b/build.gradle @@ -3,6 +3,7 @@ println "Host: " + java.net.InetAddress.getLocalHost() println "Gradle: " + gradle.gradleVersion + " JVM: " + org.gradle.internal.jvm.Jvm.current() + " Groovy: " + GroovySystem.getVersion() println "Build: group: '${project.group}', name: '${project.name}', version: '${project.version}'" +apply from: 'gradle/ext.gradle' apply plugin: 'java' apply plugin: 'maven' apply plugin: 'signing' diff --git a/gradle.properties b/gradle.properties index 6577918..e26553b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,3 @@ group = org.xbib -version = 1.0.0 +version = 1.0.1 org.gradle.daemon = true -name = 'bibliographic-character-sets' -description = 'Bibliographic character sets' -user = 'xbib' -scmUrl = 'https://github.com/' + user + '/' + name -scmConnection = 'scm:git:git://github.com/' + user + '/' + name + '.git' -scmDeveloperConnection = 'scm:git:git://github.com/' + user + '/' + name + '.git' diff --git a/gradle/ext.gradle b/gradle/ext.gradle new file mode 100644 index 0000000..2af930d --- /dev/null +++ b/gradle/ext.gradle @@ -0,0 +1,8 @@ +ext { + user = 'xbib' + projectName = 'bibliographic-character-sets' + projectDescription = 'Bibliographic character sets' + scmUrl = 'https://github.com/xbib/bibliographic-character-sets' + scmConnection = 'scm:git:git://github.com/xbib/bibliographic-character-sets.git' + scmDeveloperConnection = 'scm:git:git://github.com/xbib/bibliographic-character-sets.git' +} \ No newline at end of file diff --git a/gradle/publish.gradle b/gradle/publish.gradle index 61dd790..b026d3f 100644 --- a/gradle/publish.gradle +++ b/gradle/publish.gradle @@ -8,6 +8,40 @@ task xbibUpload(type: Upload) { repository(url: uri('scpexe://xbib.org/repository')) { authentication(userName: xbibUsername, privateKey: xbibPrivateKey) } + snapshotRepository(url: uri('scpexe://xbib.org/repository/snapshots')) { + authentication(userName: xbibUsername, privateKey: xbibPrivateKey) + } + pom.project { + name projectName + description projectDescription + packaging 'jar' + inceptionYear '2016' + url scmUrl + organization { + name 'xbib' + url 'http://xbib.org' + } + developers { + developer { + id user + name 'Jörg Prante' + email 'joergprante@gmail.com' + url 'https://github.com/jprante' + } + } + scm { + url scmUrl + connection scmConnection + developerConnection scmDeveloperConnection + } + licenses { + license { + name 'Affero GNU Public License Version 3' + url 'http://www.gnu.org/licenses/agpl-3.0.html' + } + } + } + } } } @@ -27,8 +61,8 @@ task mavenCentralUpload(type: Upload) { authentication(userName: ossrhUsername, password: ossrhPassword) } pom.project { - name name - description description + name projectName + description projectDescription packaging 'jar' inceptionYear '2016' url scmUrl diff --git a/src/main/java/org/xbib/charset/BibliographicCharsetProvider.java b/src/main/java/org/xbib/charset/BibliographicCharsetProvider.java index 0617ab0..d42604c 100644 --- a/src/main/java/org/xbib/charset/BibliographicCharsetProvider.java +++ b/src/main/java/org/xbib/charset/BibliographicCharsetProvider.java @@ -52,7 +52,7 @@ public class BibliographicCharsetProvider extends CharsetProvider { * If there are no remaining references to this instance, * the character set will be removed by the garbage collector. */ - private static volatile SoftReference instance = null; + private static volatile BibliographicCharsetProvider instance = new BibliographicCharsetProvider(); private final Map classMap; private final Map aliasMap; private final Map aliasNameMap; @@ -77,26 +77,16 @@ public class BibliographicCharsetProvider extends CharsetProvider { charset("PICA", "Pica", new String[]{"Pica", "pica"}); charset("x-PICA", "PicaCharset", new String[]{"x-pica"}); charset("SIMPLE_ANSEL", "SimpleAnselCharset", new String[]{}); - instance = new SoftReference<>(this); } /** * List all aliases defined for a character set. * - * @param s the name of the character set + * @param charsetName the name of the character set * @return an alias string array */ - static String[] aliasesFor(String s) { - SoftReference softreference = instance; - BibliographicCharsetProvider charsets = null; - if (softreference != null) { - charsets = softreference.get(); - } - if (charsets == null) { - charsets = new BibliographicCharsetProvider(); - instance = new SoftReference<>(charsets); - } - return charsets.aliases(s); + static String[] aliasesFor(String charsetName) { + return instance.aliasNameMap.get(charsetName); } @Override @@ -166,8 +156,4 @@ public class BibliographicCharsetProvider extends CharsetProvider { } return null; } - - private String[] aliases(String s) { - return (String[]) aliasNameMap.get(s); - } } diff --git a/src/test/java/org/xbib/charset/BibliographicCharsetsTest.java b/src/test/java/org/xbib/charset/BibliographicCharsetsTest.java index 2ea105e..5763709 100644 --- a/src/test/java/org/xbib/charset/BibliographicCharsetsTest.java +++ b/src/test/java/org/xbib/charset/BibliographicCharsetsTest.java @@ -31,9 +31,12 @@ */ package org.xbib.charset; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; /** * @@ -43,10 +46,16 @@ public class BibliographicCharsetsTest { @Test public void testAvailability() { Charset charset = BibliographicCharsets.ANSEL; + assertEquals("hello", new String("hello".getBytes(StandardCharsets.US_ASCII), charset)); charset = BibliographicCharsets.ISO5426; + assertEquals("hello", new String("hello".getBytes(StandardCharsets.US_ASCII), charset)); charset = BibliographicCharsets.ISO5428; + assertEquals("hello", new String("hello".getBytes(StandardCharsets.US_ASCII), charset)); charset = BibliographicCharsets.MAB; + assertEquals("hello", new String("hello".getBytes(StandardCharsets.US_ASCII), charset)); charset = BibliographicCharsets.MAB_DISKETTE; + assertEquals("hello", new String("hello".getBytes(StandardCharsets.US_ASCII), charset)); charset = BibliographicCharsets.PICA; + assertEquals("hello", new String("hello".getBytes(StandardCharsets.US_ASCII), charset)); } }