update to Java 17, add Alma XML, relax label value interpretation with # symbol

This commit is contained in:
Jörg Prante 2022-10-13 17:51:01 +02:00
parent 4cb84894db
commit ee55fa7ff8
12 changed files with 105 additions and 17 deletions

View file

@ -1,13 +1,13 @@
group = org.xbib group = org.xbib
name = marc name = marc
version = 2.6.0 version = 2.7.0
org.gradle.warning.mode = ALL org.gradle.warning.mode = ALL
gradle.wrapper.version = 7.3.2 gradle.wrapper.version = 7.5.1
xbib-content.version = 4.0.0 xbib-content.version = 4.0.0
xbib-bibliographic-character-sets.version = 2.0.0 xbib-bibliographic-character-sets.version = 2.0.0
xalan.version = 2.7.2 xalan.version = 2.7.2
xmlunit-matchers.version = 2.6.3 xmlunit-matchers.version = 2.8.4
system-rules.version = 1.19.0 system-rules.version = 1.19.0
mockito.version = 3.3.3 mockito.version = 3.3.3
marc4j.version = 2.9.2 marc4j.version = 2.9.2

View file

@ -6,13 +6,13 @@ java {
} }
compileJava { compileJava {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_17
} }
compileTestJava { compileTestJava {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_17
} }
jar { jar {

View file

@ -24,6 +24,17 @@ test {
"${result.skippedTestCount} skipped" "${result.skippedTestCount} skipped"
} }
} }
// massive heap for for xmlunit DOM comparer 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'
} }

View file

@ -59,6 +59,7 @@ public enum Encoding {
public static Encoding from(char ch) { public static Encoding from(char ch) {
switch (ch) { switch (ch) {
case ' ': case ' ':
case '#':
return MARC8; return MARC8;
case 'a': case 'a':
return UCS_UNICODE; return UCS_UNICODE;

View file

@ -106,6 +106,7 @@ public enum EncodingLevel {
public static EncodingLevel from(char ch) { public static EncodingLevel from(char ch) {
switch (ch) { switch (ch) {
case ' ': case ' ':
case '#':
return FULL; return FULL;
case '1': case '1':
return FULL_NOT_EXAMINED; return FULL_NOT_EXAMINED;
@ -125,6 +126,14 @@ public enum EncodingLevel {
return UNKNOWN; return UNKNOWN;
case 'z': case 'z':
return NOT_APPLICABLE; return NOT_APPLICABLE;
case 'I':
return LESS_THAN_FULL_NOT_EXAMINED;
case 'K':
return LESS_THAN_FULL_NOT_EXAMINED;
case 'M':
return LESS_THAN_FULL_NOT_EXAMINED;
case 'U':
return UNKNOWN;
default: default:
logger.log(Level.FINEST, () -> "unknown encoding level " + ch); logger.log(Level.FINEST, () -> "unknown encoding level " + ch);
return FULL; return FULL;

View file

@ -63,6 +63,7 @@ public enum MultipartResourceRecordLevel {
public static MultipartResourceRecordLevel from(char ch) { public static MultipartResourceRecordLevel from(char ch) {
switch (ch) { switch (ch) {
case ' ': case ' ':
case '#':
return NOT_SPECIFIED; return NOT_SPECIFIED;
case 'a': case 'a':
return SET; return SET;

View file

@ -51,6 +51,7 @@ public enum TypeOfControl {
public static TypeOfControl from(char ch) { public static TypeOfControl from(char ch) {
switch (ch) { switch (ch) {
case ' ': case ' ':
case '#':
return UNSPECIFIED; return UNSPECIFIED;
case 'a': case 'a':
return ARCHIVAL; return ARCHIVAL;

View file

@ -166,6 +166,7 @@ public enum TypeOfRecord {
static TypeOfRecord from(char ch) { static TypeOfRecord from(char ch) {
switch (ch) { switch (ch) {
case ' ': case ' ':
case '#':
return UNSPECIFIED; return UNSPECIFIED;
case 'a': case 'a':
return LANGUAGE_MATERIAL; return LANGUAGE_MATERIAL;

View file

@ -119,11 +119,11 @@ public class MarcContentHandler
/** /**
* Set MARC record listener.. * Set MARC record listener..
* @param listener the MARC recordlistener * @param marcRecordListener the MARC recordlistener
* @return this handler * @return this handler
*/ */
public MarcContentHandler setMarcRecordListener(MarcRecordListener listener) { public MarcContentHandler setMarcRecordListener(MarcRecordListener marcRecordListener) {
this.marcRecordListener = listener; this.marcRecordListener = marcRecordListener;
return this; return this;
} }
@ -161,7 +161,7 @@ public class MarcContentHandler
public void beginCollection() { public void beginCollection() {
// early setup of MARC listener, even before beginRecord(format, type), it works only // early setup of MARC listener, even before beginRecord(format, type), it works only
// if type is set to this handler. // if type is set to this handler.
this.marcListener = listeners.get(this.type); marcListener = listeners.get(this.type);
if (marcListener != null) { if (marcListener != null) {
marcListener.beginCollection(); marcListener.beginCollection();
} }
@ -286,7 +286,7 @@ public class MarcContentHandler
} }
switch (localName) { switch (localName) {
case COLLECTION: { case COLLECTION: {
if (!isCollection) { if (!isCollection) {;
beginCollection(); beginCollection();
isCollection = true; isCollection = true;
} }
@ -485,6 +485,6 @@ public class MarcContentHandler
} }
protected boolean isNamespace(String uri) { protected boolean isNamespace(String uri) {
return validNamespaces.contains(uri); return uri.isEmpty() || validNamespaces.contains(uri);
} }
} }

View file

@ -0,0 +1,53 @@
package org.xbib.marc.xml;
import org.junit.jupiter.api.Test;
import org.xbib.marc.Marc;
import org.xbib.marc.MarcRecord;
import org.xbib.marc.MarcRecordListener;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
import java.util.logging.Logger;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class AlmaXMLTest {
private static final Logger logger = Logger.getLogger(AlmaXMLTest.class.getName());
@Test
public void testAlmaRecordListener() throws Exception {
String s = "alma.xml";
InputStream in = getClass().getResourceAsStream(s);
AtomicBoolean found = new AtomicBoolean();
MarcRecordListener marcRecordListener = new MarcRecordListener() {
@Override
public void beginCollection() {
}
@Override
public void record(MarcRecord marcRecord) {
logger.log(Level.INFO, "record = " + marcRecord);
found.set(true);
}
@Override
public void endCollection() {
}
};
// attach record listener
MarcContentHandler marcListener = new MarcContentHandler();
marcListener.setMarcRecordListener(marcRecordListener);
Marc.builder()
.setInputStream(in)
.setCharset(StandardCharsets.UTF_8)
.setContentHandler(marcListener)
.build()
.xmlReader()
.parse();
assertTrue(found.get());
}
}

View file

@ -0,0 +1,9 @@
handlers=java.util.logging.FileHandler, java.util.logging.ConsoleHandler
.level=ALL
java.util.logging.SimpleFormatter.format=%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS.%1$tL %4$-7s [%3$s] %5$s %6$s%n
java.util.logging.ConsoleHandler.level=ALL
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.FileHandler.level=ALL
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.FileHandler.pattern=build/marc.log
jdk.event.security.level=INFO

File diff suppressed because one or more lines are too long