Compare commits
No commits in common. "main" and "1.0.2" have entirely different histories.
51 changed files with 529 additions and 11224 deletions
8
.travis.yml
Normal file
8
.travis.yml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
sudo: false
|
||||||
|
language: java
|
||||||
|
jdk:
|
||||||
|
- oraclejdk8
|
||||||
|
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- $HOME/.m2
|
14
README.md
14
README.md
|
@ -14,11 +14,9 @@ in migrating library data to Unicode, and UTF-8, respectively.
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
| Version | Release date |
|
| Version | Release date |
|
||||||
|---------|--------------|
|
| ------- | ------------ |
|
||||||
| 3.0.0 | May 22, 2023 |
|
| 1.0.0 | Aug 18, 2016 |
|
||||||
| 1.0.2 | Aug 30, 2016 |
|
| 1.0.1 | Aug 20, 2016 |
|
||||||
| 1.0.1 | Aug 20, 2016 |
|
|
||||||
| 1.0.0 | Aug 18, 2016 |
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
@ -27,7 +25,7 @@ With Maven
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.xbib</groupId>
|
<groupId>org.xbib</groupId>
|
||||||
<artifactId>bibliographic-character-sets</artifactId>
|
<artifactId>bibliographic-character-sets</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>1.0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
With Gradle
|
With Gradle
|
||||||
|
@ -36,7 +34,7 @@ With Gradle
|
||||||
provided
|
provided
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
provided 'org.xbib:bibliographic-character-sets:3.0.0'
|
provided 'org.xbib:bibliographic-character-sets:1.0.1'
|
||||||
}
|
}
|
||||||
|
|
||||||
You can also include this jar in the classpath, the Java CharsetProvider and
|
You can also include this jar in the classpath, the Java CharsetProvider and
|
||||||
|
@ -50,7 +48,7 @@ of your project to the public if you make modifications to this program.
|
||||||
All contributions and pull requests are welcome.
|
All contributions and pull requests are welcome.
|
||||||
|
|
||||||
If you have questions or find issues, pleas post them at
|
If you have questions or find issues, pleas post them at
|
||||||
https://xbib.org/xbib/bibliographic-character-sets/issues
|
https://github.com/xbib/bibliographic-character-sets/issues
|
||||||
|
|
||||||
## List of character sets included
|
## List of character sets included
|
||||||
|
|
||||||
|
|
90
build.gradle
90
build.gradle
|
@ -1,33 +1,71 @@
|
||||||
plugins {
|
plugins {
|
||||||
id 'maven-publish'
|
id "org.sonarqube" version "2.1-rc1"
|
||||||
id 'signing'
|
|
||||||
id "build-dashboard"
|
|
||||||
id "io.github.gradle-nexus.publish-plugin" version "2.0.0-rc-1"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wrapper {
|
println "Host: " + java.net.InetAddress.getLocalHost()
|
||||||
gradleVersion = libs.versions.gradle.get()
|
println "Gradle: " + gradle.gradleVersion + " JVM: " + org.gradle.internal.jvm.Jvm.current() + " Groovy: " + GroovySystem.getVersion()
|
||||||
distributionType = Wrapper.DistributionType.BIN
|
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'
|
||||||
|
apply plugin: 'findbugs'
|
||||||
|
apply plugin: 'pmd'
|
||||||
|
apply plugin: 'checkstyle'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
mavenCentral()
|
||||||
|
jcenter()
|
||||||
|
maven {
|
||||||
|
url "http://xbib.org/repository"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
configurations {
|
||||||
user = 'xbib'
|
wagon
|
||||||
name = 'bibliographic-character-sets'
|
|
||||||
description = 'Bibliographic character sets for Java'
|
|
||||||
inceptionYear = '2016'
|
|
||||||
url = 'https://xbib.org/' + user + '/' + name
|
|
||||||
scmUrl = 'https://xbib.org/' + user + '/' + name
|
|
||||||
scmConnection = 'scm:git::ssh://xbib.org/' + user + '/' + name + '.git'
|
|
||||||
scmDeveloperConnection = 'scm:git:ssh://forgejo@xbib.org:' + user + '/' + name + '.git'
|
|
||||||
issueManagementSystem = 'Forgejo'
|
|
||||||
issueManagementUrl = ext.scmUrl + '/issues'
|
|
||||||
licenseName = 'Affero GNU Public License Version 3'
|
|
||||||
licenseUrl = 'http://www.gnu.org/licenses/agpl-3.0.html'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'java-library'
|
dependencies {
|
||||||
apply from: rootProject.file('gradle/repositories/maven.gradle')
|
testCompile "org.apache.logging.log4j:log4j-core:2.5"
|
||||||
apply from: rootProject.file('gradle/compile/java.gradle')
|
testCompile('junit:junit:4.12')
|
||||||
apply from: rootProject.file('gradle/test/junit5.gradle')
|
wagon 'org.apache.maven.wagon:wagon-ssh-external:2.10'
|
||||||
apply from: rootProject.file('gradle/publish/maven.gradle')
|
}
|
||||||
apply from: rootProject.file('gradle/publish/maven-central/sonatype.gradle')
|
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
|
||||||
|
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
|
||||||
|
tasks.withType(JavaCompile) {
|
||||||
|
options.compilerArgs << "-Xlint:deprecation,unchecked"
|
||||||
|
}
|
||||||
|
test {
|
||||||
|
testLogging {
|
||||||
|
showStandardStreams = false
|
||||||
|
exceptionFormat = 'full'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tasks.withType(FindBugs) {
|
||||||
|
ignoreFailures = true
|
||||||
|
reports {
|
||||||
|
xml.enabled = false
|
||||||
|
html.enabled = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
task sourcesJar(type: Jar, dependsOn: classes) {
|
||||||
|
classifier 'sources'
|
||||||
|
from sourceSets.main.allSource
|
||||||
|
}
|
||||||
|
task javadocJar(type: Jar, dependsOn: javadoc) {
|
||||||
|
classifier 'javadoc'
|
||||||
|
}
|
||||||
|
artifacts {
|
||||||
|
archives sourcesJar, javadocJar
|
||||||
|
}
|
||||||
|
if (project.hasProperty('signing.keyId')) {
|
||||||
|
signing {
|
||||||
|
sign configurations.archives
|
||||||
|
}
|
||||||
|
}
|
||||||
|
apply from: 'gradle/publish.gradle'
|
|
@ -9,10 +9,6 @@ page at http://checkstyle.sourceforge.net/config.html -->
|
||||||
|
|
||||||
<module name="Checker">
|
<module name="Checker">
|
||||||
|
|
||||||
<module name="BeforeExecutionExclusionFileFilter">
|
|
||||||
<property name="fileNamePattern" value=".*(Example|Test|module-info)(\$.*)?"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<module name="FileTabCharacter">
|
<module name="FileTabCharacter">
|
||||||
<!-- Checks that there are no tab characters in the file.
|
<!-- Checks that there are no tab characters in the file.
|
||||||
-->
|
-->
|
||||||
|
@ -60,19 +56,10 @@ page at http://checkstyle.sourceforge.net/config.html -->
|
||||||
<!-- Checks for out of order import statements. -->
|
<!-- Checks for out of order import statements. -->
|
||||||
|
|
||||||
<property name="severity" value="warning"/>
|
<property name="severity" value="warning"/>
|
||||||
<!-- <property name="tokens" value="IMPORT, STATIC_IMPORT"/> -->
|
<property name="groups" value="com.google,android,junit,net,org,java,javax"/>
|
||||||
<property name="separated" value="false"/>
|
<!-- This ensures that static imports go first. -->
|
||||||
<property name="groups" value="*"/>
|
<property name="option" value="top"/>
|
||||||
<!-- <property name="option" value="above"/> -->
|
<property name="tokens" value="STATIC_IMPORT, IMPORT"/>
|
||||||
<property name="sortStaticImportsAlphabetically" value="true"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<module name="CustomImportOrder">
|
|
||||||
<!-- <property name="customImportOrderRules" value="THIRD_PARTY_PACKAGE###SPECIAL_IMPORTS###STANDARD_JAVA_PACKAGE###STATIC"/> -->
|
|
||||||
<!-- <property name="specialImportsRegExp" value="^javax\."/> -->
|
|
||||||
<!-- <property name="standardPackageRegExp" value="^java\."/> -->
|
|
||||||
<property name="sortImportsInGroupAlphabetically" value="true"/>
|
|
||||||
<property name="separateLineBetweenGroups" value="false"/>
|
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
@ -84,10 +71,14 @@ page at http://checkstyle.sourceforge.net/config.html -->
|
||||||
<!-- Checks for Javadoc comments. -->
|
<!-- Checks for Javadoc comments. -->
|
||||||
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
|
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
|
||||||
<module name="JavadocMethod">
|
<module name="JavadocMethod">
|
||||||
<property name="accessModifiers" value="protected"/>
|
<property name="scope" value="protected"/>
|
||||||
<property name="severity" value="warning"/>
|
<property name="severity" value="warning"/>
|
||||||
|
<property name="allowMissingJavadoc" value="true"/>
|
||||||
<property name="allowMissingParamTags" value="true"/>
|
<property name="allowMissingParamTags" value="true"/>
|
||||||
<property name="allowMissingReturnTag" value="true"/>
|
<property name="allowMissingReturnTag" value="true"/>
|
||||||
|
<property name="allowMissingThrowsTags" value="true"/>
|
||||||
|
<property name="allowThrowsTagsForSubclasses" value="true"/>
|
||||||
|
<property name="allowUndeclaredRTE" value="true"/>
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
<module name="JavadocType">
|
<module name="JavadocType">
|
||||||
|
@ -193,6 +184,21 @@ page at http://checkstyle.sourceforge.net/config.html -->
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
<module name="LineLength">
|
||||||
|
<!-- Checks if a line is too long. -->
|
||||||
|
<property name="max" value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.max}" default="128"/>
|
||||||
|
<property name="severity" value="error"/>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
The default ignore pattern exempts the following elements:
|
||||||
|
- import statements
|
||||||
|
- long URLs inside comments
|
||||||
|
-->
|
||||||
|
|
||||||
|
<property name="ignorePattern"
|
||||||
|
value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.ignorePattern}"
|
||||||
|
default="^(package .*;\s*)|(import .*;\s*)|( *(\*|//).*https?://.*)$"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
<module name="LeftCurly">
|
<module name="LeftCurly">
|
||||||
<!-- Checks for placement of the left curly brace ('{'). -->
|
<!-- Checks for placement of the left curly brace ('{'). -->
|
||||||
|
@ -313,21 +319,5 @@ page at http://checkstyle.sourceforge.net/config.html -->
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
<module name="LineLength">
|
|
||||||
<!-- Checks if a line is too long. -->
|
|
||||||
<property name="max" value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.max}" default="128"/>
|
|
||||||
<property name="severity" value="error"/>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
The default ignore pattern exempts the following elements:
|
|
||||||
- import statements
|
|
||||||
- long URLs inside comments
|
|
||||||
-->
|
|
||||||
|
|
||||||
<property name="ignorePattern"
|
|
||||||
value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.ignorePattern}"
|
|
||||||
default="^(package .*;\s*)|(import .*;\s*)|( *(\*|//).*https?://.*)$"/>
|
|
||||||
</module>
|
|
||||||
</module>
|
</module>
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
group = org.xbib
|
group = org.xbib
|
||||||
name = bibliographic-character-sets
|
version = 1.0.2
|
||||||
version = 4.0.0
|
org.gradle.daemon = true
|
||||||
|
|
||||||
org.gradle.warning.mode = ALL
|
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
|
|
||||||
apply plugin: 'java-library'
|
|
||||||
|
|
||||||
java {
|
|
||||||
toolchain {
|
|
||||||
languageVersion = JavaLanguageVersion.of(21)
|
|
||||||
}
|
|
||||||
modularity.inferModulePath.set(true)
|
|
||||||
withSourcesJar()
|
|
||||||
withJavadocJar()
|
|
||||||
}
|
|
||||||
|
|
||||||
jar {
|
|
||||||
manifest {
|
|
||||||
attributes('Implementation-Version': project.version)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
|
||||||
options.fork = true
|
|
||||||
options.forkOptions.jvmArgs += ['-Duser.language=en','-Duser.country=US']
|
|
||||||
options.compilerArgs.add('-Xlint:all')
|
|
||||||
options.encoding = 'UTF-8'
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(Javadoc) {
|
|
||||||
options.addStringOption('Xdoclint:none', '-quiet')
|
|
||||||
options.encoding = 'UTF-8'
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
apply plugin: 'org.xbib.gradle.plugin.asciidoctor'
|
|
||||||
|
|
||||||
asciidoctor {
|
|
||||||
backends 'html5'
|
|
||||||
outputDir = file("${rootProject.projectDir}/docs")
|
|
||||||
separateOutputDirs = false
|
|
||||||
attributes 'source-highlighter': 'coderay',
|
|
||||||
idprefix: '',
|
|
||||||
idseparator: '-',
|
|
||||||
toc: 'left',
|
|
||||||
doctype: 'book',
|
|
||||||
icons: 'font',
|
|
||||||
encoding: 'utf-8',
|
|
||||||
sectlink: true,
|
|
||||||
sectanchors: true,
|
|
||||||
linkattrs: true,
|
|
||||||
imagesdir: 'img',
|
|
||||||
stylesheet: "${projectDir}/src/docs/asciidoc/css/foundation.css"
|
|
||||||
}
|
|
8
gradle/ext.gradle
Normal file
8
gradle/ext.gradle
Normal file
|
@ -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'
|
||||||
|
}
|
96
gradle/publish.gradle
Normal file
96
gradle/publish.gradle
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
task xbibUpload(type: Upload) {
|
||||||
|
configuration = configurations.archives
|
||||||
|
uploadDescriptor = true
|
||||||
|
repositories {
|
||||||
|
if (project.hasProperty("xbibUsername")) {
|
||||||
|
mavenDeployer {
|
||||||
|
configuration = configurations.wagon
|
||||||
|
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'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task mavenCentralUpload(type: Upload) {
|
||||||
|
configuration = configurations.archives
|
||||||
|
uploadDescriptor = true
|
||||||
|
repositories {
|
||||||
|
if (project.hasProperty('ossrhUsername')) {
|
||||||
|
mavenDeployer {
|
||||||
|
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
|
||||||
|
repository(url: uri(ossrhReleaseUrl)) {
|
||||||
|
authentication(userName: ossrhUsername, password: ossrhPassword)
|
||||||
|
}
|
||||||
|
snapshotRepository(url: uri(ossrhSnapshotUrl)) {
|
||||||
|
authentication(userName: ossrhUsername, password: ossrhPassword)
|
||||||
|
}
|
||||||
|
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'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,19 +0,0 @@
|
||||||
|
|
||||||
if (project.hasProperty("signing.keyId")) {
|
|
||||||
apply plugin: 'signing'
|
|
||||||
signing {
|
|
||||||
sign publishing.publications."${project.name}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) {
|
|
||||||
nexusPublishing {
|
|
||||||
repositories {
|
|
||||||
sonatype {
|
|
||||||
username = project.property('ossrhUsername')
|
|
||||||
password = project.property('ossrhPassword')
|
|
||||||
packageGroup = "org.xbib"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
|
|
||||||
publishing {
|
|
||||||
publications {
|
|
||||||
"${project.name}"(MavenPublication) {
|
|
||||||
from components.java
|
|
||||||
pom {
|
|
||||||
artifactId = project.name
|
|
||||||
name = project.name
|
|
||||||
description = rootProject.ext.description
|
|
||||||
url = rootProject.ext.url
|
|
||||||
inceptionYear = rootProject.ext.inceptionYear
|
|
||||||
packaging = 'jar'
|
|
||||||
organization {
|
|
||||||
name = 'xbib'
|
|
||||||
url = 'https://xbib.org'
|
|
||||||
}
|
|
||||||
developers {
|
|
||||||
developer {
|
|
||||||
id = 'jprante'
|
|
||||||
name = 'Jörg Prante'
|
|
||||||
email = 'joergprante@gmail.com'
|
|
||||||
url = 'https://xbib.org/joerg'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
scm {
|
|
||||||
url = rootProject.ext.scmUrl
|
|
||||||
connection = rootProject.ext.scmConnection
|
|
||||||
developerConnection = rootProject.ext.scmDeveloperConnection
|
|
||||||
}
|
|
||||||
issueManagement {
|
|
||||||
system = rootProject.ext.issueManagementSystem
|
|
||||||
url = rootProject.ext.issueManagementUrl
|
|
||||||
}
|
|
||||||
licenses {
|
|
||||||
license {
|
|
||||||
name = rootProject.ext.licenseName
|
|
||||||
url = rootProject.ext.licenseUrl
|
|
||||||
distribution = 'repo'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
if (project.hasProperty('forgeJoToken')) {
|
|
||||||
publishing {
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
url 'https://xbib.org/api/packages/joerg/maven'
|
|
||||||
credentials(HttpHeaderCredentials) {
|
|
||||||
name = "Authorization"
|
|
||||||
value = "token ${project.property('forgeJoToken')}"
|
|
||||||
}
|
|
||||||
authentication {
|
|
||||||
header(HttpHeaderAuthentication)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
|
|
||||||
apply plugin: 'checkstyle'
|
|
||||||
|
|
||||||
tasks.withType(Checkstyle) {
|
|
||||||
ignoreFailures = true
|
|
||||||
reports {
|
|
||||||
xml.getRequired().set(true)
|
|
||||||
html.getRequired().set(true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
checkstyle {
|
|
||||||
configFile = rootProject.file('gradle/quality/checkstyle.xml')
|
|
||||||
ignoreFailures = true
|
|
||||||
showViolations = true
|
|
||||||
checkstyleMain {
|
|
||||||
source = sourceSets.main.allSource
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
cyclonedxBom {
|
|
||||||
includeConfigs = [ 'runtimeClasspath' ]
|
|
||||||
skipConfigs = [ 'compileClasspath', 'testCompileClasspath' ]
|
|
||||||
projectType = "library"
|
|
||||||
schemaVersion = "1.5"
|
|
||||||
destination = file("build/reports")
|
|
||||||
outputName = "bom"
|
|
||||||
outputFormat = "json"
|
|
||||||
includeBomSerialNumber = true
|
|
||||||
componentVersion = "2.0.0"
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
|
|
||||||
apply plugin: 'pmd'
|
|
||||||
|
|
||||||
tasks.withType(Pmd) {
|
|
||||||
ignoreFailures = true
|
|
||||||
reports {
|
|
||||||
xml.getRequired().set(true)
|
|
||||||
html.getRequired().set(true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pmd {
|
|
||||||
ignoreFailures = true
|
|
||||||
consoleOutput = false
|
|
||||||
toolVersion = "6.51.0"
|
|
||||||
ruleSetFiles = rootProject.files('gradle/quality/pmd/category/java/bestpractices.xml')
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,10 +0,0 @@
|
||||||
|
|
||||||
rulesets.filenames=\
|
|
||||||
category/java/bestpractices.xml,\
|
|
||||||
category/java/codestyle.xml,\
|
|
||||||
category/java/design.xml,\
|
|
||||||
category/java/documentation.xml,\
|
|
||||||
category/java/errorprone.xml,\
|
|
||||||
category/java/multithreading.xml,\
|
|
||||||
category/java/performance.xml,\
|
|
||||||
category/java/security.xml
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,144 +0,0 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
|
|
||||||
<ruleset name="Documentation"
|
|
||||||
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
|
|
||||||
|
|
||||||
<description>
|
|
||||||
Rules that are related to code documentation.
|
|
||||||
</description>
|
|
||||||
|
|
||||||
<rule name="CommentContent"
|
|
||||||
since="5.0"
|
|
||||||
message="Invalid words or phrases found"
|
|
||||||
class="net.sourceforge.pmd.lang.java.rule.documentation.CommentContentRule"
|
|
||||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_documentation.html#commentcontent">
|
|
||||||
<description>
|
|
||||||
A rule for the politically correct... we don't want to offend anyone.
|
|
||||||
</description>
|
|
||||||
<priority>3</priority>
|
|
||||||
<example>
|
|
||||||
<![CDATA[
|
|
||||||
//OMG, this is horrible, Bob is an idiot !!!
|
|
||||||
]]>
|
|
||||||
</example>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<rule name="CommentRequired"
|
|
||||||
since="5.1"
|
|
||||||
message="Comment is required"
|
|
||||||
class="net.sourceforge.pmd.lang.java.rule.documentation.CommentRequiredRule"
|
|
||||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_documentation.html#commentrequired">
|
|
||||||
<description>
|
|
||||||
Denotes whether comments are required (or unwanted) for specific language elements.
|
|
||||||
</description>
|
|
||||||
<priority>3</priority>
|
|
||||||
<example>
|
|
||||||
<![CDATA[
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author Jon Doe
|
|
||||||
*/
|
|
||||||
]]>
|
|
||||||
</example>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<rule name="CommentSize"
|
|
||||||
since="5.0"
|
|
||||||
message="Comment is too large"
|
|
||||||
class="net.sourceforge.pmd.lang.java.rule.documentation.CommentSizeRule"
|
|
||||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_documentation.html#commentsize">
|
|
||||||
<description>
|
|
||||||
Determines whether the dimensions of non-header comments found are within the specified limits.
|
|
||||||
</description>
|
|
||||||
<priority>3</priority>
|
|
||||||
<example>
|
|
||||||
<![CDATA[
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* too many lines!
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
]]>
|
|
||||||
</example>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<rule name="UncommentedEmptyConstructor"
|
|
||||||
language="java"
|
|
||||||
since="3.4"
|
|
||||||
message="Document empty constructor"
|
|
||||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
|
||||||
typeResolution="true"
|
|
||||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_documentation.html#uncommentedemptyconstructor">
|
|
||||||
<description>
|
|
||||||
Uncommented Empty Constructor finds instances where a constructor does not
|
|
||||||
contain statements, but there is no comment. By explicitly commenting empty
|
|
||||||
constructors it is easier to distinguish between intentional (commented)
|
|
||||||
and unintentional empty constructors.
|
|
||||||
</description>
|
|
||||||
<priority>3</priority>
|
|
||||||
<properties>
|
|
||||||
<property name="xpath">
|
|
||||||
<value>
|
|
||||||
<![CDATA[
|
|
||||||
//ConstructorDeclaration[@Private='false']
|
|
||||||
[count(BlockStatement) = 0 and ($ignoreExplicitConstructorInvocation = 'true' or not(ExplicitConstructorInvocation)) and @containsComment = 'false']
|
|
||||||
[not(../Annotation/MarkerAnnotation/Name[pmd-java:typeIs('javax.inject.Inject')])]
|
|
||||||
]]>
|
|
||||||
</value>
|
|
||||||
</property>
|
|
||||||
<property name="ignoreExplicitConstructorInvocation" type="Boolean" description="Ignore explicit constructor invocation when deciding whether constructor is empty or not" value="false"/>
|
|
||||||
</properties>
|
|
||||||
<example>
|
|
||||||
<![CDATA[
|
|
||||||
public Foo() {
|
|
||||||
// This constructor is intentionally empty. Nothing special is needed here.
|
|
||||||
}
|
|
||||||
]]>
|
|
||||||
</example>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<rule name="UncommentedEmptyMethodBody"
|
|
||||||
language="java"
|
|
||||||
since="3.4"
|
|
||||||
message="Document empty method body"
|
|
||||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
|
||||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_documentation.html#uncommentedemptymethodbody">
|
|
||||||
<description>
|
|
||||||
Uncommented Empty Method Body finds instances where a method body does not contain
|
|
||||||
statements, but there is no comment. By explicitly commenting empty method bodies
|
|
||||||
it is easier to distinguish between intentional (commented) and unintentional
|
|
||||||
empty methods.
|
|
||||||
</description>
|
|
||||||
<priority>3</priority>
|
|
||||||
<properties>
|
|
||||||
<property name="xpath">
|
|
||||||
<value>
|
|
||||||
<![CDATA[
|
|
||||||
//MethodDeclaration/Block[count(BlockStatement) = 0 and @containsComment = 'false']
|
|
||||||
]]>
|
|
||||||
</value>
|
|
||||||
</property>
|
|
||||||
</properties>
|
|
||||||
<example>
|
|
||||||
<![CDATA[
|
|
||||||
public void doSomething() {
|
|
||||||
}
|
|
||||||
]]>
|
|
||||||
</example>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
</ruleset>
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,393 +0,0 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
|
|
||||||
<ruleset name="Multithreading"
|
|
||||||
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
|
|
||||||
|
|
||||||
<description>
|
|
||||||
Rules that flag issues when dealing with multiple threads of execution.
|
|
||||||
</description>
|
|
||||||
|
|
||||||
<rule name="AvoidSynchronizedAtMethodLevel"
|
|
||||||
language="java"
|
|
||||||
since="3.0"
|
|
||||||
message="Use block level rather than method level synchronization"
|
|
||||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
|
||||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#avoidsynchronizedatmethodlevel">
|
|
||||||
<description>
|
|
||||||
Method-level synchronization can cause problems when new code is added to the method.
|
|
||||||
Block-level synchronization helps to ensure that only the code that needs synchronization
|
|
||||||
gets it.
|
|
||||||
</description>
|
|
||||||
<priority>3</priority>
|
|
||||||
<properties>
|
|
||||||
<property name="xpath">
|
|
||||||
<value>//MethodDeclaration[@Synchronized='true']</value>
|
|
||||||
</property>
|
|
||||||
</properties>
|
|
||||||
<example>
|
|
||||||
<![CDATA[
|
|
||||||
public class Foo {
|
|
||||||
// Try to avoid this:
|
|
||||||
synchronized void foo() {
|
|
||||||
}
|
|
||||||
// Prefer this:
|
|
||||||
void bar() {
|
|
||||||
synchronized(this) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try to avoid this for static methods:
|
|
||||||
static synchronized void fooStatic() {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prefer this:
|
|
||||||
static void barStatic() {
|
|
||||||
synchronized(Foo.class) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]]>
|
|
||||||
</example>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<rule name="AvoidThreadGroup"
|
|
||||||
language="java"
|
|
||||||
since="3.6"
|
|
||||||
message="Avoid using java.lang.ThreadGroup; it is not thread safe"
|
|
||||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
|
||||||
typeResolution="true"
|
|
||||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#avoidthreadgroup">
|
|
||||||
<description>
|
|
||||||
Avoid using java.lang.ThreadGroup; although it is intended to be used in a threaded environment
|
|
||||||
it contains methods that are not thread-safe.
|
|
||||||
</description>
|
|
||||||
<priority>3</priority>
|
|
||||||
<properties>
|
|
||||||
<property name="xpath">
|
|
||||||
<value>
|
|
||||||
<![CDATA[
|
|
||||||
//AllocationExpression/ClassOrInterfaceType[pmd-java:typeIs('java.lang.ThreadGroup')]|
|
|
||||||
//PrimarySuffix[contains(@Image, 'getThreadGroup')]
|
|
||||||
]]>
|
|
||||||
</value>
|
|
||||||
</property>
|
|
||||||
</properties>
|
|
||||||
<example>
|
|
||||||
<![CDATA[
|
|
||||||
public class Bar {
|
|
||||||
void buz() {
|
|
||||||
ThreadGroup tg = new ThreadGroup("My threadgroup");
|
|
||||||
tg = new ThreadGroup(tg, "my thread group");
|
|
||||||
tg = Thread.currentThread().getThreadGroup();
|
|
||||||
tg = System.getSecurityManager().getThreadGroup();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]]>
|
|
||||||
</example>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<rule name="AvoidUsingVolatile"
|
|
||||||
language="java"
|
|
||||||
since="4.1"
|
|
||||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
|
||||||
message="Use of modifier volatile is not recommended."
|
|
||||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#avoidusingvolatile">
|
|
||||||
<description>
|
|
||||||
Use of the keyword 'volatile' is generally used to fine tune a Java application, and therefore, requires
|
|
||||||
a good expertise of the Java Memory Model. Moreover, its range of action is somewhat misknown. Therefore,
|
|
||||||
the volatile keyword should not be used for maintenance purpose and portability.
|
|
||||||
</description>
|
|
||||||
<priority>2</priority>
|
|
||||||
<properties>
|
|
||||||
<property name="xpath">
|
|
||||||
<value>//FieldDeclaration[contains(@Volatile,'true')]</value>
|
|
||||||
</property>
|
|
||||||
</properties>
|
|
||||||
<example>
|
|
||||||
<![CDATA[
|
|
||||||
public class ThrDeux {
|
|
||||||
private volatile String var1; // not suggested
|
|
||||||
private String var2; // preferred
|
|
||||||
}
|
|
||||||
]]>
|
|
||||||
</example>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<rule name="DoNotUseThreads"
|
|
||||||
language="java"
|
|
||||||
since="4.1"
|
|
||||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
|
||||||
message="To be compliant to J2EE, a webapp should not use any thread."
|
|
||||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#donotusethreads">
|
|
||||||
<description>
|
|
||||||
The J2EE specification explicitly forbids the use of threads.
|
|
||||||
</description>
|
|
||||||
<priority>3</priority>
|
|
||||||
<properties>
|
|
||||||
<property name="xpath">
|
|
||||||
<value>//ClassOrInterfaceType[@Image = 'Thread' or @Image = 'Runnable']</value>
|
|
||||||
</property>
|
|
||||||
</properties>
|
|
||||||
<example>
|
|
||||||
<![CDATA[
|
|
||||||
// This is not allowed
|
|
||||||
public class UsingThread extends Thread {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Neither this,
|
|
||||||
public class OtherThread implements Runnable {
|
|
||||||
// Nor this ...
|
|
||||||
public void methode() {
|
|
||||||
Runnable thread = new Thread(); thread.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]]>
|
|
||||||
</example>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<rule name="DontCallThreadRun"
|
|
||||||
language="java"
|
|
||||||
since="4.3"
|
|
||||||
message="Don't call Thread.run() explicitly, use Thread.start()"
|
|
||||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
|
||||||
typeResolution="true"
|
|
||||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#dontcallthreadrun">
|
|
||||||
<description>
|
|
||||||
Explicitly calling Thread.run() method will execute in the caller's thread of control. Instead, call Thread.start() for the intended behavior.
|
|
||||||
</description>
|
|
||||||
<priority>4</priority>
|
|
||||||
<properties>
|
|
||||||
<property name="xpath">
|
|
||||||
<value>
|
|
||||||
<![CDATA[
|
|
||||||
//StatementExpression/PrimaryExpression
|
|
||||||
[
|
|
||||||
PrimaryPrefix
|
|
||||||
[
|
|
||||||
./Name[ends-with(@Image, '.run') or @Image = 'run']
|
|
||||||
and substring-before(Name/@Image, '.') =//VariableDeclarator/VariableDeclaratorId/@Image
|
|
||||||
[../../../Type/ReferenceType/ClassOrInterfaceType[pmd-java:typeIs('java.lang.Thread')]]
|
|
||||||
or (./AllocationExpression/ClassOrInterfaceType[pmd-java:typeIs('java.lang.Thread')]
|
|
||||||
and ../PrimarySuffix[@Image = 'run'])
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]]>
|
|
||||||
</value>
|
|
||||||
</property>
|
|
||||||
</properties>
|
|
||||||
<example>
|
|
||||||
<![CDATA[
|
|
||||||
Thread t = new Thread();
|
|
||||||
t.run(); // use t.start() instead
|
|
||||||
new Thread().run(); // same violation
|
|
||||||
]]>
|
|
||||||
</example>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<rule name="DoubleCheckedLocking"
|
|
||||||
language="java"
|
|
||||||
since="1.04"
|
|
||||||
message="Double checked locking is not thread safe in Java."
|
|
||||||
class="net.sourceforge.pmd.lang.java.rule.multithreading.DoubleCheckedLockingRule"
|
|
||||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#doublecheckedlocking">
|
|
||||||
<description>
|
|
||||||
Partially created objects can be returned by the Double Checked Locking pattern when used in Java.
|
|
||||||
An optimizing JRE may assign a reference to the baz variable before it calls the constructor of the object the
|
|
||||||
reference points to.
|
|
||||||
|
|
||||||
Note: With Java 5, you can make Double checked locking work, if you declare the variable to be `volatile`.
|
|
||||||
|
|
||||||
For more details refer to: <http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-double.html>
|
|
||||||
or <http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html>
|
|
||||||
</description>
|
|
||||||
<priority>1</priority>
|
|
||||||
<example>
|
|
||||||
<![CDATA[
|
|
||||||
public class Foo {
|
|
||||||
/*volatile */ Object baz = null; // fix for Java5 and later: volatile
|
|
||||||
Object bar() {
|
|
||||||
if (baz == null) { // baz may be non-null yet not fully created
|
|
||||||
synchronized(this) {
|
|
||||||
if (baz == null) {
|
|
||||||
baz = new Object();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return baz;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]]>
|
|
||||||
</example>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<rule name="NonThreadSafeSingleton"
|
|
||||||
since="3.4"
|
|
||||||
message="Singleton is not thread safe"
|
|
||||||
class="net.sourceforge.pmd.lang.java.rule.multithreading.NonThreadSafeSingletonRule"
|
|
||||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#nonthreadsafesingleton">
|
|
||||||
<description>
|
|
||||||
Non-thread safe singletons can result in bad state changes. Eliminate
|
|
||||||
static singletons if possible by instantiating the object directly. Static
|
|
||||||
singletons are usually not needed as only a single instance exists anyway.
|
|
||||||
Other possible fixes are to synchronize the entire method or to use an
|
|
||||||
[initialize-on-demand holder class](https://en.wikipedia.org/wiki/Initialization-on-demand_holder_idiom).
|
|
||||||
|
|
||||||
Refrain from using the double-checked locking pattern. The Java Memory Model doesn't
|
|
||||||
guarantee it to work unless the variable is declared as `volatile`, adding an uneeded
|
|
||||||
performance penalty. [Reference](http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html)
|
|
||||||
|
|
||||||
See Effective Java, item 48.
|
|
||||||
</description>
|
|
||||||
<priority>3</priority>
|
|
||||||
<example>
|
|
||||||
<![CDATA[
|
|
||||||
private static Foo foo = null;
|
|
||||||
|
|
||||||
//multiple simultaneous callers may see partially initialized objects
|
|
||||||
public static Foo getFoo() {
|
|
||||||
if (foo==null) {
|
|
||||||
foo = new Foo();
|
|
||||||
}
|
|
||||||
return foo;
|
|
||||||
}
|
|
||||||
]]>
|
|
||||||
</example>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<rule name="UnsynchronizedStaticDateFormatter"
|
|
||||||
since="3.6"
|
|
||||||
deprecated="true"
|
|
||||||
message="Static DateFormatter objects should be accessed in a synchronized manner"
|
|
||||||
class="net.sourceforge.pmd.lang.java.rule.multithreading.UnsynchronizedStaticDateFormatterRule"
|
|
||||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#unsynchronizedstaticdateformatter">
|
|
||||||
<description>
|
|
||||||
SimpleDateFormat instances are not synchronized. Sun recommends using separate format instances
|
|
||||||
for each thread. If multiple threads must access a static formatter, the formatter must be
|
|
||||||
synchronized either on method or block level.
|
|
||||||
|
|
||||||
This rule has been deprecated in favor of the rule {% rule UnsynchronizedStaticFormatter %}.
|
|
||||||
</description>
|
|
||||||
<priority>3</priority>
|
|
||||||
<example>
|
|
||||||
<![CDATA[
|
|
||||||
public class Foo {
|
|
||||||
private static final SimpleDateFormat sdf = new SimpleDateFormat();
|
|
||||||
void bar() {
|
|
||||||
sdf.format(); // poor, no thread-safety
|
|
||||||
}
|
|
||||||
synchronized void foo() {
|
|
||||||
sdf.format(); // preferred
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]]>
|
|
||||||
</example>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<rule name="UnsynchronizedStaticFormatter"
|
|
||||||
since="6.11.0"
|
|
||||||
message="Static Formatter objects should be accessed in a synchronized manner"
|
|
||||||
class="net.sourceforge.pmd.lang.java.rule.multithreading.UnsynchronizedStaticFormatterRule"
|
|
||||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#unsynchronizedstaticformatter">
|
|
||||||
<description>
|
|
||||||
Instances of `java.text.Format` are generally not synchronized.
|
|
||||||
Sun recommends using separate format instances for each thread.
|
|
||||||
If multiple threads must access a static formatter, the formatter must be
|
|
||||||
synchronized either on method or block level.
|
|
||||||
</description>
|
|
||||||
<priority>3</priority>
|
|
||||||
<example>
|
|
||||||
<![CDATA[
|
|
||||||
public class Foo {
|
|
||||||
private static final SimpleDateFormat sdf = new SimpleDateFormat();
|
|
||||||
void bar() {
|
|
||||||
sdf.format(); // poor, no thread-safety
|
|
||||||
}
|
|
||||||
synchronized void foo() {
|
|
||||||
sdf.format(); // preferred
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]]>
|
|
||||||
</example>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<rule name="UseConcurrentHashMap"
|
|
||||||
language="java"
|
|
||||||
minimumLanguageVersion="1.5"
|
|
||||||
since="4.2.6"
|
|
||||||
message="If you run in Java5 or newer and have concurrent access, you should use the ConcurrentHashMap implementation"
|
|
||||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
|
||||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#useconcurrenthashmap">
|
|
||||||
<description>
|
|
||||||
Since Java5 brought a new implementation of the Map designed for multi-threaded access, you can
|
|
||||||
perform efficient map reads without blocking other threads.
|
|
||||||
</description>
|
|
||||||
<priority>3</priority>
|
|
||||||
<properties>
|
|
||||||
<property name="xpath">
|
|
||||||
<value>
|
|
||||||
<![CDATA[
|
|
||||||
//Type[../VariableDeclarator/VariableInitializer//AllocationExpression/ClassOrInterfaceType[@Image != 'ConcurrentHashMap']]
|
|
||||||
/ReferenceType/ClassOrInterfaceType[@Image = 'Map']
|
|
||||||
]]>
|
|
||||||
</value>
|
|
||||||
</property>
|
|
||||||
</properties>
|
|
||||||
<example>
|
|
||||||
<![CDATA[
|
|
||||||
public class ConcurrentApp {
|
|
||||||
public void getMyInstance() {
|
|
||||||
Map map1 = new HashMap(); // fine for single-threaded access
|
|
||||||
Map map2 = new ConcurrentHashMap(); // preferred for use with multiple threads
|
|
||||||
|
|
||||||
// the following case will be ignored by this rule
|
|
||||||
Map map3 = someModule.methodThatReturnMap(); // might be OK, if the returned map is already thread-safe
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]]>
|
|
||||||
</example>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<rule name="UseNotifyAllInsteadOfNotify"
|
|
||||||
language="java"
|
|
||||||
since="3.0"
|
|
||||||
message="Call Thread.notifyAll() rather than Thread.notify()"
|
|
||||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
|
||||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#usenotifyallinsteadofnotify">
|
|
||||||
<description>
|
|
||||||
Thread.notify() awakens a thread monitoring the object. If more than one thread is monitoring, then only
|
|
||||||
one is chosen. The thread chosen is arbitrary; thus its usually safer to call notifyAll() instead.
|
|
||||||
</description>
|
|
||||||
<priority>3</priority>
|
|
||||||
<properties>
|
|
||||||
<property name="xpath">
|
|
||||||
<value>
|
|
||||||
<![CDATA[
|
|
||||||
//StatementExpression/PrimaryExpression
|
|
||||||
[PrimarySuffix/Arguments[@ArgumentCount = '0']]
|
|
||||||
[
|
|
||||||
PrimaryPrefix[
|
|
||||||
./Name[@Image='notify' or ends-with(@Image,'.notify')]
|
|
||||||
or ../PrimarySuffix/@Image='notify'
|
|
||||||
or (./AllocationExpression and ../PrimarySuffix[@Image='notify'])
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]]>
|
|
||||||
</value>
|
|
||||||
</property>
|
|
||||||
</properties>
|
|
||||||
<example>
|
|
||||||
<![CDATA[
|
|
||||||
void bar() {
|
|
||||||
x.notify();
|
|
||||||
// If many threads are monitoring x, only one (and you won't know which) will be notified.
|
|
||||||
// use instead:
|
|
||||||
x.notifyAll();
|
|
||||||
}
|
|
||||||
]]>
|
|
||||||
</example>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
</ruleset>
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,65 +0,0 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
|
|
||||||
<ruleset name="Security" xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
|
|
||||||
|
|
||||||
<description>
|
|
||||||
Rules that flag potential security flaws.
|
|
||||||
</description>
|
|
||||||
|
|
||||||
<rule name="HardCodedCryptoKey"
|
|
||||||
since="6.4.0"
|
|
||||||
message="Do not use hard coded encryption keys"
|
|
||||||
class="net.sourceforge.pmd.lang.java.rule.security.HardCodedCryptoKeyRule"
|
|
||||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_security.html#hardcodedcryptokey">
|
|
||||||
<description>
|
|
||||||
Do not use hard coded values for cryptographic operations. Please store keys outside of source code.
|
|
||||||
</description>
|
|
||||||
<priority>3</priority>
|
|
||||||
<example>
|
|
||||||
<![CDATA[
|
|
||||||
public class Foo {
|
|
||||||
void good() {
|
|
||||||
SecretKeySpec secretKeySpec = new SecretKeySpec(Properties.getKey(), "AES");
|
|
||||||
}
|
|
||||||
|
|
||||||
void bad() {
|
|
||||||
SecretKeySpec secretKeySpec = new SecretKeySpec("my secret here".getBytes(), "AES");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]]>
|
|
||||||
</example>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<rule name="InsecureCryptoIv"
|
|
||||||
since="6.3.0"
|
|
||||||
message="Do not use hard coded initialization vector in crypto operations"
|
|
||||||
class="net.sourceforge.pmd.lang.java.rule.security.InsecureCryptoIvRule"
|
|
||||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_security.html#insecurecryptoiv">
|
|
||||||
<description>
|
|
||||||
Do not use hard coded initialization vector in cryptographic operations. Please use a randomly generated IV.
|
|
||||||
</description>
|
|
||||||
<priority>3</priority>
|
|
||||||
<example>
|
|
||||||
<![CDATA[
|
|
||||||
public class Foo {
|
|
||||||
void good() {
|
|
||||||
SecureRandom random = new SecureRandom();
|
|
||||||
byte iv[] = new byte[16];
|
|
||||||
random.nextBytes(bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
void bad() {
|
|
||||||
byte[] iv = new byte[] { 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, };
|
|
||||||
}
|
|
||||||
|
|
||||||
void alsoBad() {
|
|
||||||
byte[] iv = "secret iv in here".getBytes();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]]>
|
|
||||||
</example>
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
</ruleset>
|
|
|
@ -1,37 +0,0 @@
|
||||||
|
|
||||||
subprojects {
|
|
||||||
|
|
||||||
sonarqube {
|
|
||||||
properties {
|
|
||||||
property "sonar.projectName", "${project.group} ${project.name}"
|
|
||||||
property "sonar.sourceEncoding", "UTF-8"
|
|
||||||
property "sonar.tests", "src/test/java"
|
|
||||||
property "sonar.scm.provider", "git"
|
|
||||||
property "sonar.junit.reportsPath", "build/test-results/test/"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
tasks.withType(Pmd) {
|
|
||||||
ignoreFailures = true
|
|
||||||
reports {
|
|
||||||
xml.enabled = true
|
|
||||||
html.enabled = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
spotbugs {
|
|
||||||
effort = "max"
|
|
||||||
reportLevel = "low"
|
|
||||||
//includeFilter = file("findbugs-exclude.xml")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(com.github.spotbugs.SpotBugsTask) {
|
|
||||||
ignoreFailures = true
|
|
||||||
reports {
|
|
||||||
xml.enabled = false
|
|
||||||
html.enabled = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
/*
|
|
||||||
apply plugin: 'com.github.spotbugs'
|
|
||||||
|
|
||||||
spotbugs {
|
|
||||||
effort = "max"
|
|
||||||
reportLevel = "low"
|
|
||||||
ignoreFailures = true
|
|
||||||
}
|
|
||||||
|
|
||||||
spotbugsMain {
|
|
||||||
reports {
|
|
||||||
xml.getRequired().set(false)
|
|
||||||
html.getRequired().set(true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
|
@ -1,4 +0,0 @@
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
|
@ -1,41 +0,0 @@
|
||||||
dependencies {
|
|
||||||
testImplementation testLibs.junit.jupiter.api
|
|
||||||
testImplementation testLibs.junit.jupiter.params
|
|
||||||
testImplementation testLibs.hamcrest
|
|
||||||
testRuntimeOnly testLibs.junit.jupiter.engine
|
|
||||||
testRuntimeOnly testLibs.junit.jupiter.platform.launcher
|
|
||||||
}
|
|
||||||
|
|
||||||
test {
|
|
||||||
useJUnitPlatform()
|
|
||||||
failFast = false
|
|
||||||
ignoreFailures = true
|
|
||||||
jvmArgs '--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED',
|
|
||||||
'--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED',
|
|
||||||
'--add-exports=java.base/sun.nio.ch=ALL-UNNAMED',
|
|
||||||
'--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED',
|
|
||||||
'--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED',
|
|
||||||
'--add-opens=jdk.compiler/com.sun.tools.javac=ALL-UNNAMED',
|
|
||||||
'--add-opens=java.base/java.lang=ALL-UNNAMED',
|
|
||||||
'--add-opens=java.base/java.lang.reflect=ALL-UNNAMED',
|
|
||||||
'--add-opens=java.base/java.io=ALL-UNNAMED',
|
|
||||||
'--add-opens=java.base/java.nio=ALL-UNNAMED',
|
|
||||||
'--add-opens=java.base/java.util=ALL-UNNAMED'
|
|
||||||
testLogging {
|
|
||||||
events 'STARTED', 'PASSED', 'FAILED', 'SKIPPED'
|
|
||||||
showStandardStreams = false
|
|
||||||
}
|
|
||||||
reports {
|
|
||||||
html.required = false
|
|
||||||
junitXml.outputLocation.set(layout.buildDirectory.dir("test-junit-xml"))
|
|
||||||
}
|
|
||||||
afterSuite { desc, result ->
|
|
||||||
if (!desc.parent) {
|
|
||||||
println "\nTest result: ${result.resultType}"
|
|
||||||
println "Test summary: ${result.testCount} tests, " +
|
|
||||||
"${result.successfulTestCount} succeeded, " +
|
|
||||||
"${result.failedTestCount} failed, " +
|
|
||||||
"${result.skippedTestCount} skipped"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
5
gradle/wrapper/gradle-wrapper.properties
vendored
5
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,7 +1,6 @@
|
||||||
|
#Thu Aug 18 20:34:33 CEST 2016
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
|
||||||
networkTimeout=10000
|
|
||||||
validateDistributionUrl=true
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-bin.zip
|
||||||
|
|
312
gradlew
vendored
312
gradlew
vendored
|
@ -1,127 +1,78 @@
|
||||||
#!/bin/sh
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#
|
|
||||||
# Copyright © 2015-2021 the original authors.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
##
|
||||||
# Gradle start up script for POSIX generated by Gradle.
|
## Gradle start up script for UN*X
|
||||||
#
|
##
|
||||||
# Important for running:
|
|
||||||
#
|
|
||||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
|
||||||
# noncompliant, but you have some other compliant shell such as ksh or
|
|
||||||
# bash, then to run this script, type that shell name before the whole
|
|
||||||
# command line, like:
|
|
||||||
#
|
|
||||||
# ksh Gradle
|
|
||||||
#
|
|
||||||
# Busybox and similar reduced shells will NOT work, because this script
|
|
||||||
# requires all of these POSIX shell features:
|
|
||||||
# * functions;
|
|
||||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
|
||||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
|
||||||
# * compound commands having a testable exit status, especially «case»;
|
|
||||||
# * various built-in commands including «command», «set», and «ulimit».
|
|
||||||
#
|
|
||||||
# Important for patching:
|
|
||||||
#
|
|
||||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
|
||||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
|
||||||
#
|
|
||||||
# The "traditional" practice of packing multiple parameters into a
|
|
||||||
# space-separated string is a well documented source of bugs and security
|
|
||||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
|
||||||
# options in "$@", and eventually passing that to Java.
|
|
||||||
#
|
|
||||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
|
||||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
|
||||||
# see the in-line comments for details.
|
|
||||||
#
|
|
||||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
|
||||||
# Darwin, MinGW, and NonStop.
|
|
||||||
#
|
|
||||||
# (3) This script is generated from the Groovy template
|
|
||||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
|
||||||
# within the Gradle project.
|
|
||||||
#
|
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
|
||||||
#
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
# Resolve links: $0 may be a link
|
# Resolve links: $0 may be a link
|
||||||
app_path=$0
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
# Need this for daisy-chained symlinks.
|
while [ -h "$PRG" ] ; do
|
||||||
while
|
ls=`ls -ld "$PRG"`
|
||||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
[ -h "$app_path" ]
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
do
|
PRG="$link"
|
||||||
ls=$( ls -ld "$app_path" )
|
else
|
||||||
link=${ls#*' -> '}
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
case $link in #(
|
fi
|
||||||
/*) app_path=$link ;; #(
|
|
||||||
*) app_path=$APP_HOME$link ;;
|
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
# This is normally unused
|
APP_NAME="Gradle"
|
||||||
# shellcheck disable=SC2034
|
APP_BASE_NAME=`basename "$0"`
|
||||||
APP_BASE_NAME=${0##*/}
|
|
||||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
DEFAULT_JVM_OPTS=""
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD="maximum"
|
||||||
|
|
||||||
warn () {
|
warn ( ) {
|
||||||
echo "$*"
|
echo "$*"
|
||||||
} >&2
|
}
|
||||||
|
|
||||||
die () {
|
die ( ) {
|
||||||
echo
|
echo
|
||||||
echo "$*"
|
echo "$*"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
} >&2
|
}
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
# OS specific support (must be 'true' or 'false').
|
||||||
cygwin=false
|
cygwin=false
|
||||||
msys=false
|
msys=false
|
||||||
darwin=false
|
darwin=false
|
||||||
nonstop=false
|
nonstop=false
|
||||||
case "$( uname )" in #(
|
case "`uname`" in
|
||||||
CYGWIN* ) cygwin=true ;; #(
|
CYGWIN* )
|
||||||
Darwin* ) darwin=true ;; #(
|
cygwin=true
|
||||||
MSYS* | MINGW* ) msys=true ;; #(
|
;;
|
||||||
NONSTOP* ) nonstop=true ;;
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
else
|
else
|
||||||
JAVACMD=$JAVA_HOME/bin/java
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
fi
|
fi
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
@ -130,120 +81,89 @@ Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD=java
|
JAVACMD="java"
|
||||||
if ! command -v java >/dev/null 2>&1
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
then
|
|
||||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
case $MAX_FD in #(
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
max*)
|
if [ $? -eq 0 ] ; then
|
||||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
# shellcheck disable=SC2039,SC3045
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
|
||||||
warn "Could not query maximum file descriptor limit"
|
|
||||||
esac
|
|
||||||
case $MAX_FD in #(
|
|
||||||
'' | soft) :;; #(
|
|
||||||
*)
|
|
||||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
|
||||||
# shellcheck disable=SC2039,SC3045
|
|
||||||
ulimit -n "$MAX_FD" ||
|
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Collect all arguments for the java command, stacking in reverse order:
|
|
||||||
# * args from the command line
|
|
||||||
# * the main class name
|
|
||||||
# * -classpath
|
|
||||||
# * -D...appname settings
|
|
||||||
# * --module-path (only if needed)
|
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
||||||
if "$cygwin" || "$msys" ; then
|
|
||||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
|
||||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
|
||||||
|
|
||||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
|
||||||
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
||||||
for arg do
|
|
||||||
if
|
|
||||||
case $arg in #(
|
|
||||||
-*) false ;; # don't mess with options #(
|
|
||||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
|
||||||
[ -e "$t" ] ;; #(
|
|
||||||
*) false ;;
|
|
||||||
esac
|
|
||||||
then
|
|
||||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
|
||||||
fi
|
fi
|
||||||
# Roll the args list around exactly as many times as the number of
|
ulimit -n $MAX_FD
|
||||||
# args, so each arg winds up back in the position where it started, but
|
if [ $? -ne 0 ] ; then
|
||||||
# possibly modified.
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
#
|
fi
|
||||||
# NB: a `for` loop captures its iteration list before it begins, so
|
else
|
||||||
# changing the positional parameters here affects neither the number of
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
# iterations, nor the values presented in `arg`.
|
fi
|
||||||
shift # remove old arg
|
fi
|
||||||
set -- "$@" "$arg" # push replacement arg
|
|
||||||
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
|
if $darwin; then
|
||||||
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
|
if $cygwin ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
SEP=""
|
||||||
|
for dir in $ROOTDIRSRAW ; do
|
||||||
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
|
SEP="|"
|
||||||
done
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
(0) set -- ;;
|
||||||
|
(1) set -- "$args0" ;;
|
||||||
|
(2) set -- "$args0" "$args1" ;;
|
||||||
|
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||||
|
function splitJvmOpts() {
|
||||||
|
JVM_OPTS=("$@")
|
||||||
|
}
|
||||||
|
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||||
|
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
if [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]]; then
|
||||||
|
cd "$(dirname "$0")"
|
||||||
# Collect all arguments for the java command:
|
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
|
||||||
# and any embedded shellness will be escaped.
|
|
||||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
|
||||||
# treated as '${Hostname}' itself on the command line.
|
|
||||||
|
|
||||||
set -- \
|
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
|
||||||
-classpath "$CLASSPATH" \
|
|
||||||
org.gradle.wrapper.GradleWrapperMain \
|
|
||||||
"$@"
|
|
||||||
|
|
||||||
# Stop when "xargs" is not available.
|
|
||||||
if ! command -v xargs >/dev/null 2>&1
|
|
||||||
then
|
|
||||||
die "xargs is not available"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||||
#
|
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
|
||||||
#
|
|
||||||
# In Bash we could simply go:
|
|
||||||
#
|
|
||||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
|
||||||
# set -- "${ARGS[@]}" "$@"
|
|
||||||
#
|
|
||||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
|
||||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
|
||||||
# character that might be a shell metacharacter, then use eval to reverse
|
|
||||||
# that process (while maintaining the separation between arguments), and wrap
|
|
||||||
# the whole thing up as a single "set" statement.
|
|
||||||
#
|
|
||||||
# This will of course break if any of these variables contains a newline or
|
|
||||||
# an unmatched quote.
|
|
||||||
#
|
|
||||||
|
|
||||||
eval "set -- $(
|
|
||||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
|
||||||
xargs -n1 |
|
|
||||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
|
||||||
tr '\n' ' '
|
|
||||||
)" '"$@"'
|
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
|
||||||
|
|
76
gradlew.bat
vendored
76
gradlew.bat
vendored
|
@ -1,20 +1,4 @@
|
||||||
@rem
|
@if "%DEBUG%" == "" @echo off
|
||||||
@rem Copyright 2015 the original author or authors.
|
|
||||||
@rem
|
|
||||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
@rem you may not use this file except in compliance with the License.
|
|
||||||
@rem You may obtain a copy of the License at
|
|
||||||
@rem
|
|
||||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
@rem
|
|
||||||
@rem Unless required by applicable law or agreed to in writing, software
|
|
||||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
@rem See the License for the specific language governing permissions and
|
|
||||||
@rem limitations under the License.
|
|
||||||
@rem
|
|
||||||
|
|
||||||
@if "%DEBUG%"=="" @echo off
|
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
|
@ -25,29 +9,25 @@
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%"=="" set DIRNAME=.
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
@rem This is normally unused
|
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
|
||||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
set DEFAULT_JVM_OPTS=
|
||||||
|
|
||||||
@rem Find java.exe
|
@rem Find java.exe
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if %ERRORLEVEL% equ 0 goto execute
|
if "%ERRORLEVEL%" == "0" goto init
|
||||||
|
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
echo location of your Java installation. 1>&2
|
echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
|
@ -55,36 +35,48 @@ goto fail
|
||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
if exist "%JAVA_EXE%" goto init
|
||||||
|
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
echo location of your Java installation. 1>&2
|
echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
|
:init
|
||||||
|
@rem Get command-line arguments, handling Windows variants
|
||||||
|
|
||||||
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
|
|
||||||
|
:win9xME_args
|
||||||
|
@rem Slurp the command line arguments.
|
||||||
|
set CMD_LINE_ARGS=
|
||||||
|
set _SKIP=2
|
||||||
|
|
||||||
|
:win9xME_args_slurp
|
||||||
|
if "x%~1" == "x" goto execute
|
||||||
|
|
||||||
|
set CMD_LINE_ARGS=%*
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
set EXIT_CODE=%ERRORLEVEL%
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
exit /b 1
|
||||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
|
||||||
exit /b %EXIT_CODE%
|
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
|
@ -1,16 +1 @@
|
||||||
dependencyResolutionManagement {
|
rootProject.name = 'bibliographic-character-sets'
|
||||||
versionCatalogs {
|
|
||||||
libs {
|
|
||||||
version('gradle', '8.7')
|
|
||||||
}
|
|
||||||
testLibs {
|
|
||||||
version('junit', '5.10.3')
|
|
||||||
library('junit-jupiter-api', 'org.junit.jupiter', 'junit-jupiter-api').versionRef('junit')
|
|
||||||
library('junit-jupiter-params', 'org.junit.jupiter', 'junit-jupiter-params').versionRef('junit')
|
|
||||||
library('junit-jupiter-engine', 'org.junit.jupiter', 'junit-jupiter-engine').versionRef('junit')
|
|
||||||
library('junit-jupiter-platform-launcher', 'org.junit.platform', 'junit-platform-launcher').version('1.10.1')
|
|
||||||
library('junit4', 'junit', 'junit').version('4.13.2')
|
|
||||||
library('hamcrest', 'org.hamcrest', 'hamcrest-library').version('2.2')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
module org.xbib.charset {
|
|
||||||
exports org.xbib.charset;
|
|
||||||
requires java.xml; // for reading ansel mappings
|
|
||||||
provides java.nio.charset.spi.CharsetProvider with
|
|
||||||
org.xbib.charset.BibliographicCharsetProvider;
|
|
||||||
}
|
|
|
@ -43,27 +43,43 @@ import java.nio.charset.CoderResult;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.xml.stream.XMLStreamException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class AnselCharset extends Charset {
|
public class AnselCharset extends Charset {
|
||||||
|
|
||||||
private final Map<String, AnselCodeTableParser.CharacterSet> characterSetMap;
|
private static final Logger logger = Logger.getLogger(AnselCharset.class.getName());
|
||||||
|
|
||||||
private final Charset encodeCharset;
|
private static final Map<String, AnselCodeTableParser.CharacterSet> characterSetMap;
|
||||||
|
|
||||||
public AnselCharset() throws IOException {
|
static {
|
||||||
super("ANSEL", BibliographicCharsetProvider.aliasesFor("ANSEL"));
|
|
||||||
this.encodeCharset = StandardCharsets.UTF_8;
|
|
||||||
characterSetMap = new LinkedHashMap<>();
|
characterSetMap = new LinkedHashMap<>();
|
||||||
try (InputStream inputStream = AnselCharset.class.getResourceAsStream(("codetables.xml"))) {
|
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||||
|
try (InputStream inputStream = cl.getResource("org/xbib/charset/codetables.xml").openStream()) {
|
||||||
AnselCodeTableParser anselCodeTableParser = new AnselCodeTableParser(inputStream);
|
AnselCodeTableParser anselCodeTableParser = new AnselCodeTableParser(inputStream);
|
||||||
for (AnselCodeTableParser.CodeTable codeTable : anselCodeTableParser.getCodeTables()) {
|
for (AnselCodeTableParser.CodeTable codeTable : anselCodeTableParser.getCodeTables()) {
|
||||||
for (AnselCodeTableParser.CharacterSet characterSet : codeTable.getCharacterSets()) {
|
for (AnselCodeTableParser.CharacterSet characterSet : codeTable.getCharacterSets()) {
|
||||||
characterSetMap.put(characterSet.getName(), characterSet);
|
characterSetMap.put(characterSet.getName(), characterSet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// sonar wants logging
|
||||||
|
logger.log(Level.SEVERE, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Charset encodeCharset;
|
||||||
|
|
||||||
|
public AnselCharset() throws XMLStreamException {
|
||||||
|
super("ANSEL", BibliographicCharsetProvider.aliasesFor("ANSEL"));
|
||||||
|
this.encodeCharset = StandardCharsets.UTF_8;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Charset charset) {
|
public boolean contains(Charset charset) {
|
||||||
return charset instanceof AnselCharset;
|
return charset instanceof AnselCharset;
|
||||||
|
@ -79,17 +95,14 @@ public class AnselCharset extends Charset {
|
||||||
|
|
||||||
private static class Decoder extends CharsetDecoder {
|
private static class Decoder extends CharsetDecoder {
|
||||||
|
|
||||||
private String g0;
|
String g0;
|
||||||
|
String g1;
|
||||||
|
|
||||||
private String g1;
|
Decoder(Charset cs, CharsetDecoder baseDecoder) {
|
||||||
|
|
||||||
Decoder(AnselCharset cs, CharsetDecoder baseDecoder) {
|
|
||||||
super(cs, baseDecoder.averageCharsPerByte(), baseDecoder.maxCharsPerByte());
|
super(cs, baseDecoder.averageCharsPerByte(), baseDecoder.maxCharsPerByte());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected CoderResult decodeLoop(ByteBuffer in, CharBuffer out) {
|
protected CoderResult decodeLoop(ByteBuffer in, CharBuffer out) {
|
||||||
AnselCharset charset = (AnselCharset) charset();
|
|
||||||
g0 = "Basic Latin (ASCII)";
|
g0 = "Basic Latin (ASCII)";
|
||||||
g1 = "Extended Latin (ANSEL)";
|
g1 = "Extended Latin (ANSEL)";
|
||||||
CharArrayWriter w = new CharArrayWriter();
|
CharArrayWriter w = new CharArrayWriter();
|
||||||
|
@ -108,9 +121,8 @@ public class AnselCharset extends Charset {
|
||||||
return CoderResult.UNDERFLOW;
|
return CoderResult.UNDERFLOW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AnselCodeTableParser.CharacterSet characterSet = isG0(oldChar) ?
|
AnselCodeTableParser.CharacterSet characterSet = isG0(oldChar) ? characterSetMap.get(g0) :
|
||||||
charset.characterSetMap.get(g0) :
|
isG1(oldChar) ? characterSetMap.get(g1) : null;
|
||||||
isG1(oldChar) ? charset.characterSetMap.get(g1) : null;
|
|
||||||
int len = characterSet != null ? characterSet.getLength() : 1;
|
int len = characterSet != null ? characterSet.getLength() : 1;
|
||||||
String str = len == 1 ? "" + oldChar : "" + oldChar + (char) (in.get() & 0xFF) + (char) (in.get() & 0xFF);
|
String str = len == 1 ? "" + oldChar : "" + oldChar + (char) (in.get() & 0xFF) + (char) (in.get() & 0xFF);
|
||||||
AnselCodeTableParser.Code code = characterSet != null ? characterSet.getMarc().get(str) : null;
|
AnselCodeTableParser.Code code = characterSet != null ? characterSet.getMarc().get(str) : null;
|
||||||
|
@ -129,6 +141,8 @@ public class AnselCharset extends Charset {
|
||||||
try {
|
try {
|
||||||
w.write(diacritics.toCharArray());
|
w.write(diacritics.toCharArray());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
// sonar wants logging
|
||||||
|
logger.log(Level.SEVERE, e.getMessage(), e);
|
||||||
w.flush();
|
w.flush();
|
||||||
}
|
}
|
||||||
diacritics = new CharArrayWriter();
|
diacritics = new CharArrayWriter();
|
||||||
|
@ -244,14 +258,22 @@ public class AnselCharset extends Charset {
|
||||||
break;
|
break;
|
||||||
case '$':
|
case '$':
|
||||||
oneByte = in.get();
|
oneByte = in.get();
|
||||||
if (oneByte == '1') {
|
switch (oneByte) {
|
||||||
g0 = "Chinese, Japanese, Korean (EACC)";
|
case '1':
|
||||||
|
g0 = "Chinese, Japanese, Korean (EACC)";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '!':
|
case '!':
|
||||||
oneByte = in.get();
|
oneByte = in.get();
|
||||||
if (oneByte == 'E') {
|
switch (oneByte) {
|
||||||
g0 = "Extended Latin (ANSEL)";
|
case 'E':
|
||||||
|
g0 = "Extended Latin (ANSEL)";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -37,6 +37,8 @@ import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.xml.namespace.QName;
|
import javax.xml.namespace.QName;
|
||||||
import javax.xml.stream.XMLEventReader;
|
import javax.xml.stream.XMLEventReader;
|
||||||
|
@ -50,6 +52,8 @@ import javax.xml.stream.events.XMLEvent;
|
||||||
|
|
||||||
class AnselCodeTableParser {
|
class AnselCodeTableParser {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(AnselCodeTableParser.class.getName());
|
||||||
|
|
||||||
private final List<CodeTable> codeTables;
|
private final List<CodeTable> codeTables;
|
||||||
|
|
||||||
private CodeTable codeTable;
|
private CodeTable codeTable;
|
||||||
|
@ -65,6 +69,7 @@ class AnselCodeTableParser {
|
||||||
try {
|
try {
|
||||||
codeTables = createCodeTables(inputStream);
|
codeTables = createCodeTables(inputStream);
|
||||||
} catch (XMLStreamException e) {
|
} catch (XMLStreamException e) {
|
||||||
|
logger.log(Level.SEVERE, e.getMessage(), e);
|
||||||
codeTables = null;
|
codeTables = null;
|
||||||
}
|
}
|
||||||
this.codeTables = codeTables;
|
this.codeTables = codeTables;
|
||||||
|
|
|
@ -37,27 +37,26 @@ import java.nio.charset.spi.CharsetProvider;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extra bibliographic character sets.
|
* Extra bibliographic character sets.
|
||||||
*/
|
*/
|
||||||
public class BibliographicCharsetProvider extends CharsetProvider {
|
public class BibliographicCharsetProvider extends CharsetProvider {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(BibliographicCharsetProvider.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The reference to the character set instance.
|
* The reference to the character set instance.
|
||||||
* If there are no remaining references to this instance,
|
* If there are no remaining references to this instance,
|
||||||
* the character set will be removed by the garbage collector.
|
* the character set will be removed by the garbage collector.
|
||||||
*/
|
*/
|
||||||
private static final BibliographicCharsetProvider instance = new BibliographicCharsetProvider();
|
private static volatile BibliographicCharsetProvider instance = new BibliographicCharsetProvider();
|
||||||
|
|
||||||
private final Map<String, String> classMap;
|
private final Map<String, String> classMap;
|
||||||
|
|
||||||
private final Map<String, String> aliasMap;
|
private final Map<String, String> aliasMap;
|
||||||
|
|
||||||
private final Map<String, String[]> aliasNameMap;
|
private final Map<String, String[]> aliasNameMap;
|
||||||
|
|
||||||
private final Map<String, SoftReference<Charset>> cache;
|
private final Map<String, SoftReference<Charset>> cache;
|
||||||
|
|
||||||
private final String packagePrefix;
|
private final String packagePrefix;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,9 +96,9 @@ public class BibliographicCharsetProvider extends CharsetProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final Iterator<Charset> charsets() {
|
public final Iterator<Charset> charsets() {
|
||||||
return new Iterator<>() {
|
return new Iterator<Charset>() {
|
||||||
|
|
||||||
final Iterator<String> iterator = classMap.keySet().iterator();
|
Iterator<String> iterator = classMap.keySet().iterator();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
|
@ -145,11 +144,16 @@ public class BibliographicCharsetProvider extends CharsetProvider {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Class<?> cl = Class.forName(packagePrefix + "." + className, true, getClass().getClassLoader());
|
Class<?> cl = Class.forName(packagePrefix + "." + className, true, getClass().getClassLoader());
|
||||||
Charset charset = (Charset) cl.getDeclaredConstructor().newInstance();
|
Charset charset = (Charset) cl.newInstance();
|
||||||
cache.put(charsetName, new SoftReference<>(charset));
|
cache.put(charsetName, new SoftReference<>(charset));
|
||||||
return charset;
|
return charset;
|
||||||
} catch (Exception e) {
|
} catch (ClassNotFoundException e1) {
|
||||||
return null;
|
logger.log(Level.WARNING, "Class not found: " + packagePrefix + "." + className, e1);
|
||||||
|
} catch (IllegalAccessException e2) {
|
||||||
|
logger.log(Level.WARNING, "Illegal access: " + packagePrefix + "." + className, e2);
|
||||||
|
} catch (InstantiationException e3) {
|
||||||
|
logger.log(Level.WARNING, "Instantiation failed: " + packagePrefix + "." + className, e3);
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,11 +33,11 @@ package org.xbib.charset;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
public final class BibliographicCharsets {
|
public final class BibliographicCharsets {
|
||||||
|
|
||||||
private BibliographicCharsets() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Charset ANSEL = Charset.forName("ANSEL");
|
public static final Charset ANSEL = Charset.forName("ANSEL");
|
||||||
|
|
||||||
public static final Charset ISO5426 = Charset.forName("ISO-5426");
|
public static final Charset ISO5426 = Charset.forName("ISO-5426");
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/**
|
||||||
* Licensed to Jörg Prante and xbib under one or more contributor
|
* Licensed to Jörg Prante and xbib under one or more contributor
|
||||||
* license agreements. See the NOTICE.txt file distributed with this work
|
* license agreements. See the NOTICE.txt file distributed with this work
|
||||||
* for additional information regarding copyright ownership.
|
* for additional information regarding copyright ownership.
|
||||||
|
@ -29,6 +29,7 @@
|
||||||
* feasible for technical reasons, the Appropriate Legal Notices must display
|
* feasible for technical reasons, the Appropriate Legal Notices must display
|
||||||
* the words "Powered by xbib".
|
* the words "Powered by xbib".
|
||||||
*
|
*
|
||||||
|
*
|
||||||
* Derived from
|
* Derived from
|
||||||
*
|
*
|
||||||
* ByteCharset.java -- Abstract class for generic 1-byte encodings.
|
* ByteCharset.java -- Abstract class for generic 1-byte encodings.
|
||||||
|
@ -67,6 +68,7 @@
|
||||||
* this exception to your version of the library, but you are not
|
* this exception to your version of the library, but you are not
|
||||||
* obligated to do so. If you do not wish to do so, delete this
|
* obligated to do so. If you do not wish to do so, delete this
|
||||||
* exception statement from your version.
|
* exception statement from your version.
|
||||||
|
*//**
|
||||||
*
|
*
|
||||||
* Derived from
|
* Derived from
|
||||||
*
|
*
|
||||||
|
@ -155,7 +157,7 @@ abstract class ByteCharset extends Charset {
|
||||||
|
|
||||||
private static final class Decoder extends CharsetDecoder {
|
private static final class Decoder extends CharsetDecoder {
|
||||||
|
|
||||||
private final char[] lookup;
|
private char[] lookup;
|
||||||
|
|
||||||
Decoder(ByteCharset cs) {
|
Decoder(ByteCharset cs) {
|
||||||
super(cs, 1.0f, 1.0f);
|
super(cs, 1.0f, 1.0f);
|
||||||
|
@ -180,18 +182,19 @@ abstract class ByteCharset extends Charset {
|
||||||
|
|
||||||
private static final class Encoder extends CharsetEncoder {
|
private static final class Encoder extends CharsetEncoder {
|
||||||
|
|
||||||
private final byte[] lookup;
|
private byte[] lookup;
|
||||||
|
|
||||||
Encoder(ByteCharset cs) {
|
Encoder(ByteCharset cs) {
|
||||||
super(cs, 1.0f, 1.0f);
|
super(cs, 1.0f, 1.0f);
|
||||||
char[] lookuptable = cs.getLookupTable();
|
char[] lookuptable = cs.getLookupTable();
|
||||||
int max = 0;
|
int max = 0;
|
||||||
for (char ch : lookuptable) {
|
for (char ch : lookuptable) {
|
||||||
max = (int) ch > max && (int) ch < NONE ? (int) ch : max;
|
int c = (int) ch;
|
||||||
|
max = c > max && c < NONE ? c : max;
|
||||||
}
|
}
|
||||||
lookup = new byte[max + 1];
|
lookup = new byte[max + 1];
|
||||||
for (int i = 0; i < lookuptable.length; i++) {
|
for (int i = 0; i < lookuptable.length; i++) {
|
||||||
int c = lookuptable[i];
|
int c = (int) lookuptable[i];
|
||||||
if (c != 0 && c < NONE) {
|
if (c != 0 && c < NONE) {
|
||||||
lookup[c] = (byte) i;
|
lookup[c] = (byte) i;
|
||||||
}
|
}
|
||||||
|
@ -200,7 +203,7 @@ abstract class ByteCharset extends Charset {
|
||||||
|
|
||||||
protected CoderResult encodeLoop(CharBuffer in, ByteBuffer out) {
|
protected CoderResult encodeLoop(CharBuffer in, ByteBuffer out) {
|
||||||
while (in.hasRemaining()) {
|
while (in.hasRemaining()) {
|
||||||
int c = in.get();
|
int c = (int) in.get();
|
||||||
if (!out.hasRemaining()) {
|
if (!out.hasRemaining()) {
|
||||||
in.position(in.position() - 1);
|
in.position(in.position() - 1);
|
||||||
return CoderResult.OVERFLOW;
|
return CoderResult.OVERFLOW;
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class ISO5426 extends Charset {
|
||||||
|
|
||||||
private static final Map<Character, Byte> charToByteTable = newMabByteToCharMap();
|
private static final Map<Character, Byte> charToByteTable = newMabByteToCharMap();
|
||||||
|
|
||||||
private final boolean isNFCOutput;
|
private boolean isNFCOutput;
|
||||||
|
|
||||||
public ISO5426() {
|
public ISO5426() {
|
||||||
this(true);
|
this(true);
|
||||||
|
|
|
@ -53,7 +53,6 @@ import java.util.Map;
|
||||||
public class Pica extends Charset {
|
public class Pica extends Charset {
|
||||||
|
|
||||||
private static final Map<Character, Character> encodeMap = new HashMap<>();
|
private static final Map<Character, Character> encodeMap = new HashMap<>();
|
||||||
|
|
||||||
private static final Map<Character, Character> decodeMap = new HashMap<>();
|
private static final Map<Character, Character> decodeMap = new HashMap<>();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -63,7 +62,8 @@ public class Pica extends Charset {
|
||||||
* which are different from ISO-8859-1.
|
* which are different from ISO-8859-1.
|
||||||
*/
|
*/
|
||||||
static {
|
static {
|
||||||
Pica.charTable(new char[] {
|
Pica.charTable(encodeMap, decodeMap, '\u00a0', '\u00ff',
|
||||||
|
new char[]{
|
||||||
'\u00a0', '\u0141', '\u00d8', '\u0110', '\u00de', '\u00c6',
|
'\u00a0', '\u0141', '\u00d8', '\u0110', '\u00de', '\u00c6',
|
||||||
'\u0152', '\u02b9', '\u00b7', '\u266d', '\u00ae', '\u00b1',
|
'\u0152', '\u02b9', '\u00b7', '\u266d', '\u00ae', '\u00b1',
|
||||||
'\u01a0', '\u01af', '\u02be', '\u00c5', '\u02bf', '\u0142',
|
'\u01a0', '\u01af', '\u02be', '\u00c5', '\u02bf', '\u0142',
|
||||||
|
@ -86,7 +86,7 @@ public class Pica extends Charset {
|
||||||
// Handle to the real charset we'll use for transcoding between
|
// Handle to the real charset we'll use for transcoding between
|
||||||
// characters and bytes. Doing this allows applying the Pica
|
// characters and bytes. Doing this allows applying the Pica
|
||||||
// charset to multi-byte charset encodings like UTF-8.
|
// charset to multi-byte charset encodings like UTF-8.
|
||||||
private final Charset encodeCharset;
|
private Charset encodeCharset;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for the Pica charset. Call the superclass
|
* Constructor for the Pica charset. Call the superclass
|
||||||
|
@ -101,13 +101,16 @@ public class Pica extends Charset {
|
||||||
/**
|
/**
|
||||||
* Fill the conversion tables.
|
* Fill the conversion tables.
|
||||||
*/
|
*/
|
||||||
private static void charTable(char[] code) {
|
private static void charTable(Map<Character, Character> encodeMap, Map<Character, Character> decodeMap, char from, char to,
|
||||||
|
char[] code) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (char c = '\u00a0'; c <= '\u00ff'; c++) {
|
|
||||||
|
for (char c = from; c <= to; c++) {
|
||||||
if (code[i] != '\u0000') {
|
if (code[i] != '\u0000') {
|
||||||
encodeMap.put(code[i], c);
|
encodeMap.put(code[i], c);
|
||||||
decodeMap.put(c, code[i]);
|
decodeMap.put(c, code[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,7 +143,7 @@ public class Pica extends Charset {
|
||||||
|
|
||||||
private static class PicaEncoder extends CharsetEncoder {
|
private static class PicaEncoder extends CharsetEncoder {
|
||||||
|
|
||||||
private final CharsetEncoder baseEncoder;
|
private CharsetEncoder baseEncoder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor, call the superclass constructor with the
|
* Constructor, call the superclass constructor with the
|
||||||
|
@ -222,3 +225,4 @@ public class Pica extends Charset {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class PicaCharset extends Charset {
|
||||||
|
|
||||||
private static final Map<Character, Byte> CHAR_TO_BYTE_MAP = newCharToByteMap();
|
private static final Map<Character, Byte> CHAR_TO_BYTE_MAP = newCharToByteMap();
|
||||||
|
|
||||||
private final boolean isNFCOutput;
|
private boolean isNFCOutput;
|
||||||
|
|
||||||
public PicaCharset() {
|
public PicaCharset() {
|
||||||
this(true);
|
this(true);
|
||||||
|
@ -101,18 +101,10 @@ public class PicaCharset extends Charset {
|
||||||
map[0xAD] = '\u01AF';
|
map[0xAD] = '\u01AF';
|
||||||
/* Modifier letter apostrophe */
|
/* Modifier letter apostrophe */
|
||||||
map[0xAE] = '\u02BC';
|
map[0xAE] = '\u02BC';
|
||||||
|
|
||||||
// HTML SOURCE = '\u00b4' ?
|
|
||||||
// arab. ALIF? MODIFIER LETTER RIGHT HALF RING? '\u02be' ?
|
|
||||||
|
|
||||||
/* LATIN CAPITAL LETTER A WITH RING ABOVE */
|
/* LATIN CAPITAL LETTER A WITH RING ABOVE */
|
||||||
map[0xAF] = '\u00C5';
|
map[0xAF] = '\u00C5';
|
||||||
/* Modifier letter turned comma */
|
/* Modifier letter turned comma */
|
||||||
map[0xB0] = '\u02BB';
|
map[0xB0] = '\u02BB';
|
||||||
|
|
||||||
// HTML SOURCE = Grave accent?
|
|
||||||
// arab. AYN? MODIFIER LETTER LEFT HALF RING? U+02BF
|
|
||||||
|
|
||||||
/* Latin small letter l with stroke */
|
/* Latin small letter l with stroke */
|
||||||
map[0xB1] = '\u0142';
|
map[0xB1] = '\u0142';
|
||||||
/* Latin small letter o with stroke */
|
/* Latin small letter o with stroke */
|
||||||
|
|
|
@ -45,8 +45,9 @@ import java.nio.charset.StandardCharsets;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a simplified version of "ANSEL charset" at http://anselcharset.sourceforge.net/
|
* This is a simplified version of "ANSEL charset" at http://anselcharset.sourceforge.net/
|
||||||
|
@ -56,13 +57,11 @@ import java.util.TreeMap;
|
||||||
public class SimpleAnselCharset extends Charset {
|
public class SimpleAnselCharset extends Charset {
|
||||||
|
|
||||||
private final Map<Character, byte[]> mapping;
|
private final Map<Character, byte[]> mapping;
|
||||||
|
|
||||||
private final Map<Byte, ReverseMappingEntity> reverseMapping;
|
private final Map<Byte, ReverseMappingEntity> reverseMapping;
|
||||||
|
|
||||||
public SimpleAnselCharset() {
|
public SimpleAnselCharset() {
|
||||||
super("SIMPLE_ANSEL", BibliographicCharsetProvider.aliasesFor("SIMPLE_ANSEL"));
|
super("SIMPLE_ANSEL", BibliographicCharsetProvider.aliasesFor("SIMPLE_ANSEL"));
|
||||||
this.mapping = createMapping(getClass().getResourceAsStream("ansel-mapping.txt"));
|
mapping = createMapping(getClass().getResourceAsStream("ansel-mapping.txt"));
|
||||||
Objects.requireNonNull(this.mapping);
|
|
||||||
reverseMapping = createReverseMapping(mapping);
|
reverseMapping = createReverseMapping(mapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,30 +90,10 @@ public class SimpleAnselCharset extends Charset {
|
||||||
mapping.put(uniCode, ansCodes);
|
mapping.put(uniCode, ansCodes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mapping;
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return null;
|
Logger.getLogger(SimpleAnselCharset.class.getName()).log(Level.WARNING, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
return mapping;
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canEncode() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CharsetDecoder newDecoder() {
|
|
||||||
return new Decoder(this, reverseMapping);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CharsetEncoder newEncoder() {
|
|
||||||
return new Encoder(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean contains(Charset cs) {
|
|
||||||
return displayName().equals(cs.displayName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<Byte, ReverseMappingEntity> createReverseMapping(Map<Character, byte[]> mapping) {
|
private static Map<Byte, ReverseMappingEntity> createReverseMapping(Map<Character, byte[]> mapping) {
|
||||||
|
@ -139,10 +118,28 @@ public class SimpleAnselCharset extends Charset {
|
||||||
return rev;
|
return rev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canEncode() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CharsetDecoder newDecoder() {
|
||||||
|
return new Decoder(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CharsetEncoder newEncoder() {
|
||||||
|
return new Encoder(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean contains(Charset cs) {
|
||||||
|
return displayName().equals(cs.displayName());
|
||||||
|
}
|
||||||
|
|
||||||
private static class ReverseMappingEntity {
|
private static class ReverseMappingEntity {
|
||||||
|
private TreeMap<Byte, ReverseMappingEntity> mapping = new TreeMap<>();
|
||||||
private final TreeMap<Byte, ReverseMappingEntity> mapping = new TreeMap<>();
|
|
||||||
|
|
||||||
private Character character;
|
private Character character;
|
||||||
|
|
||||||
public Character getCharacter() {
|
public Character getCharacter() {
|
||||||
|
@ -158,15 +155,11 @@ public class SimpleAnselCharset extends Charset {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Decoder extends CharsetDecoder {
|
private class Decoder extends CharsetDecoder {
|
||||||
|
private LinkedList<Byte> buffer = new LinkedList<>();
|
||||||
|
|
||||||
private final Map<Byte, ReverseMappingEntity> reverseMapping;
|
Decoder(Charset charset) {
|
||||||
|
|
||||||
private final LinkedList<Byte> buffer = new LinkedList<>();
|
|
||||||
|
|
||||||
Decoder(Charset charset, Map<Byte, ReverseMappingEntity> reverseMapping) {
|
|
||||||
super(charset, 2.2f, 3.0f);
|
super(charset, 2.2f, 3.0f);
|
||||||
this.reverseMapping = reverseMapping;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -226,11 +219,9 @@ public class SimpleAnselCharset extends Charset {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract static class ReverseMappingBuffer {
|
abstract class ReverseMappingBuffer {
|
||||||
|
private Map<Byte, ReverseMappingEntity> rm;
|
||||||
private final Map<Byte, ReverseMappingEntity> rm;
|
private LinkedList<Byte> buffer;
|
||||||
|
|
||||||
private final LinkedList<Byte> buffer;
|
|
||||||
|
|
||||||
ReverseMappingBuffer(Map<Byte, ReverseMappingEntity> rm, LinkedList<Byte> buffer) {
|
ReverseMappingBuffer(Map<Byte, ReverseMappingEntity> rm, LinkedList<Byte> buffer) {
|
||||||
this.rm = rm;
|
this.rm = rm;
|
||||||
|
|
|
@ -31,23 +31,23 @@
|
||||||
*/
|
*/
|
||||||
package org.xbib.charset;
|
package org.xbib.charset;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import org.junit.Assert;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.CharBuffer;
|
import java.nio.CharBuffer;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.charset.CharsetDecoder;
|
import java.nio.charset.CharsetDecoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.text.Normalizer;
|
import java.text.Normalizer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class AnselCharsetTest {
|
public class AnselCharsetTest extends Assert {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAnsel() throws Exception {
|
public void testAnsel() throws Exception {
|
||||||
ByteBuffer buf = ByteBuffer.wrap("\u00e8\u0075".getBytes(StandardCharsets.ISO_8859_1));
|
ByteBuffer buf = ByteBuffer.wrap("\u00e8\u0075".getBytes("ISO-8859-1"));
|
||||||
Charset charset = Charset.forName("ANSEL");
|
Charset charset = Charset.forName("ANSEL");
|
||||||
CharsetDecoder decoder = charset.newDecoder();
|
CharsetDecoder decoder = charset.newDecoder();
|
||||||
CharBuffer cbuf = decoder.decode(buf);
|
CharBuffer cbuf = decoder.decode(buf);
|
||||||
|
@ -59,8 +59,7 @@ public class AnselCharsetTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAnsel2() throws Exception {
|
public void testAnsel2() throws Exception {
|
||||||
ByteBuffer buf =
|
ByteBuffer buf = ByteBuffer.wrap("\u00AC\u00E2\u0041\u00ED\u0042\u00E2\u0043\u00E2\u0044".getBytes("ISO-8859-1"));
|
||||||
ByteBuffer.wrap("\u00AC\u00E2\u0041\u00ED\u0042\u00E2\u0043\u00E2\u0044".getBytes(StandardCharsets.ISO_8859_1));
|
|
||||||
Charset charset = Charset.forName("ANSEL");
|
Charset charset = Charset.forName("ANSEL");
|
||||||
CharsetDecoder decoder = charset.newDecoder();
|
CharsetDecoder decoder = charset.newDecoder();
|
||||||
CharBuffer cbuf = decoder.decode(buf);
|
CharBuffer cbuf = decoder.decode(buf);
|
||||||
|
|
|
@ -31,8 +31,10 @@
|
||||||
*/
|
*/
|
||||||
package org.xbib.charset;
|
package org.xbib.charset;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import java.util.logging.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
import javax.xml.stream.XMLStreamException;
|
import javax.xml.stream.XMLStreamException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,12 +42,14 @@ import javax.xml.stream.XMLStreamException;
|
||||||
*/
|
*/
|
||||||
public class AnselCodeTableParserTest {
|
public class AnselCodeTableParserTest {
|
||||||
|
|
||||||
|
private Logger logger = LogManager.getLogger(AnselCodeTableParserTest.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() throws XMLStreamException {
|
public void test() throws XMLStreamException {
|
||||||
AnselCodeTableParser anselCodeTableParser = new AnselCodeTableParser(getClass().getResourceAsStream("codetables.xml"));
|
AnselCodeTableParser anselCodeTableParser = new AnselCodeTableParser(getClass().getResourceAsStream("codetables.xml"));
|
||||||
for (AnselCodeTableParser.CodeTable codeTable : anselCodeTableParser.getCodeTables()) {
|
for (AnselCodeTableParser.CodeTable codeTable : anselCodeTableParser.getCodeTables()) {
|
||||||
for (AnselCodeTableParser.CharacterSet characterSet : codeTable.getCharacterSets()) {
|
for (AnselCodeTableParser.CharacterSet characterSet : codeTable.getCharacterSets()) {
|
||||||
Logger.getLogger(AnselCodeTableParserTest.class.getName()).info(characterSet.getName() + " " + characterSet.getLength());
|
logger.info("{} {}", characterSet.getName(), characterSet.getLength());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,10 @@
|
||||||
*/
|
*/
|
||||||
package org.xbib.charset;
|
package org.xbib.charset;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
|
|
@ -31,9 +31,9 @@
|
||||||
*/
|
*/
|
||||||
package org.xbib.charset;
|
package org.xbib.charset;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import org.junit.Assert;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import org.junit.Test;
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.CharBuffer;
|
import java.nio.CharBuffer;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
@ -44,12 +44,12 @@ import java.util.SortedMap;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ISO5426Test {
|
public class ISO5426Test extends Assert {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void listCharsets() throws Exception {
|
public void listCharsets() throws Exception {
|
||||||
SortedMap<String, Charset> map = Charset.availableCharsets();
|
SortedMap<String, Charset> map = Charset.availableCharsets();
|
||||||
assertTrue(map.containsKey("ISO-5426"));
|
assertTrue(map.keySet().contains("ISO-5426"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -81,4 +81,5 @@ public class ISO5426Test {
|
||||||
String output = cbuf.toString();
|
String output = cbuf.toString();
|
||||||
assertEquals(output, "£");
|
assertEquals(output, "£");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,20 +31,20 @@
|
||||||
*/
|
*/
|
||||||
package org.xbib.charset;
|
package org.xbib.charset;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import org.junit.Assert;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.Test;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.text.Normalizer;
|
import java.text.Normalizer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class NormalizerTest {
|
public class NormalizerTest extends Assert {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNormalizer() {
|
public void testNormalizer() throws Exception {
|
||||||
byte[] b = new byte[]{(byte) 103, (byte) 101, (byte) 109, (byte) 97, (byte) 204, (byte) 136, (byte) 195, (byte) 159};
|
byte[] b = new byte[]{(byte) 103, (byte) 101, (byte) 109, (byte) 97, (byte) 204, (byte) 136, (byte) 195, (byte) 159};
|
||||||
String input = new String(b, StandardCharsets.UTF_8);
|
String input = new String(b, "UTF-8");
|
||||||
String norm = Normalizer.normalize(input, Normalizer.Form.NFC);
|
String norm = Normalizer.normalize(input, Normalizer.Form.NFC);
|
||||||
assertEquals("gemäß", norm);
|
assertEquals("gemäß", norm);
|
||||||
}
|
}
|
||||||
|
@ -56,4 +56,5 @@ public class NormalizerTest {
|
||||||
String norm = Normalizer.normalize(s, Normalizer.Form.NFC);
|
String norm = Normalizer.normalize(s, Normalizer.Form.NFC);
|
||||||
assertEquals(56, norm.length());
|
assertEquals(56, norm.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,34 +31,34 @@
|
||||||
*/
|
*/
|
||||||
package org.xbib.charset;
|
package org.xbib.charset;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import org.junit.Assert;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import org.junit.Test;
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.CharBuffer;
|
import java.nio.CharBuffer;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.charset.CharsetDecoder;
|
import java.nio.charset.CharsetDecoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SimpleAnselCharsetTest {
|
public class SimpleAnselCharsetTest extends Assert {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void listCharsets() {
|
public void listCharsets() throws Exception {
|
||||||
SortedMap<String, Charset> map = Charset.availableCharsets();
|
SortedMap<String, Charset> map = Charset.availableCharsets();
|
||||||
assertTrue(map.containsKey("SIMPLE_ANSEL"));
|
assertTrue(map.keySet().contains("SIMPLE_ANSEL"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSimpleAnsel() throws Exception {
|
public void testSimpleAnsel() throws Exception {
|
||||||
ByteBuffer buf = ByteBuffer.wrap("\u00e8\u0075".getBytes(StandardCharsets.ISO_8859_1));
|
ByteBuffer buf = ByteBuffer.wrap("\u00e8\u0075".getBytes("ISO-8859-1"));
|
||||||
Charset charset = Charset.forName("SIMPLE_ANSEL");
|
Charset charset = Charset.forName("SIMPLE_ANSEL");
|
||||||
CharsetDecoder decoder = charset.newDecoder();
|
CharsetDecoder decoder = charset.newDecoder();
|
||||||
CharBuffer cbuf = decoder.decode(buf);
|
CharBuffer cbuf = decoder.decode(buf);
|
||||||
String output = cbuf.toString();
|
String output = cbuf.toString();
|
||||||
assertEquals("\u00fc", output);
|
assertEquals("\u00fc", output);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
13
src/test/resources/log4j2.xml
Normal file
13
src/test/resources/log4j2.xml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration status="OFF">
|
||||||
|
<appenders>
|
||||||
|
<Console name="Console" target="SYSTEM_OUT">
|
||||||
|
<PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%-25c][%t] %m%n"/>
|
||||||
|
</Console>
|
||||||
|
</appenders>
|
||||||
|
<Loggers>
|
||||||
|
<Root level="info">
|
||||||
|
<AppenderRef ref="Console" />
|
||||||
|
</Root>
|
||||||
|
</Loggers>
|
||||||
|
</configuration>
|
|
@ -1,6 +0,0 @@
|
||||||
handlers=java.util.logging.ConsoleHandler
|
|
||||||
.level=ALL
|
|
||||||
java.util.logging.SimpleFormatter.format=%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS.%1$tL %4$-7s [%3$s] %5$s %6$s%n
|
|
||||||
java.util.logging.ConsoleHandler.level=ALL
|
|
||||||
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
|
|
||||||
jdk.event.security.level=INFO
|
|
Loading…
Reference in a new issue