Compare commits
10 commits
1f8c84a5e1
...
7062a13338
Author | SHA1 | Date | |
---|---|---|---|
7062a13338 | |||
684cbf62a5 | |||
6f7d768601 | |||
89354c7bcc | |||
0f251114a3 | |||
ff3d3b5535 | |||
28650e723e | |||
7c527ea4ec | |||
40e6051a40 | |||
53fbabba47 |
39 changed files with 213 additions and 10935 deletions
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
* linguist-vendored
|
||||||
|
*.java linguist-vendored=false
|
36
build.gradle
vendored
36
build.gradle
vendored
|
@ -1,11 +1,10 @@
|
||||||
plugins {
|
plugins {
|
||||||
id "de.marcphilipp.nexus-publish" version "0.4.0"
|
|
||||||
id "io.codearte.nexus-staging" version "0.21.1"
|
|
||||||
id "org.xbib.gradle.plugin.asciidoctor" version "2.5.2.2"
|
|
||||||
id "org.cyclonedx.bom" version "1.7.2"
|
|
||||||
id "com.github.spotbugs" version "5.0.13"
|
|
||||||
id "checkstyle"
|
|
||||||
id "pmd"
|
id "pmd"
|
||||||
|
id 'maven-publish'
|
||||||
|
id 'signing'
|
||||||
|
id "io.github.gradle-nexus.publish-plugin" version "2.0.0-rc-1"
|
||||||
|
id "org.cyclonedx.bom" version "1.7.4"
|
||||||
|
id "org.xbib.gradle.plugin.asciidoctor" version "3.0.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
wrapper {
|
wrapper {
|
||||||
|
@ -18,9 +17,9 @@ ext {
|
||||||
name = 'marc'
|
name = 'marc'
|
||||||
description = 'MARC bibliographic data processing library for Java'
|
description = 'MARC bibliographic data processing library for Java'
|
||||||
inceptionYear = '2016'
|
inceptionYear = '2016'
|
||||||
url = 'https://github.com/' + user + '/' + name
|
url = 'https://xbib.org/' + user + '/' + name
|
||||||
scmUrl = 'https://github.com/' + user + '/' + name
|
scmUrl = 'https://xbib.org/' + user + '/' + name
|
||||||
scmConnection = 'scm:git:git://github.com/' + user + '/' + name + '.git'
|
scmConnection = 'scm:git:git://xbib.org/' + user + '/' + name + '.git'
|
||||||
scmDeveloperConnection = 'scm:git:ssh://git@github.com:' + user + '/' + name + '.git'
|
scmDeveloperConnection = 'scm:git:ssh://git@github.com:' + user + '/' + name + '.git'
|
||||||
issueManagementSystem = 'Github'
|
issueManagementSystem = 'Github'
|
||||||
issueManagementUrl = ext.scmUrl + '/issues'
|
issueManagementUrl = ext.scmUrl + '/issues'
|
||||||
|
@ -31,22 +30,21 @@ ext {
|
||||||
apply plugin: 'java-library'
|
apply plugin: 'java-library'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testImplementation libs.charactersets
|
testImplementation testLibs.charactersets
|
||||||
testImplementation libs.json
|
testImplementation testLibs.json
|
||||||
testImplementation libs.xalan
|
testImplementation testLibs.xalan
|
||||||
testImplementation libs.xmlunit
|
testImplementation testLibs.xmlunit
|
||||||
testImplementation(libs.mockito) {
|
testImplementation(testLibs.mockito) {
|
||||||
exclude group: 'org.hamcrest'
|
exclude group: 'org.hamcrest'
|
||||||
}
|
}
|
||||||
testImplementation libs.marc4j
|
testImplementation testLibs.marc4j
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: rootProject.file('gradle/ide/idea.gradle')
|
|
||||||
apply from: rootProject.file('gradle/compile/java.gradle')
|
apply from: rootProject.file('gradle/compile/java.gradle')
|
||||||
apply from: rootProject.file('gradle/test/junit5.gradle')
|
apply from: rootProject.file('gradle/test/junit5.gradle')
|
||||||
apply from: rootProject.file('gradle/repositories/maven.gradle')
|
apply from: rootProject.file('gradle/repositories/maven.gradle')
|
||||||
apply from: rootProject.file('gradle/publishing/publication.gradle')
|
|
||||||
apply from: rootProject.file('gradle/quality/cyclonedx.gradle')
|
apply from: rootProject.file('gradle/quality/cyclonedx.gradle')
|
||||||
apply from: rootProject.file('gradle/quality/spotbugs.gradle')
|
|
||||||
apply from: rootProject.file('gradle/quality/checkstyle.gradle')
|
|
||||||
apply from: rootProject.file('gradle/quality/pmd.gradle')
|
apply from: rootProject.file('gradle/quality/pmd.gradle')
|
||||||
|
apply from: rootProject.file('gradle/publish/maven.gradle')
|
||||||
|
apply from: rootProject.file('gradle/publish/sonatype.gradle')
|
||||||
|
apply from: rootProject.file('gradle/publish/forgejo.gradle')
|
||||||
|
|
323
config/checkstyle/checkstyle.xml
vendored
323
config/checkstyle/checkstyle.xml
vendored
|
@ -1,323 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE module PUBLIC
|
|
||||||
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
|
||||||
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
|
||||||
|
|
||||||
<!-- This is a checkstyle configuration file. For descriptions of
|
|
||||||
what the following rules do, please see the checkstyle configuration
|
|
||||||
page at http://checkstyle.sourceforge.net/config.html -->
|
|
||||||
|
|
||||||
<module name="Checker">
|
|
||||||
|
|
||||||
<module name="FileTabCharacter">
|
|
||||||
<!-- Checks that there are no tab characters in the file.
|
|
||||||
-->
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<module name="NewlineAtEndOfFile">
|
|
||||||
<property name="lineSeparator" value="lf"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<module name="RegexpSingleline">
|
|
||||||
<!-- Checks that FIXME is not used in comments. TODO is preferred.
|
|
||||||
-->
|
|
||||||
<property name="format" value="((//.*)|(\*.*))FIXME" />
|
|
||||||
<property name="message" value='TODO is preferred to FIXME. e.g. "TODO(johndoe): Refactor when v2 is released."' />
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<module name="RegexpSingleline">
|
|
||||||
<!-- Checks that TODOs are named. (Actually, just that they are followed
|
|
||||||
by an open paren.)
|
|
||||||
-->
|
|
||||||
<property name="format" value="((//.*)|(\*.*))TODO[^(]" />
|
|
||||||
<property name="message" value='All TODOs should be named. e.g. "TODO(johndoe): Refactor when v2 is released."' />
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<module name="JavadocPackage">
|
|
||||||
<!-- Checks that each Java package has a Javadoc file used for commenting.
|
|
||||||
Only allows a package-info.java, not package.html. -->
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<!-- All Java AST specific tests live under TreeWalker module. -->
|
|
||||||
<module name="TreeWalker">
|
|
||||||
|
|
||||||
<!--
|
|
||||||
|
|
||||||
IMPORT CHECKS
|
|
||||||
|
|
||||||
-->
|
|
||||||
|
|
||||||
<module name="RedundantImport">
|
|
||||||
<!-- Checks for redundant import statements. -->
|
|
||||||
<property name="severity" value="error"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<module name="ImportOrder">
|
|
||||||
<!-- Checks for out of order import statements. -->
|
|
||||||
|
|
||||||
<property name="severity" value="warning"/>
|
|
||||||
<property name="groups" value="com,junit,net,org,java,javax"/>
|
|
||||||
<!-- This ensures that static imports go first. -->
|
|
||||||
<property name="option" value="top"/>
|
|
||||||
<property name="tokens" value="STATIC_IMPORT, IMPORT"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
|
|
||||||
JAVADOC CHECKS
|
|
||||||
|
|
||||||
-->
|
|
||||||
|
|
||||||
<!-- Checks for Javadoc comments. -->
|
|
||||||
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
|
|
||||||
<module name="JavadocMethod">
|
|
||||||
<property name="scope" value="protected"/>
|
|
||||||
<property name="severity" value="warning"/>
|
|
||||||
<property name="allowMissingJavadoc" value="true"/>
|
|
||||||
<property name="allowMissingParamTags" value="true"/>
|
|
||||||
<property name="allowMissingReturnTag" value="true"/>
|
|
||||||
<property name="allowMissingThrowsTags" value="true"/>
|
|
||||||
<property name="allowThrowsTagsForSubclasses" value="true"/>
|
|
||||||
<property name="allowUndeclaredRTE" value="true"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<module name="JavadocType">
|
|
||||||
<property name="scope" value="protected"/>
|
|
||||||
<property name="severity" value="error"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<module name="JavadocStyle">
|
|
||||||
<property name="severity" value="warning"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
|
|
||||||
NAMING CHECKS
|
|
||||||
|
|
||||||
-->
|
|
||||||
|
|
||||||
<!-- Item 38 - Adhere to generally accepted naming conventions -->
|
|
||||||
|
|
||||||
<module name="PackageName">
|
|
||||||
<!-- Validates identifiers for package names against the
|
|
||||||
supplied expression. -->
|
|
||||||
<!-- Here the default checkstyle rule restricts package name parts to
|
|
||||||
seven characters, this is not in line with common practice at Google.
|
|
||||||
-->
|
|
||||||
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]{1,})*$"/>
|
|
||||||
<property name="severity" value="warning"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<module name="TypeNameCheck">
|
|
||||||
<!-- Validates static, final fields against the
|
|
||||||
expression "^[A-Z][a-zA-Z0-9]*$". -->
|
|
||||||
<metadata name="altname" value="TypeName"/>
|
|
||||||
<property name="severity" value="warning"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<module name="ConstantNameCheck">
|
|
||||||
<!-- Validates non-private, static, final fields against the supplied
|
|
||||||
public/package final fields "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$". -->
|
|
||||||
<metadata name="altname" value="ConstantName"/>
|
|
||||||
<property name="applyToPublic" value="true"/>
|
|
||||||
<property name="applyToProtected" value="true"/>
|
|
||||||
<property name="applyToPackage" value="true"/>
|
|
||||||
<property name="applyToPrivate" value="false"/>
|
|
||||||
<property name="format" value="^([A-Z][A-Z0-9]*(_[A-Z0-9]+)*|FLAG_.*)$"/>
|
|
||||||
<message key="name.invalidPattern"
|
|
||||||
value="Variable ''{0}'' should be in ALL_CAPS (if it is a constant) or be private (otherwise)."/>
|
|
||||||
<property name="severity" value="warning"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<module name="StaticVariableNameCheck">
|
|
||||||
<!-- Validates static, non-final fields against the supplied
|
|
||||||
expression "^[a-z][a-zA-Z0-9]*_?$". -->
|
|
||||||
<metadata name="altname" value="StaticVariableName"/>
|
|
||||||
<property name="applyToPublic" value="true"/>
|
|
||||||
<property name="applyToProtected" value="true"/>
|
|
||||||
<property name="applyToPackage" value="true"/>
|
|
||||||
<property name="applyToPrivate" value="true"/>
|
|
||||||
<property name="format" value="^[a-z][a-zA-Z0-9]*_?$"/>
|
|
||||||
<property name="severity" value="warning"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<module name="MemberNameCheck">
|
|
||||||
<!-- Validates non-static members against the supplied expression. -->
|
|
||||||
<metadata name="altname" value="MemberName"/>
|
|
||||||
<property name="applyToPublic" value="true"/>
|
|
||||||
<property name="applyToProtected" value="true"/>
|
|
||||||
<property name="applyToPackage" value="true"/>
|
|
||||||
<property name="applyToPrivate" value="true"/>
|
|
||||||
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
|
|
||||||
<property name="severity" value="warning"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<module name="MethodNameCheck">
|
|
||||||
<!-- Validates identifiers for method names. -->
|
|
||||||
<metadata name="altname" value="MethodName"/>
|
|
||||||
<property name="format" value="^[a-z][a-zA-Z0-9]*(_[a-zA-Z0-9]+)*$"/>
|
|
||||||
<property name="severity" value="warning"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<module name="ParameterName">
|
|
||||||
<!-- Validates identifiers for method parameters against the
|
|
||||||
expression "^[a-z][a-zA-Z0-9]*$". -->
|
|
||||||
<property name="severity" value="warning"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<module name="LocalFinalVariableName">
|
|
||||||
<!-- Validates identifiers for local final variables against the
|
|
||||||
expression "^[a-z][a-zA-Z0-9]*$". -->
|
|
||||||
<property name="severity" value="warning"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<module name="LocalVariableName">
|
|
||||||
<!-- Validates identifiers for local variables against the
|
|
||||||
expression "^[a-z][a-zA-Z0-9]*$". -->
|
|
||||||
<property name="severity" value="warning"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
|
|
||||||
<!--
|
|
||||||
|
|
||||||
LENGTH and CODING CHECKS
|
|
||||||
|
|
||||||
-->
|
|
||||||
|
|
||||||
<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">
|
|
||||||
<!-- Checks for placement of the left curly brace ('{'). -->
|
|
||||||
<property name="severity" value="warning"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<module name="RightCurly">
|
|
||||||
<!-- Checks right curlies on CATCH, ELSE, and TRY blocks are on
|
|
||||||
the same line. e.g., the following example is fine:
|
|
||||||
<pre>
|
|
||||||
if {
|
|
||||||
...
|
|
||||||
} else
|
|
||||||
</pre>
|
|
||||||
-->
|
|
||||||
<!-- This next example is not fine:
|
|
||||||
<pre>
|
|
||||||
if {
|
|
||||||
...
|
|
||||||
}
|
|
||||||
else
|
|
||||||
</pre>
|
|
||||||
-->
|
|
||||||
<property name="option" value="same"/>
|
|
||||||
<property name="severity" value="warning"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<!-- Checks for braces around if and else blocks -->
|
|
||||||
<module name="NeedBraces">
|
|
||||||
<property name="severity" value="warning"/>
|
|
||||||
<property name="tokens" value="LITERAL_IF, LITERAL_ELSE, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<module name="UpperEll">
|
|
||||||
<!-- Checks that long constants are defined with an upper ell.-->
|
|
||||||
<property name="severity" value="error"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<module name="FallThrough">
|
|
||||||
<!-- Warn about falling through to the next case statement. Similar to
|
|
||||||
javac -Xlint:fallthrough, but the check is suppressed if a single-line comment
|
|
||||||
on the last non-blank line preceding the fallen-into case contains 'fall through' (or
|
|
||||||
some other variants which we don't publicized to promote consistency).
|
|
||||||
-->
|
|
||||||
<property name="reliefPattern"
|
|
||||||
value="fall through|Fall through|fallthru|Fallthru|falls through|Falls through|fallthrough|Fallthrough|No break|NO break|no break|continue on"/>
|
|
||||||
<property name="severity" value="error"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
|
|
||||||
<!--
|
|
||||||
|
|
||||||
MODIFIERS CHECKS
|
|
||||||
|
|
||||||
-->
|
|
||||||
|
|
||||||
<module name="ModifierOrder">
|
|
||||||
<!-- Warn if modifier order is inconsistent with JLS3 8.1.1, 8.3.1, and
|
|
||||||
8.4.3. The prescribed order is:
|
|
||||||
public, protected, private, abstract, static, final, transient, volatile,
|
|
||||||
synchronized, native, strictfp
|
|
||||||
-->
|
|
||||||
</module>
|
|
||||||
|
|
||||||
|
|
||||||
<!--
|
|
||||||
|
|
||||||
WHITESPACE CHECKS
|
|
||||||
|
|
||||||
-->
|
|
||||||
|
|
||||||
<module name="WhitespaceAround">
|
|
||||||
<!-- Checks that various tokens are surrounded by whitespace.
|
|
||||||
This includes most binary operators and keywords followed
|
|
||||||
by regular or curly braces.
|
|
||||||
-->
|
|
||||||
<property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR,
|
|
||||||
BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN,
|
|
||||||
EQUAL, GE, GT, LAND, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
|
|
||||||
LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
|
|
||||||
LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS,
|
|
||||||
MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION,
|
|
||||||
SL, SL_ASSIGN, SR_ASSIGN, STAR, STAR_ASSIGN"/>
|
|
||||||
<property name="severity" value="error"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<module name="WhitespaceAfter">
|
|
||||||
<!-- Checks that commas, semicolons and typecasts are followed by
|
|
||||||
whitespace.
|
|
||||||
-->
|
|
||||||
<property name="tokens" value="COMMA, SEMI, TYPECAST"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<module name="NoWhitespaceAfter">
|
|
||||||
<!-- Checks that there is no whitespace after various unary operators.
|
|
||||||
Linebreaks are allowed.
|
|
||||||
-->
|
|
||||||
<property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS,
|
|
||||||
UNARY_PLUS"/>
|
|
||||||
<property name="allowLineBreaks" value="true"/>
|
|
||||||
<property name="severity" value="error"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<module name="NoWhitespaceBefore">
|
|
||||||
<!-- Checks that there is no whitespace before various unary operators.
|
|
||||||
Linebreaks are allowed.
|
|
||||||
-->
|
|
||||||
<property name="tokens" value="SEMI, DOT, POST_DEC, POST_INC"/>
|
|
||||||
<property name="allowLineBreaks" value="true"/>
|
|
||||||
<property name="severity" value="error"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
<module name="ParenPad">
|
|
||||||
<!-- Checks that there is no whitespace before close parens or after
|
|
||||||
open parens.
|
|
||||||
-->
|
|
||||||
<property name="severity" value="warning"/>
|
|
||||||
</module>
|
|
||||||
|
|
||||||
</module>
|
|
||||||
</module>
|
|
||||||
|
|
7
config/checkstyle/suppressions.xml
vendored
7
config/checkstyle/suppressions.xml
vendored
|
@ -1,7 +0,0 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
<!DOCTYPE suppressions PUBLIC
|
|
||||||
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
|
|
||||||
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
|
|
||||||
<suppressions>
|
|
||||||
<suppress checks="." files="[\\/]generated-src[\\/].*\.java$"/>
|
|
||||||
</suppressions>
|
|
1636
config/pmd/category/java/bestpractices.xml
vendored
1636
config/pmd/category/java/bestpractices.xml
vendored
File diff suppressed because it is too large
Load diff
13
config/pmd/category/java/categories.properties
vendored
13
config/pmd/category/java/categories.properties
vendored
|
@ -1,13 +0,0 @@
|
||||||
#
|
|
||||||
# BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
|
||||||
#
|
|
||||||
|
|
||||||
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
|
|
2176
config/pmd/category/java/codestyle.xml
vendored
2176
config/pmd/category/java/codestyle.xml
vendored
File diff suppressed because it is too large
Load diff
1657
config/pmd/category/java/design.xml
vendored
1657
config/pmd/category/java/design.xml
vendored
File diff suppressed because it is too large
Load diff
144
config/pmd/category/java/documentation.xml
vendored
144
config/pmd/category/java/documentation.xml
vendored
|
@ -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>
|
|
3383
config/pmd/category/java/errorprone.xml
vendored
3383
config/pmd/category/java/errorprone.xml
vendored
File diff suppressed because it is too large
Load diff
393
config/pmd/category/java/multithreading.xml
vendored
393
config/pmd/category/java/multithreading.xml
vendored
|
@ -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>
|
|
1006
config/pmd/category/java/performance.xml
vendored
1006
config/pmd/category/java/performance.xml
vendored
File diff suppressed because it is too large
Load diff
65
config/pmd/category/java/security.xml
vendored
65
config/pmd/category/java/security.xml
vendored
|
@ -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>
|
|
2
gradle.properties
vendored
2
gradle.properties
vendored
|
@ -1,5 +1,5 @@
|
||||||
group = org.xbib
|
group = org.xbib
|
||||||
name = marc
|
name = marc
|
||||||
version = 2.9.21
|
version = 2.14.1
|
||||||
|
|
||||||
org.gradle.warning.mode = ALL
|
org.gradle.warning.mode = ALL
|
||||||
|
|
33
gradle/compile/java.gradle
vendored
33
gradle/compile/java.gradle
vendored
|
@ -2,17 +2,12 @@
|
||||||
apply plugin: 'java-library'
|
apply plugin: 'java-library'
|
||||||
|
|
||||||
java {
|
java {
|
||||||
|
toolchain {
|
||||||
|
languageVersion = JavaLanguageVersion.of(21)
|
||||||
|
}
|
||||||
modularity.inferModulePath.set(true)
|
modularity.inferModulePath.set(true)
|
||||||
}
|
withSourcesJar()
|
||||||
|
withJavadocJar()
|
||||||
compileJava {
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_17
|
|
||||||
targetCompatibility = JavaVersion.VERSION_17
|
|
||||||
}
|
|
||||||
|
|
||||||
compileTestJava {
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_17
|
|
||||||
targetCompatibility = JavaVersion.VERSION_17
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
|
@ -21,23 +16,9 @@ jar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
|
||||||
dependsOn classes
|
|
||||||
classifier 'sources'
|
|
||||||
from sourceSets.main.allSource
|
|
||||||
}
|
|
||||||
|
|
||||||
task javadocJar(type: Jar, dependsOn: javadoc) {
|
|
||||||
dependsOn javadoc
|
|
||||||
classifier 'javadoc'
|
|
||||||
from javadoc.destinationDir
|
|
||||||
}
|
|
||||||
|
|
||||||
artifacts {
|
|
||||||
archives sourcesJar, javadocJar
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile) {
|
||||||
|
options.fork = true
|
||||||
|
options.forkOptions.jvmArgs += ['-Duser.language=en','-Duser.country=US']
|
||||||
options.compilerArgs << '-Xlint:all'
|
options.compilerArgs << '-Xlint:all'
|
||||||
options.encoding = 'UTF-8'
|
options.encoding = 'UTF-8'
|
||||||
}
|
}
|
||||||
|
|
16
gradle/publish/forgejo.gradle
vendored
Normal file
16
gradle/publish/forgejo.gradle
vendored
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
27
gradle/publish/ivy.gradle
vendored
Normal file
27
gradle/publish/ivy.gradle
vendored
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
apply plugin: 'ivy-publish'
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
repositories {
|
||||||
|
ivy {
|
||||||
|
url = "https://xbib.org/repo"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
publications {
|
||||||
|
ivy(IvyPublication) {
|
||||||
|
from components.java
|
||||||
|
descriptor {
|
||||||
|
license {
|
||||||
|
name = 'The Apache License, Version 2.0'
|
||||||
|
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
||||||
|
}
|
||||||
|
author {
|
||||||
|
name = 'Jörg Prante'
|
||||||
|
url = 'http://example.com/users/jane'
|
||||||
|
}
|
||||||
|
descriptor.description {
|
||||||
|
text = rootProject.ext.description
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +1,10 @@
|
||||||
|
|
||||||
apply plugin: "de.marcphilipp.nexus-publish"
|
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
mavenJava(MavenPublication) {
|
"${project.name}"(MavenPublication) {
|
||||||
from components.java
|
from components.java
|
||||||
artifact sourcesJar
|
|
||||||
artifact javadocJar
|
|
||||||
pom {
|
pom {
|
||||||
|
artifactId = project.name
|
||||||
name = project.name
|
name = project.name
|
||||||
description = rootProject.ext.description
|
description = rootProject.ext.description
|
||||||
url = rootProject.ext.url
|
url = rootProject.ext.url
|
||||||
|
@ -22,7 +19,7 @@ publishing {
|
||||||
id = 'jprante'
|
id = 'jprante'
|
||||||
name = 'Jörg Prante'
|
name = 'Jörg Prante'
|
||||||
email = 'joergprante@gmail.com'
|
email = 'joergprante@gmail.com'
|
||||||
url = 'https://github.com/jprante'
|
url = 'https://xbib.org/joerg'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scm {
|
scm {
|
||||||
|
@ -49,17 +46,6 @@ publishing {
|
||||||
if (project.hasProperty("signing.keyId")) {
|
if (project.hasProperty("signing.keyId")) {
|
||||||
apply plugin: 'signing'
|
apply plugin: 'signing'
|
||||||
signing {
|
signing {
|
||||||
sign publishing.publications.mavenJava
|
sign publishing.publications."${project.name}"
|
||||||
}
|
|
||||||
}
|
|
||||||
if (project.hasProperty("ossrhUsername")) {
|
|
||||||
nexusPublishing {
|
|
||||||
repositories {
|
|
||||||
sonatype {
|
|
||||||
username = project.property('ossrhUsername')
|
|
||||||
password = project.property('ossrhPassword')
|
|
||||||
packageGroup = "org.xbib"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
12
gradle/publish/sonatype.gradle
vendored
Normal file
12
gradle/publish/sonatype.gradle
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
|
||||||
|
if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) {
|
||||||
|
nexusPublishing {
|
||||||
|
repositories {
|
||||||
|
sonatype {
|
||||||
|
username = project.property('ossrhUsername')
|
||||||
|
password = project.property('ossrhPassword')
|
||||||
|
packageGroup = "org.xbib"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
gradle/publishing/sonatype.gradle
vendored
11
gradle/publishing/sonatype.gradle
vendored
|
@ -1,11 +0,0 @@
|
||||||
|
|
||||||
if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) {
|
|
||||||
|
|
||||||
apply plugin: 'io.codearte.nexus-staging'
|
|
||||||
|
|
||||||
nexusStaging {
|
|
||||||
username = project.property('ossrhUsername')
|
|
||||||
password = project.property('ossrhPassword')
|
|
||||||
packageGroup = "org.xbib"
|
|
||||||
}
|
|
||||||
}
|
|
13
gradle/test/junit5.gradle
vendored
13
gradle/test/junit5.gradle
vendored
|
@ -1,9 +1,10 @@
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testImplementation libs.junit.jupiter.api
|
testImplementation testLibs.junit.jupiter.api
|
||||||
testImplementation libs.junit.jupiter.params
|
testImplementation testLibs.junit.jupiter.params
|
||||||
testImplementation libs.hamcrest
|
testImplementation testLibs.hamcrest
|
||||||
testRuntimeOnly libs.junit.jupiter.engine
|
testRuntimeOnly testLibs.junit.jupiter.engine
|
||||||
|
testRuntimeOnly testLibs.junit.jupiter.platform.launcher
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
|
@ -23,4 +24,8 @@ test {
|
||||||
}
|
}
|
||||||
jvmArgs '-Xmx2048m'
|
jvmArgs '-Xmx2048m'
|
||||||
systemProperty 'java.util.logging.config.file', 'src/test/resources/logging.properties'
|
systemProperty 'java.util.logging.config.file', 'src/test/resources/logging.properties'
|
||||||
|
// for reading large MARC XML files
|
||||||
|
systemProperty 'entityExpansionLimit', '2147480000'
|
||||||
|
systemProperty 'totalEntitySizeLimit', '2147480000'
|
||||||
|
systemProperty 'jdk.xml.totalEntitySizeLimit', '2147480000'
|
||||||
}
|
}
|
||||||
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,7 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
35
gradlew
vendored
35
gradlew
vendored
|
@ -55,7 +55,7 @@
|
||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (3) This script is generated from the Groovy template
|
||||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
# within the Gradle project.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
@ -80,13 +80,11 @@ do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
APP_NAME="Gradle"
|
|
||||||
APP_BASE_NAME=${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='"-Xmx64m" "-Xms64m"'
|
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -133,22 +131,29 @@ location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD=java
|
JAVACMD=java
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
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" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
max*)
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
warn "Could not query maximum file descriptor limit"
|
warn "Could not query maximum file descriptor limit"
|
||||||
esac
|
esac
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
'' | soft) :;; #(
|
'' | 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" ||
|
ulimit -n "$MAX_FD" ||
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
esac
|
esac
|
||||||
|
@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect all arguments for the java command;
|
|
||||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
# shell script including quotes and variable substitutions, so put them in
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
# double quotes to make sure that they get re-expanded; and
|
|
||||||
# * put everything else in single quotes, so that it's not re-expanded.
|
# 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 -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
|
1
gradlew.bat
vendored
1
gradlew.bat
vendored
|
@ -26,6 +26,7 @@ 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%
|
||||||
|
|
||||||
|
|
11
settings.gradle
vendored
11
settings.gradle
vendored
|
@ -15,20 +15,21 @@ pluginManagement {
|
||||||
dependencyResolutionManagement {
|
dependencyResolutionManagement {
|
||||||
versionCatalogs {
|
versionCatalogs {
|
||||||
libs {
|
libs {
|
||||||
version('gradle', '7.5.1')
|
version('gradle', '8.5')
|
||||||
version('groovy', '3.0.10')
|
}
|
||||||
version('junit', '5.9.1')
|
testLibs {
|
||||||
// all dependencies are test dependencies only
|
version('junit', '5.10.0')
|
||||||
library('junit-jupiter-api', 'org.junit.jupiter', 'junit-jupiter-api').versionRef('junit')
|
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-params', 'org.junit.jupiter', 'junit-jupiter-params').versionRef('junit')
|
||||||
library('junit-jupiter-engine', 'org.junit.jupiter', 'junit-jupiter-engine').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.0')
|
||||||
library('hamcrest', 'org.hamcrest', 'hamcrest-library').version('2.2')
|
library('hamcrest', 'org.hamcrest', 'hamcrest-library').version('2.2')
|
||||||
library('charactersets', 'org.xbib', 'bibliographic-character-sets').version('2.0.0')
|
library('charactersets', 'org.xbib', 'bibliographic-character-sets').version('2.0.0')
|
||||||
library('json', 'org.xbib', 'content-json').version('5.0.1')
|
|
||||||
library('xalan', 'xalan', 'xalan').version('2.7.2')
|
library('xalan', 'xalan', 'xalan').version('2.7.2')
|
||||||
library('xmlunit', 'org.xmlunit', 'xmlunit-matchers').version('2.8.4')
|
library('xmlunit', 'org.xmlunit', 'xmlunit-matchers').version('2.8.4')
|
||||||
library('mockito', 'org.mockito', 'mockito-core').version('3.3.3')
|
library('mockito', 'org.mockito', 'mockito-core').version('3.3.3')
|
||||||
library('marc4j', 'org.marc4j', 'marc4j').version('2.9.2')
|
library('marc4j', 'org.marc4j', 'marc4j').version('2.9.2')
|
||||||
|
library('json', 'org.xbib', 'datastructures-json-tiny').version('5.0.6')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package org.xbib.marc;
|
package org.xbib.marc;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
import org.xbib.marc.dialects.mab.MabSubfieldControl;
|
import org.xbib.marc.dialects.mab.MabSubfieldControl;
|
||||||
import org.xbib.marc.label.RecordLabel;
|
import org.xbib.marc.label.RecordLabel;
|
||||||
|
|
||||||
|
@ -24,6 +25,7 @@ import java.util.Deque;
|
||||||
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.Set;
|
||||||
import java.util.function.BinaryOperator;
|
import java.util.function.BinaryOperator;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
@ -602,6 +604,37 @@ public class MarcField implements Comparable<MarcField> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove subfields if they match the given set of subfield IDs.
|
||||||
|
* @param subfieldIds the IDs to remove
|
||||||
|
* @return this builder
|
||||||
|
*/
|
||||||
|
public Builder removeSubfields(Set<String> subfieldIds) {
|
||||||
|
// create a new subfield list and replace the whole list by a filtered list
|
||||||
|
LinkedList<Subfield> list = subfields.stream()
|
||||||
|
.filter(sf -> !subfieldIds.contains(sf.id))
|
||||||
|
.collect(Collectors.toCollection(LinkedList::new));
|
||||||
|
this.subfields.clear();
|
||||||
|
this.subfields.addAll(list);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In-place replacement of all subfields with a given ID.
|
||||||
|
* @param subfieldId the subfield ID
|
||||||
|
* @param newValue the new value, must be non-null
|
||||||
|
* @return this builder
|
||||||
|
*/
|
||||||
|
public Builder replace(String subfieldId, String newValue) {
|
||||||
|
Objects.requireNonNull(newValue);
|
||||||
|
for (Subfield subfield : subfields) {
|
||||||
|
if (subfield.getId().equals(subfieldId)) {
|
||||||
|
subfield.setValue(newValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy a MARC field into this builder.
|
* Copy a MARC field into this builder.
|
||||||
* @param field the MARC field to copy
|
* @param field the MARC field to copy
|
||||||
|
@ -770,7 +803,7 @@ public class MarcField implements Comparable<MarcField> {
|
||||||
|
|
||||||
private final String id;
|
private final String id;
|
||||||
|
|
||||||
private final String value;
|
private String value;
|
||||||
|
|
||||||
private Subfield(String id, String value) {
|
private Subfield(String id, String value) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
@ -793,6 +826,20 @@ public class MarcField implements Comparable<MarcField> {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
return obj instanceof Subfield && toString().equals(obj.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return toString().hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return id + "=" + value;
|
return id + "=" + value;
|
||||||
|
|
|
@ -20,7 +20,7 @@ import org.xbib.marc.label.RecordLabel;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings({"serial", "this-escape"})
|
||||||
public class MarcFieldDirectory extends TreeMap<Integer, MarcField.Builder> {
|
public class MarcFieldDirectory extends TreeMap<Integer, MarcField.Builder> {
|
||||||
|
|
||||||
public MarcFieldDirectory(RecordLabel label, String encodedDirectory) throws IOException {
|
public MarcFieldDirectory(RecordLabel label, String encodedDirectory) throws IOException {
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class MarcRecord implements Map<String, Object> {
|
||||||
|
|
||||||
private transient RecordLabel recordLabel;
|
private transient RecordLabel recordLabel;
|
||||||
|
|
||||||
private transient List<MarcField> marcFields;
|
private transient Collection<MarcField> marcFields;
|
||||||
|
|
||||||
private MarcRecord(Map<String, Object> delegate) {
|
private MarcRecord(Map<String, Object> delegate) {
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
|
@ -86,7 +86,7 @@ public class MarcRecord implements Map<String, Object> {
|
||||||
public MarcRecord(String format,
|
public MarcRecord(String format,
|
||||||
String type,
|
String type,
|
||||||
RecordLabel recordLabel,
|
RecordLabel recordLabel,
|
||||||
List<MarcField> marcFields,
|
Collection<MarcField> marcFields,
|
||||||
boolean lightweight,
|
boolean lightweight,
|
||||||
Comparator<String> comparator) {
|
Comparator<String> comparator) {
|
||||||
this.format = format;
|
this.format = format;
|
||||||
|
@ -183,7 +183,7 @@ public class MarcRecord implements Map<String, Object> {
|
||||||
*
|
*
|
||||||
* @return the MARC field list
|
* @return the MARC field list
|
||||||
*/
|
*/
|
||||||
public List<MarcField> getFields() {
|
public Collection<MarcField> getFields() {
|
||||||
return marcFields;
|
return marcFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ public class MabXMLContentHandler extends MarcContentHandler implements MabXMLCo
|
||||||
|
|
||||||
private final Set<String> validNamespaces = new HashSet<>(Collections.singletonList(MABXML_NAMESPACE));
|
private final Set<String> validNamespaces = new HashSet<>(Collections.singletonList(MABXML_NAMESPACE));
|
||||||
|
|
||||||
|
@SuppressWarnings("this-escape")
|
||||||
public MabXMLContentHandler() {
|
public MabXMLContentHandler() {
|
||||||
setTrim(true);
|
setTrim(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,15 +18,16 @@ package org.xbib.marc.io;
|
||||||
/**
|
/**
|
||||||
* Scan buffer.
|
* Scan buffer.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("this-escape")
|
||||||
public class ScanBuffer {
|
public class ScanBuffer {
|
||||||
|
|
||||||
private boolean cs;
|
private boolean cs;
|
||||||
|
|
||||||
private char[] buffer = new char[0];
|
private char[] buffer;
|
||||||
|
|
||||||
private int[] buffer2 = new int[0];
|
private int[] buffer2;
|
||||||
|
|
||||||
private char[] token = new char[0];
|
private char[] token;
|
||||||
|
|
||||||
private int pos;
|
private int pos;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.xbib.marc.json;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
public class MarcListNode extends LinkedList<Node<?>> implements ListNode {
|
public class MarcListNode extends LinkedList<Node<?>> implements ListNode {
|
||||||
|
|
||||||
public MarcListNode() {
|
public MarcListNode() {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.xbib.marc.json;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
public class MarcMapNode extends LinkedHashMap<CharSequence, Node<?>> implements MapNode {
|
public class MarcMapNode extends LinkedHashMap<CharSequence, Node<?>> implements MapNode {
|
||||||
|
|
||||||
public MarcMapNode() {
|
public MarcMapNode() {
|
||||||
|
|
|
@ -8,11 +8,6 @@ public class ValueNode implements Node<Object> {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getDepth() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void set(Object value) {
|
public void set(Object value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import javax.xml.transform.TransformerFactory;
|
||||||
import javax.xml.transform.stream.StreamResult;
|
import javax.xml.transform.stream.StreamResult;
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URI;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
@ -120,7 +120,7 @@ public class MarcTool {
|
||||||
if (schema != null && stylesheet != null && result != null) {
|
if (schema != null && stylesheet != null && result != null) {
|
||||||
System.setProperty("http.agent", "Java Agent");
|
System.setProperty("http.agent", "Java Agent");
|
||||||
builder.setSchema(schema).build().transform(TransformerFactory.newInstance(),
|
builder.setSchema(schema).build().transform(TransformerFactory.newInstance(),
|
||||||
new URL(stylesheet),
|
URI.create(stylesheet).toURL(),
|
||||||
new StreamResult(Files.newBufferedWriter(Paths.get(result))));
|
new StreamResult(Files.newBufferedWriter(Paths.get(result))));
|
||||||
} else {
|
} else {
|
||||||
builder.build().writeCollection(65536);
|
builder.build().writeCollection(65536);
|
||||||
|
|
|
@ -60,6 +60,7 @@ import java.util.zip.GZIPOutputStream;
|
||||||
* This MarcXchange Writer writes MarcXchange events to a StaX XML output stream or XML event consumer.
|
* This MarcXchange Writer writes MarcXchange events to a StaX XML output stream or XML event consumer.
|
||||||
* Default output format is MarcXchange.
|
* Default output format is MarcXchange.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("this-escape")
|
||||||
public class MarcXchangeWriter extends MarcContentHandler implements Flushable, Closeable {
|
public class MarcXchangeWriter extends MarcContentHandler implements Flushable, Closeable {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(MarcXchangeWriter.class.getName());
|
private static final Logger logger = Logger.getLogger(MarcXchangeWriter.class.getName());
|
||||||
|
|
|
@ -22,8 +22,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.xbib.content.XContentBuilder;
|
import org.xbib.datastructures.api.Builder;
|
||||||
import org.xbib.content.json.JsonXContent;
|
import org.xbib.datastructures.json.tiny.JsonBuilder;
|
||||||
import org.xbib.marc.label.RecordLabel;
|
import org.xbib.marc.label.RecordLabel;
|
||||||
import org.xbib.marc.transformer.value.MarcValueTransformers;
|
import org.xbib.marc.transformer.value.MarcValueTransformers;
|
||||||
import org.xbib.marc.xml.MarcXchangeWriter;
|
import org.xbib.marc.xml.MarcXchangeWriter;
|
||||||
|
@ -295,9 +295,9 @@ public class MarcRecordTest {
|
||||||
"100", Map.of("_", Map.of("a", "Hello World"))));
|
"100", Map.of("_", Map.of("a", "Hello World"))));
|
||||||
MarcRecord marcRecord = MarcRecord.from(map);
|
MarcRecord marcRecord = MarcRecord.from(map);
|
||||||
assertEquals("{001=123, 100={_={a=Hello World}}}", marcRecord.toString());
|
assertEquals("{001=123, 100={_={a=Hello World}}}", marcRecord.toString());
|
||||||
XContentBuilder builder = JsonXContent.contentBuilder();
|
Builder builder = JsonBuilder.builder();
|
||||||
builder.map(marcRecord);
|
builder.buildMap(marcRecord);
|
||||||
assertEquals("{\"001\":\"123\",\"100\":{\"_\":{\"a\":\"Hello World\"}}}", builder.string());
|
assertEquals("{\"001\":\"123\",\"100\":{\"_\":{\"a\":\"Hello World\"}}}", builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -308,4 +308,9 @@ public class MarcRecordTest {
|
||||||
marcRecord.all("001", field -> assertEquals("123", field.getValue()));
|
marcRecord.all("001", field -> assertEquals("123", field.getValue()));
|
||||||
marcRecord.all("100", field -> assertEquals("Hello World", field.getFirstSubfieldValue("a")));
|
marcRecord.all("100", field -> assertEquals("Hello World", field.getFirstSubfieldValue("a")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMarcRecordBuildWithUniqueFields() {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
package org.xbib.marc.filter;
|
package org.xbib.marc.filter;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.xbib.content.XContentBuilder;
|
import org.xbib.datastructures.api.Builder;
|
||||||
import org.xbib.content.json.JsonXContent;
|
import org.xbib.datastructures.json.tiny.JsonBuilder;
|
||||||
import org.xbib.marc.Marc;
|
import org.xbib.marc.Marc;
|
||||||
import org.xbib.marc.MarcField;
|
import org.xbib.marc.MarcField;
|
||||||
import org.xbib.marc.MarcFieldAdapter;
|
import org.xbib.marc.MarcFieldAdapter;
|
||||||
|
@ -93,15 +93,15 @@ public class MarcFieldFilterByRecordIdentifierTest {
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
// JSON output
|
// JSON output
|
||||||
XContentBuilder builder = JsonXContent.contentBuilder().prettyPrint()
|
Builder builder = JsonBuilder.builder()
|
||||||
.startObject();
|
.beginMap();
|
||||||
for (Map.Entry<String, Map<String, List<Map<String, String>>>> entry : result.entrySet()) {
|
for (Map.Entry<String, Map<String, List<Map<String, String>>>> entry : result.entrySet()) {
|
||||||
builder.field(entry.getKey(), entry.getValue());
|
builder.field(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
builder.field("issns", issns);
|
builder.field("issns", issns);
|
||||||
builder.endObject();
|
builder.endMap();
|
||||||
|
|
||||||
logger.log(Level.INFO, builder.string());
|
logger.log(Level.INFO, builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean matchISSNField(MarcField field, MarcField.Subfield subfield) {
|
private static boolean matchISSNField(MarcField field, MarcField.Subfield subfield) {
|
||||||
|
|
|
@ -15,9 +15,9 @@
|
||||||
*/
|
*/
|
||||||
package org.xbib.marc.filter;
|
package org.xbib.marc.filter;
|
||||||
|
|
||||||
import static org.xbib.content.json.JsonXContent.contentBuilder;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.xbib.content.XContentBuilder;
|
import org.xbib.datastructures.api.Builder;
|
||||||
|
import org.xbib.datastructures.json.tiny.JsonBuilder;
|
||||||
import org.xbib.marc.Marc;
|
import org.xbib.marc.Marc;
|
||||||
import org.xbib.marc.MarcField;
|
import org.xbib.marc.MarcField;
|
||||||
import org.xbib.marc.MarcFieldAdapter;
|
import org.xbib.marc.MarcFieldAdapter;
|
||||||
|
@ -77,15 +77,15 @@ public class MarcFieldFilterTest {
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
// JSON output
|
// JSON output
|
||||||
XContentBuilder builder = contentBuilder().prettyPrint()
|
Builder builder = JsonBuilder.builder()
|
||||||
.startObject();
|
.beginMap();
|
||||||
for (Map.Entry<String, List<Map<String, String>>> entry : result.entrySet()) {
|
for (Map.Entry<String, List<Map<String, String>>> entry : result.entrySet()) {
|
||||||
builder.field(entry.getKey(), entry.getValue());
|
builder.field(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
builder.array("issns", issns);
|
builder.collection("issns", issns);
|
||||||
builder.endObject();
|
builder.endMap();
|
||||||
|
|
||||||
logger.log(Level.INFO, builder.string());
|
logger.log(Level.INFO, builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean matchISSNField(MarcField field, MarcField.Subfield subfield) {
|
private static boolean matchISSNField(MarcField field, MarcField.Subfield subfield) {
|
||||||
|
|
Loading…
Reference in a new issue