update to Java 17, fix field list for MarcContentHandler
This commit is contained in:
parent
ee55fa7ff8
commit
d2fa91317c
18 changed files with 134 additions and 79 deletions
16
build.gradle
16
build.gradle
|
@ -5,7 +5,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
wrapper {
|
wrapper {
|
||||||
gradleVersion = "${rootProject.property('gradle.wrapper.version')}"
|
gradleVersion = libs.versions.gradle.get()
|
||||||
distributionType = Wrapper.DistributionType.ALL
|
distributionType = Wrapper.DistributionType.ALL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,17 +27,17 @@ ext {
|
||||||
apply plugin: 'java-library'
|
apply plugin: 'java-library'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testImplementation "org.xbib:bibliographic-character-sets:${project.property('xbib-bibliographic-character-sets.version')}"
|
testImplementation libs.charactersets
|
||||||
testImplementation "org.xbib:content-json:${project.property('xbib-content.version')}"
|
testImplementation libs.json
|
||||||
testImplementation "xalan:xalan:${project.property('xalan.version')}"
|
testImplementation libs.xalan
|
||||||
testImplementation "org.xmlunit:xmlunit-matchers:${project.property('xmlunit-matchers.version')}"
|
testImplementation libs.xmlunit
|
||||||
testImplementation("com.github.stefanbirkner:system-rules:${project.property('system-rules.version')}") {
|
testImplementation (libs.system.rules) {
|
||||||
exclude module: 'junit'
|
exclude module: 'junit'
|
||||||
}
|
}
|
||||||
testImplementation("org.mockito:mockito-core:${project.property('mockito.version')}") {
|
testImplementation(libs.mockito) {
|
||||||
exclude group: 'org.hamcrest'
|
exclude group: 'org.hamcrest'
|
||||||
}
|
}
|
||||||
testImplementation "org.marc4j:marc4j:${project.property('marc4j.version')}"
|
testImplementation libs.marc4j
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: rootProject.file('gradle/ide/idea.gradle')
|
apply from: rootProject.file('gradle/ide/idea.gradle')
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
|
|
||||||
def junitVersion = project.hasProperty('junit.version')?project.property('junit.version'):'5.8.2'
|
|
||||||
def hamcrestVersion = project.hasProperty('hamcrest.version')?project.property('hamcrest.version'):'2.2'
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
|
testImplementation libs.junit.jupiter.api
|
||||||
testImplementation "org.junit.jupiter:junit-jupiter-params:${junitVersion}"
|
testImplementation libs.junit.jupiter.params
|
||||||
testImplementation "org.hamcrest:hamcrest-library:${hamcrestVersion}"
|
testImplementation libs.hamcrest
|
||||||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
|
testRuntimeOnly libs.junit.jupiter.engine
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
|
@ -24,17 +21,6 @@ test {
|
||||||
"${result.skippedTestCount} skipped"
|
"${result.skippedTestCount} skipped"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jvmArgs '-Xmx2048m',
|
jvmArgs '-Xmx2048m'
|
||||||
'--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'
|
|
||||||
systemProperty 'java.util.logging.config.file', 'src/test/resources/logging.properties'
|
systemProperty 'java.util.logging.config.file', 'src/test/resources/logging.properties'
|
||||||
}
|
}
|
||||||
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,5 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
6
gradlew
vendored
6
gradlew
vendored
|
@ -205,6 +205,12 @@ set -- \
|
||||||
org.gradle.wrapper.GradleWrapperMain \
|
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
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
# Use "xargs" to parse quoted args.
|
||||||
#
|
#
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
|
10
gradlew.bat
vendored
10
gradlew.bat
vendored
|
@ -40,7 +40,7 @@ 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%" == "0" goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
: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%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 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!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=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
|
||||||
|
|
20
settings.gradle
Normal file
20
settings.gradle
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
dependencyResolutionManagement {
|
||||||
|
versionCatalogs {
|
||||||
|
libs {
|
||||||
|
version('gradle', '7.5.1')
|
||||||
|
version('groovy', '3.0.10')
|
||||||
|
version('junit', '5.9.1')
|
||||||
|
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('hamcrest', 'org.hamcrest', 'hamcrest-library').version('2.2')
|
||||||
|
library('charactersets', 'org.xbib', 'bibliographic-character-sets').version('2.0.0')
|
||||||
|
library('json', 'org.xbib', 'content-json').version('4.0.0')
|
||||||
|
library('xalan', 'xalan', 'xalan').version('2.7.2')
|
||||||
|
library('xmlunit', 'org.xmlunit', 'xmlunit-matchers').version('2.8.4')
|
||||||
|
library('system-rules', 'com.github.stefanbirkner', 'system-rules').version('1.19.0')
|
||||||
|
library('mockito', 'org.mockito', 'mockito-core').version('3.3.3')
|
||||||
|
library('marc4j', 'org.marc4j', 'marc4j').version('2.9.2')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,6 +20,10 @@ package org.xbib.marc;
|
||||||
* A MARC listener with empty methods. Useful for extending.
|
* A MARC listener with empty methods. Useful for extending.
|
||||||
*/
|
*/
|
||||||
public class MarcFieldAdapter implements MarcListener {
|
public class MarcFieldAdapter implements MarcListener {
|
||||||
|
|
||||||
|
public MarcFieldAdapter() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beginCollection() {
|
public void beginCollection() {
|
||||||
// empty by design
|
// empty by design
|
||||||
|
|
|
@ -16,14 +16,13 @@
|
||||||
*/
|
*/
|
||||||
package org.xbib.marc.dialects.pica;
|
package org.xbib.marc.dialects.pica;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import org.xbib.marc.MarcField;
|
import org.xbib.marc.MarcField;
|
||||||
import org.xbib.marc.label.RecordLabel;
|
import org.xbib.marc.label.RecordLabel;
|
||||||
import org.xbib.marc.xml.MarcContentHandler;
|
import org.xbib.marc.xml.MarcContentHandler;
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,8 +31,12 @@ import java.util.Set;
|
||||||
*/
|
*/
|
||||||
public class PicaXMLContentHandler extends MarcContentHandler implements PicaConstants {
|
public class PicaXMLContentHandler extends MarcContentHandler implements PicaConstants {
|
||||||
|
|
||||||
private Set<String> validNamespaces =
|
private final Set<String> validNamespaces;
|
||||||
new HashSet<>(Arrays.asList(PICAXML_NAMESPACE, SRW_PICAXML_NAMESPACE));
|
|
||||||
|
public PicaXMLContentHandler() {
|
||||||
|
this.validNamespaces = new HashSet<>();
|
||||||
|
this.validNamespaces.addAll(Set.of(PICAXML_NAMESPACE, SRW_PICAXML_NAMESPACE));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getDefaultFormat() {
|
protected String getDefaultFormat() {
|
||||||
|
|
|
@ -16,13 +16,13 @@
|
||||||
*/
|
*/
|
||||||
package org.xbib.marc.json;
|
package org.xbib.marc.json;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class JsonDefaultHandler implements JsonHandler<JsonArray, JsonObject> {
|
public class JsonDefaultHandler implements JsonHandler<JsonArray, JsonObject> {
|
||||||
|
|
||||||
protected JsonValue value;
|
protected JsonValue value;
|
||||||
|
|
||||||
|
public JsonDefaultHandler() {
|
||||||
|
}
|
||||||
|
|
||||||
public JsonValue getValue() {
|
public JsonValue getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,9 @@ import java.io.StringWriter;
|
||||||
*/
|
*/
|
||||||
public abstract class JsonValue {
|
public abstract class JsonValue {
|
||||||
|
|
||||||
|
public JsonValue() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detects whether this value represents a JSON object. If this is the case, this value is an
|
* Detects whether this value represents a JSON object. If this is the case, this value is an
|
||||||
* instance of {@link JsonObject}.
|
* instance of {@link JsonObject}.
|
||||||
|
|
|
@ -39,13 +39,23 @@ public class MarcTool {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(MarcTool.class.getName());
|
private static final Logger logger = Logger.getLogger(MarcTool.class.getName());
|
||||||
|
|
||||||
private String mode = null;
|
private String mode;
|
||||||
private String input = null;
|
|
||||||
private String output = null;
|
private String input;
|
||||||
private String charset = "UTF-8";
|
|
||||||
private String schema = null;
|
private String output;
|
||||||
private String stylesheet = null;
|
|
||||||
private String result = null;
|
private String charset;
|
||||||
|
|
||||||
|
private String schema;
|
||||||
|
|
||||||
|
private String stylesheet;
|
||||||
|
|
||||||
|
private String result;
|
||||||
|
|
||||||
|
public MarcTool() {
|
||||||
|
this.charset = "UTF-8";
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
MarcTool marcTool = new MarcTool();
|
MarcTool marcTool = new MarcTool();
|
||||||
|
|
|
@ -21,11 +21,11 @@ import org.xbib.marc.MarcField;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
@SuppressWarnings("serial")
|
||||||
*/
|
|
||||||
public class MarcFieldTransformers extends LinkedList<MarcFieldTransformer> {
|
public class MarcFieldTransformers extends LinkedList<MarcFieldTransformer> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 2704484673464559115L;
|
public MarcFieldTransformers() {
|
||||||
|
}
|
||||||
|
|
||||||
public List<MarcField> transform(List<MarcField> marcFields) {
|
public List<MarcField> transform(List<MarcField> marcFields) {
|
||||||
LinkedList<MarcField> list = new LinkedList<>();
|
LinkedList<MarcField> list = new LinkedList<>();
|
||||||
|
|
|
@ -21,15 +21,18 @@ import org.xbib.marc.MarcField;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class MarcValueTransformers {
|
public class MarcValueTransformers {
|
||||||
|
|
||||||
private static final String DEFAULT = "_default";
|
private static final String DEFAULT = "_default";
|
||||||
|
|
||||||
private final Map<String, MarcValueTransformer> marcValueTransformerMap = new HashMap<>();
|
private final Map<String, MarcValueTransformer> marcValueTransformerMap;
|
||||||
|
|
||||||
private final Map<String, String> subfieldMap = new HashMap<>();
|
private final Map<String, String> subfieldMap;
|
||||||
|
|
||||||
|
public MarcValueTransformers() {
|
||||||
|
marcValueTransformerMap = new HashMap<>();
|
||||||
|
subfieldMap = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
public MarcValueTransformers setMarcValueTransformer(MarcValueTransformer transformer) {
|
public MarcValueTransformers setMarcValueTransformer(MarcValueTransformer transformer) {
|
||||||
this.marcValueTransformerMap.put(DEFAULT, transformer);
|
this.marcValueTransformerMap.put(DEFAULT, transformer);
|
||||||
|
|
|
@ -16,9 +16,11 @@
|
||||||
*/
|
*/
|
||||||
package org.xbib.marc.transformer.value;
|
package org.xbib.marc.transformer.value;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class Xml10MarcValueCleaner implements MarcValueTransformer {
|
public class Xml10MarcValueCleaner implements MarcValueTransformer {
|
||||||
|
|
||||||
|
public Xml10MarcValueCleaner() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String transform(String string) {
|
public String transform(String string) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.xbib.marc.xml;
|
package org.xbib.marc.xml;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import org.xbib.marc.MarcField;
|
import org.xbib.marc.MarcField;
|
||||||
import org.xbib.marc.MarcListener;
|
import org.xbib.marc.MarcListener;
|
||||||
import org.xbib.marc.MarcRecord;
|
import org.xbib.marc.MarcRecord;
|
||||||
|
@ -35,10 +36,8 @@ import org.xml.sax.SAXException;
|
||||||
import org.xml.sax.SAXParseException;
|
import org.xml.sax.SAXParseException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Deque;
|
import java.util.Deque;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -57,13 +56,13 @@ public class MarcContentHandler
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(MarcContentHandler.class.getName());
|
private static final Logger logger = Logger.getLogger(MarcContentHandler.class.getName());
|
||||||
|
|
||||||
protected final AtomicInteger recordCounter = new AtomicInteger();
|
protected final AtomicInteger recordCounter;
|
||||||
|
|
||||||
protected Deque<MarcField.Builder> stack = new LinkedList<>();
|
protected Deque<MarcField.Builder> stack;
|
||||||
|
|
||||||
protected Map<String, MarcListener> listeners = new HashMap<>();
|
protected Map<String, MarcListener> listeners;
|
||||||
|
|
||||||
protected StringBuilder content = new StringBuilder();
|
protected StringBuilder content;
|
||||||
|
|
||||||
protected MarcListener marcListener;
|
protected MarcListener marcListener;
|
||||||
|
|
||||||
|
@ -77,16 +76,25 @@ public class MarcContentHandler
|
||||||
|
|
||||||
protected MarcValueTransformers marcValueTransformers;
|
protected MarcValueTransformers marcValueTransformers;
|
||||||
|
|
||||||
protected boolean trim = false;
|
protected boolean trim;
|
||||||
|
|
||||||
private MarcFieldTransformers marcFieldTransformers;
|
private MarcFieldTransformers marcFieldTransformers;
|
||||||
|
|
||||||
private boolean isCollection = false;
|
private boolean isCollection;
|
||||||
|
|
||||||
private final List<MarcField> marcFieldList = new LinkedList<>();
|
private List<MarcField> marcFieldList;
|
||||||
|
|
||||||
private final Set<String> validNamespaces =
|
private final Set<String> validNamespaces;
|
||||||
new HashSet<>(Arrays.asList(MARCXCHANGE_V1_NS_URI, MARCXCHANGE_V2_NS_URI, MARC21_SCHEMA_URI));
|
|
||||||
|
public MarcContentHandler() {
|
||||||
|
this.recordCounter = new AtomicInteger();
|
||||||
|
this.stack = new LinkedList<>();
|
||||||
|
this.listeners = new HashMap<>();
|
||||||
|
this.content = new StringBuilder();
|
||||||
|
this.marcFieldList = new LinkedList<>();
|
||||||
|
this.validNamespaces = new HashSet<>();
|
||||||
|
this.validNamespaces.addAll(Set.of(MARCXCHANGE_V1_NS_URI, MARCXCHANGE_V2_NS_URI, MARC21_SCHEMA_URI));
|
||||||
|
}
|
||||||
|
|
||||||
protected String getDefaultFormat() {
|
protected String getDefaultFormat() {
|
||||||
return MARC21_FORMAT;
|
return MARC21_FORMAT;
|
||||||
|
@ -249,7 +257,7 @@ public class MarcContentHandler
|
||||||
if (marcFieldTransformers != null) {
|
if (marcFieldTransformers != null) {
|
||||||
marcFieldTransformers.reset();
|
marcFieldTransformers.reset();
|
||||||
}
|
}
|
||||||
marcFieldList.clear();
|
marcFieldList = new LinkedList<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,16 +16,15 @@
|
||||||
*/
|
*/
|
||||||
package org.xbib.marc.xml;
|
package org.xbib.marc.xml;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import org.xbib.marc.MarcField;
|
import org.xbib.marc.MarcField;
|
||||||
import org.xbib.marc.MarcListener;
|
import org.xbib.marc.MarcListener;
|
||||||
import org.xbib.marc.MarcXchangeConstants;
|
import org.xbib.marc.MarcXchangeConstants;
|
||||||
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 java.util.Arrays;
|
|
||||||
import java.util.Deque;
|
import java.util.Deque;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -45,22 +44,31 @@ import javax.xml.stream.util.XMLEventConsumer;
|
||||||
*/
|
*/
|
||||||
public class MarcXchangeEventConsumer implements XMLEventConsumer, MarcXchangeConstants, MarcListener {
|
public class MarcXchangeEventConsumer implements XMLEventConsumer, MarcXchangeConstants, MarcListener {
|
||||||
|
|
||||||
private Deque<MarcField.Builder> stack = new LinkedList<>();
|
private final Deque<MarcField.Builder> stack;
|
||||||
|
|
||||||
private Map<String, MarcListener> listeners = new HashMap<>();
|
private final Map<String, MarcListener> listeners;
|
||||||
|
|
||||||
private MarcValueTransformers marcValueTransformers;
|
private MarcValueTransformers marcValueTransformers;
|
||||||
|
|
||||||
private MarcListener listener;
|
private MarcListener listener;
|
||||||
|
|
||||||
private StringBuilder content = new StringBuilder();
|
private final StringBuilder content;
|
||||||
|
|
||||||
private String format = MARC21_FORMAT;
|
private String format;
|
||||||
|
|
||||||
private String type = BIBLIOGRAPHIC_TYPE;
|
private String type;
|
||||||
|
|
||||||
private Set<String> validNamespaces =
|
private final Set<String> validNamespaces;
|
||||||
new HashSet<>(Arrays.asList(MARCXCHANGE_V1_NS_URI, MARCXCHANGE_V2_NS_URI, MARC21_SCHEMA_URI));
|
|
||||||
|
public MarcXchangeEventConsumer() {
|
||||||
|
this.stack = new LinkedList<>();
|
||||||
|
this.listeners = new HashMap<>();
|
||||||
|
this.content = new StringBuilder();
|
||||||
|
this.format = MARC21_FORMAT;
|
||||||
|
this.type = BIBLIOGRAPHIC_TYPE;
|
||||||
|
this.validNamespaces = new HashSet<>();
|
||||||
|
this.validNamespaces.addAll(Set.of(MARCXCHANGE_V1_NS_URI, MARCXCHANGE_V2_NS_URI, MARC21_SCHEMA_URI));
|
||||||
|
}
|
||||||
|
|
||||||
public MarcXchangeEventConsumer setMarcListener(String type, MarcListener listener) {
|
public MarcXchangeEventConsumer setMarcListener(String type, MarcListener listener) {
|
||||||
this.listeners.put(type, listener);
|
this.listeners.put(type, listener);
|
||||||
|
|
|
@ -25,7 +25,7 @@ import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is original inspired from project {@code system-rules},
|
* This class is original inspired from project {@code system-rules},
|
||||||
* rewrite it to JUnit5. It is a JUnit Jupiter extension that allows
|
* rewritten to JUnit5. It is a JUnit Jupiter extension that allows
|
||||||
* in-test specification of expected {@code System.exit(...)} calls.
|
* in-test specification of expected {@code System.exit(...)} calls.
|
||||||
*/
|
*/
|
||||||
@Target({TYPE, METHOD})
|
@Target({TYPE, METHOD})
|
||||||
|
|
Loading…
Reference in a new issue