add Java named modules, Gradle 6, remove all logging, JUnit 5

This commit is contained in:
Jörg Prante 2020-05-19 16:06:39 +02:00
parent 00639d970b
commit d46afa4c03
101 changed files with 868 additions and 923 deletions

View file

@ -1,192 +1,34 @@
plugins {
id "org.sonarqube" version "2.8"
id "de.marcphilipp.nexus-publish" version "0.4.0"
id "io.codearte.nexus-staging" version "0.21.1"
id "com.github.spotbugs" version "2.0.1"
id "org.xbib.gradle.plugin.asciidoctor" version "1.5.6.0.1"
}
wrapper {
gradleVersion = "${rootProject.property('gradle.wrapper.version')}"
distributionType = Wrapper.DistributionType.ALL
}
ext {
user = 'xbib'
name = 'content'
description = 'Content processing library for Java'
inceptionYear = '2016'
url = 'https://github.com/' + user + '/' + name
scmUrl = 'https://github.com/' + user + '/' + name
scmConnection = 'scm:git:git://github.com/' + user + '/' + name + '.git'
scmDeveloperConnection = 'scm:git:ssh://git@github.com:' + user + '/' + name + '.git'
issueManagementSystem = 'Github'
issueManagementUrl = ext.scmUrl + '/issues'
licenseName = 'The Apache License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
subprojects {
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'pmd'
apply plugin: 'checkstyle'
apply plugin: 'com.github.spotbugs'
apply plugin: 'org.xbib.gradle.plugin.asciidoctor'
repositories {
mavenCentral()
}
configurations {
asciidoclet
}
dependencies {
testCompile "org.junit.jupiter:junit-jupiter-api:${project.property('junit.version')}"
testCompile "org.junit.jupiter:junit-jupiter-params:${project.property('junit.version')}"
testCompile "org.junit.jupiter:junit-jupiter-engine:${project.property('junit.version')}"
testCompile "org.junit.vintage:junit-vintage-engine:${project.property('junit.version')}"
testCompile "junit:junit:${project.property('junit4.version')}"
asciidoclet "org.asciidoctor:asciidoclet:${project.property('asciidoclet.version')}"
}
compileJava {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:all"
}
jar {
manifest {
attributes('Implementation-Version': project.version)
}
}
test {
useJUnitPlatform()
failFast = false
testLogging {
events 'STARTED', 'PASSED', 'FAILED', 'SKIPPED'
}
afterSuite { desc, result ->
if (!desc.parent) {
println "\nTest result: ${result.resultType}"
println "Test summary: ${result.testCount} tests, " +
"${result.successfulTestCount} succeeded, " +
"${result.failedTestCount} failed, " +
"${result.skippedTestCount} skipped"
}
}
}
clean {
delete 'out'
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier 'javadoc'
}
artifacts {
archives sourcesJar, javadocJar
}
tasks.withType(Checkstyle) {
ignoreFailures = true
reports {
xml.enabled = true
html.enabled = true
}
}
spotbugs {
effort = "max"
reportLevel = "low"
//includeFilter = file("findbugs-exclude.xml")
}
tasks.withType(com.github.spotbugs.SpotBugsTask) {
ignoreFailures = true
reports {
xml.enabled = false
html.enabled = true
}
}
tasks.withType(Pmd) {
ignoreFailures = true
reports {
xml.enabled = true
html.enabled = true
}
}
checkstyle {
configFile = rootProject.file('config/checkstyle/checkstyle.xml')
ignoreFailures = true
showViolations = true
}
sonarqube {
properties {
property "sonar.projectName", "${project.group} ${project.name}"
property "sonar.sourceEncoding", "UTF-8"
property "sonar.tests", "src/test/java"
property "sonar.scm.provider", "git"
property "sonar.junit.reportsPath", "build/test-results/test/"
}
}
ext {
projectDescription = 'Content processing library for Java'
scmUrl = 'https://github.com/xbib/content'
scmConnection = 'scm:git:git://github.com/xbib/content.git'
scmDeveloperConnection = 'scm:git:git://github.com/xbib/content.git'
}
task sonatypeUpload(type: Upload, dependsOn: build) {
group = 'publish'
configuration = configurations.archives
uploadDescriptor = true
repositories {
if (project.hasProperty('ossrhUsername')) {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: uri(ossrhReleaseUrl)) {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: uri(ossrhSnapshotUrl)) {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
pom.project {
groupId project.group
artifactId project.name
version project.version
name project.name
description projectDescription
packaging 'jar'
inceptionYear '2016'
url scmUrl
organization {
name 'xbib'
url 'http://xbib.org'
}
developers {
developer {
id 'xbib'
name 'Jörg Prante'
email 'joergprante@gmail.com'
url 'https://github.com/jprante'
}
}
scm {
url scmUrl
connection scmConnection
developerConnection scmDeveloperConnection
}
licenses {
license {
name 'The Apache License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
}
}
}
}
}
}
nexusStaging {
packageGroup = "org.xbib"
//stagingProfileId = "org.xbib"
apply plugin: 'java-library'
apply from: rootProject.file('gradle/ide/idea.gradle')
apply from: rootProject.file('gradle/compile/java.gradle')
apply from: rootProject.file('gradle/test/junit5.gradle')
apply from: rootProject.file('gradle/publishing/publication.gradle')
}
apply from: rootProject.file('gradle/publishing/sonatype.gradle')

View file

@ -73,7 +73,6 @@ page at http://checkstyle.sourceforge.net/config.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"/>

View file

@ -1,3 +1,3 @@
dependencies {
compile "com.fasterxml.jackson.core:jackson-core:${project.property('jackson.version')}"
api "com.fasterxml.jackson.core:jackson-core:${project.property('jackson.version')}"
}

View file

@ -0,0 +1,14 @@
module org.xbib.content.core {
exports org.xbib.content;
exports org.xbib.content.io;
exports org.xbib.content.json;
exports org.xbib.content.settings;
exports org.xbib.content.util.geo;
exports org.xbib.content.util.unit;
requires com.fasterxml.jackson.core;
provides org.xbib.content.XContent with
org.xbib.content.json.JsonXContent;
provides org.xbib.content.settings.SettingsLoader with
org.xbib.content.settings.PropertiesSettingsLoader,
org.xbib.content.json.JsonSettingsLoader;
}

View file

@ -1,9 +1,10 @@
package org.xbib.content;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.xbib.content.json.JsonXContent.contentBuilder;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.xbib.content.json.JsonXContent;
import java.io.IOException;
@ -16,7 +17,7 @@ import java.util.Map;
/**
*
*/
public class XContentBuilderTest extends Assert {
public class XContentBuilderTest {
@Test
public void testCopy() throws IOException {
@ -141,10 +142,11 @@ public class XContentBuilderTest extends Assert {
assertEquals(map.toString(), "{value=4AC3B67267}");
}
@Test(expected = NullPointerException.class)
public void testNullKey() throws IOException {
XContentBuilder builder = contentBuilder();
builder.field((String) null);
@Test
public void testNullKey() {
assertThrows(NullPointerException.class, () -> {
XContentBuilder builder = contentBuilder();
builder.field((String) null);
});
}
}

View file

@ -1,7 +1,9 @@
package org.xbib.content.settings;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import org.xbib.content.XContentHelper;
import org.xbib.content.io.BytesArray;
import org.xbib.content.io.BytesReference;
@ -24,7 +26,7 @@ import java.util.concurrent.TimeUnit;
/**
*
*/
public class SettingsTest extends Assert {
public class SettingsTest {
@Test
public void testEmpty() {

View file

@ -0,0 +1,3 @@
module org.xbib.content.csv {
exports org.xbib.content.csv;
}

View file

@ -6,16 +6,12 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
*/
public class CSVParser {
private static final Logger logger = Logger.getLogger(CSVParser.class.getName());
private final CSVLexer lexer;
private final List<String> row;
@ -43,7 +39,7 @@ public class CSVParser {
}
public Iterator<List<String>> iterator() {
return new Iterator<List<String>>() {
return new Iterator<>() {
private List<String> current;
private List<String> getNextRow() throws IOException {
@ -56,7 +52,6 @@ public class CSVParser {
try {
current = getNextRow();
} catch (IOException e) {
logger.log(Level.FINE, e.getMessage(), e);
throw new NoSuchElementException(e.getMessage());
}
}

View file

@ -1,7 +1,6 @@
package org.xbib.content.csv;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.StringWriter;
import java.util.Arrays;

View file

@ -1,27 +1,20 @@
package org.xbib.content.csv;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.text.MessageFormat;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
*/
public class CSVParserTest {
private static final Logger logger = Logger.getLogger(CSVParserTest.class.getName());
@Test
public void testCommaSeparated() throws IOException {
InputStream in = getClass().getResourceAsStream("test.csv");
@ -31,7 +24,6 @@ public class CSVParserTest {
Iterator<List<String>> it = csvParser.iterator();
while (it.hasNext()) {
List<String> row = it.next();
//logger.log(Level.INFO, MessageFormat.format("count={0} row={1}", count, row));
count++;
}
}
@ -47,7 +39,6 @@ public class CSVParserTest {
Iterator<List<String>> it = csvParser.iterator();
while (it.hasNext()) {
List<String> row = it.next();
//logger.log(Level.INFO, MessageFormat.format("count={0} row={1}", count, row));
count++;
}
}

View file

@ -1,11 +1,11 @@
package org.xbib.content.csv;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
/**
*
@ -15,7 +15,7 @@ public class TSVParserTest {
@Test
public void testTabSeparated() throws IOException {
InputStream in = getClass().getResourceAsStream("2076831-X-web.txt");
InputStreamReader r = new InputStreamReader(in, "UTF-8");
InputStreamReader r = new InputStreamReader(in, StandardCharsets.UTF_8);
BufferedReader reader = new BufferedReader(r);
// skip 3 lines
reader.readLine();
@ -24,7 +24,6 @@ public class TSVParserTest {
String line;
while ((line = reader.readLine()) != null) {
String[] s = line.split("\\t");
//logger.info("len={} line={}", s.length, Arrays.asList(s));
int i = 0;
String sigel = i < s.length ? s[i++] : "";
String isil = i < s.length ? s[i++] : "";
@ -40,8 +39,6 @@ public class TSVParserTest {
String lastVolume = i < s.length ? s[i++] : "";
String lastIssue = i < s.length ? s[i++] : "";
String movingWall = i < s.length ? s[i] : "";
//logger.info("lastDate={}", lastDate);
}
}
}

View file

@ -1,10 +1,9 @@
dependencies {
compile "com.fasterxml.jackson.core:jackson-databind:${project.property('jackson.version')}"
testCompile("junit:junit:${project.property('junit4.version')}") {
api "com.fasterxml.jackson.core:jackson-databind:${project.property('jackson.version')}"
testImplementation("junit:junit:${project.property('junit4.version')}") {
exclude group: 'org.hamcrest'
}
testCompile("org.mockito:mockito-core:${project.property('mockito.version')}") {
testImplementation("org.mockito:mockito-core:${project.property('mockito.version')}") {
exclude group: 'org.hamcrest'
}
testCompile "org.hamcrest:hamcrest-library:${project.property('hamcrest.version')}"
}

View file

@ -0,0 +1,8 @@
module org.xbib.content.json {
exports org.xbib.content.json.diff;
exports org.xbib.content.json.jackson;
exports org.xbib.content.json.mergepatch;
exports org.xbib.content.json.patch;
exports org.xbib.content.json.pointer;
requires com.fasterxml.jackson.databind;
}

View file

@ -0,0 +1,4 @@
module org.xbib.content.language {
exports org.xbib.content.language;
exports org.xbib.content.language.enums;
}

View file

@ -1,3 +1,5 @@
dependencies {
compile project(':content-xml')
implementation project(':content-core')
implementation project(':content-resource')
implementation project(':content-xml')
}

View file

@ -0,0 +1,17 @@
module org.xbib.content.rdf {
exports org.xbib.content.rdf;
exports org.xbib.content.rdf.internal;
exports org.xbib.content.rdf.io.json;
exports org.xbib.content.rdf.io.nquads;
exports org.xbib.content.rdf.io.ntriple;
exports org.xbib.content.rdf.io.rdfxml;
exports org.xbib.content.rdf.io.sink;
exports org.xbib.content.rdf.io.source;
exports org.xbib.content.rdf.io.turtle;
exports org.xbib.content.rdf.io.xml;
exports org.xbib.content.rdf.util;
requires org.xbib.content.core;
requires org.xbib.content.resource;
requires org.xbib.content.xml;
requires java.xml;
}

View file

@ -13,19 +13,15 @@ import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
*/
public class DefaultRdfGraph implements RdfGraph<RdfGraphParams> {
private static final Logger logger = Logger.getLogger(DefaultRdfGraph.class.getName());
private RdfGraphParams params = DefaultRdfGraphParams.DEFAULT_PARAMS;
private Map<IRI, Resource> resources = new LinkedHashMap<>();
private final Map<IRI, Resource> resources = new LinkedHashMap<>();
@Override
public Iterator<Resource> getResources() {
@ -151,8 +147,6 @@ public class DefaultRdfGraph implements RdfGraph<RdfGraphParams> {
if (r != null) {
list.add(new DefaultTriple(resource1, pred, r.id()));
list.addAll(unfold(r));
} else {
logger.log(Level.SEVERE, "huh? {}", resource1.id());
}
} else {
list.addAll(unfold(resource1));

View file

@ -18,7 +18,6 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;
import java.util.stream.Collectors;
/**
@ -27,8 +26,9 @@ import java.util.stream.Collectors;
public class DefaultResource implements Resource, Comparable<Resource>, XSDResourceIdentifiers {
static final String GENID = "genid";
static final String PLACEHOLDER = "_:";
private static final Logger logger = Logger.getLogger(DefaultResource.class.getName());
private static final String UNDERSCORE = "_";
private final MultiMap<IRI, Node> attributes;
@ -164,7 +164,6 @@ public class DefaultResource implements Resource, Comparable<Resource>, XSDResou
return child.add(triple);
} else {
// nothing found, continue with a new resource with new subject
logger.info("nothing found!!! my ID is " + id());
return new DefaultResource(otherId).add(triple);
}
}

View file

@ -15,15 +15,12 @@ import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
*/
public class JsonContentGenerator implements RdfContentGenerator<JsonContentParams>, Flushable {
private static final Logger logger = Logger.getLogger(JsonContentGenerator.class.getName());
private final Writer writer;
private boolean nsWritten;
@ -54,16 +51,12 @@ public class JsonContentGenerator implements RdfContentGenerator<JsonContentPara
}
@Override
public JsonContentGenerator receive(IRI iri) {
public JsonContentGenerator receive(IRI iri) throws IOException {
if (!iri.equals(resource.id())) {
try {
if (!nsWritten) {
writeNamespaces();
}
resource = new DefaultResource(iri);
} catch (IOException e) {
logger.log(Level.FINE, e.getMessage(), e);
if (!nsWritten) {
writeNamespaces();
}
resource = new DefaultResource(iri);
}
return this;
}

View file

@ -3,18 +3,15 @@ package org.xbib.content.rdf.io.nquads;
import org.xbib.content.rdf.io.sink.CharSink;
import org.xbib.content.rdf.io.sink.QuadSink;
import java.io.EOFException;
import java.io.IOException;
import java.util.BitSet;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Implementation of streaming NQuads parser.
*/
public final class NQuadsParser implements CharSink {
private static final Logger logger = Logger.getLogger(NQuadsParser.class.getName());
private static final short PARSING_OUTSIDE = 0;
private static final short PARSING_URI = 1;
private static final short PARSING_BNODE = 2;
@ -296,7 +293,7 @@ public final class NQuadsParser implements CharSink {
@Override
public void endStream() throws IOException {
if (tokenStartPos != -1 || waitingForSentenceEnd) {
logger.log(Level.WARNING, "unexpected end of stream");
throw new EOFException();
}
sink.endStream();
}

View file

@ -5,8 +5,6 @@ import org.xbib.content.rdf.io.sink.CharSink;
import org.xbib.content.rdf.io.sink.QuadSink;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Implementation of {@link org.xbib.content.rdf.io.sink.TripleSink} which serializes triples to
@ -14,8 +12,6 @@ import java.util.logging.Logger;
*/
public class NQuadsSerializer extends NTriplesSerializer implements QuadSink {
private static final Logger logger = Logger.getLogger(NQuadsSerializer.class.getName());
private final CharSink sink;
private NQuadsSerializer(CharSink sink) {
@ -34,50 +30,38 @@ public class NQuadsSerializer extends NTriplesSerializer implements QuadSink {
}
@Override
public void addNonLiteral(String subj, String pred, String obj, String graph) {
try {
startTriple(subj, pred);
serializeBnodeOrUri(obj);
if (graph != null) {
serializeBnodeOrUri(graph);
}
sink.process(DOT_EOL);
} catch (IOException e) {
logger.log(Level.FINE, e.getMessage(), e);
public void addNonLiteral(String subj, String pred, String obj, String graph) throws IOException {
startTriple(subj, pred);
serializeBnodeOrUri(obj);
if (graph != null) {
serializeBnodeOrUri(graph);
}
sink.process(DOT_EOL);
}
@Override
public void addPlainLiteral(String subj, String pred, String content, String lang, String graph) {
try {
startTriple(subj, pred);
addContent(content);
if (lang != null) {
sink.process('@').process(lang);
}
sink.process(SPACE);
if (graph != null) {
serializeBnodeOrUri(graph);
}
sink.process(DOT_EOL);
} catch (IOException e) {
logger.log(Level.FINE, e.getMessage(), e);
public void addPlainLiteral(String subj, String pred, String content, String lang, String graph) throws IOException {
startTriple(subj, pred);
addContent(content);
if (lang != null) {
sink.process('@').process(lang);
}
sink.process(SPACE);
if (graph != null) {
serializeBnodeOrUri(graph);
}
sink.process(DOT_EOL);
}
@Override
public void addTypedLiteral(String subj, String pred, String content, String type, String graph) {
try {
startTriple(subj, pred);
addContent(content);
sink.process("^^");
serializeUri(type);
if (graph != null) {
serializeBnodeOrUri(graph);
}
sink.process(DOT_EOL);
} catch (IOException e) {
logger.log(Level.FINE, e.getMessage(), e);
public void addTypedLiteral(String subj, String pred, String content, String type, String graph) throws IOException {
startTriple(subj, pred);
addContent(content);
sink.process("^^");
serializeUri(type);
if (graph != null) {
serializeBnodeOrUri(graph);
}
sink.process(DOT_EOL);
}
}

View file

@ -13,8 +13,6 @@ import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* NTriple content generator.
@ -22,8 +20,6 @@ import java.util.logging.Logger;
public class NTripleContentGenerator
implements RdfContentGenerator<NTripleContentParams>, Flushable {
private static final Logger logger = Logger.getLogger(NTripleContentGenerator.class.getName());
private static final char LF = '\n';
private final Writer writer;
@ -95,13 +91,9 @@ public class NTripleContentGenerator
@Override
public NTripleContentGenerator receive(Resource resource) throws IOException {
resource.triples().forEach(t -> {
try {
writer.write(writeStatement(t));
} catch (IOException e) {
logger.log(Level.FINE, e.getMessage(), e);
}
});
for (Triple t : resource.triples()) {
writer.write(writeStatement(t));
}
return this;
}

View file

@ -5,16 +5,12 @@ import org.xbib.content.rdf.io.sink.TripleSink;
import java.io.IOException;
import java.util.BitSet;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Implementation of streaming <a href="http://www.w3.org/2001/sw/RDFCore/ntriples/">NTriples</a> parser.
*/
public final class NTriplesParser implements CharSink {
private static final Logger logger = Logger.getLogger(NTriplesParser.class.getName());
private static final short PARSING_OUTSIDE = 0;
private static final short PARSING_URI = 1;
private static final short PARSING_BNODE = 2;
@ -118,7 +114,7 @@ public final class NTriplesParser implements CharSink {
parsingState = PARSING_OUTSIDE;
processOutsideChar(buffer, pos);
} else {
logger.log(Level.SEVERE, "unexpected character '" + buffer[pos] + "' after literal");
throw new IOException("unexpected character '" + buffer[pos] + "' after literal");
}
} else if (parsingState == PARSING_LITERAL_TYPE) {
processLiteralTypeChar(buffer, pos);
@ -159,7 +155,7 @@ public final class NTriplesParser implements CharSink {
} else if (type.startsWith("^^<") && type.charAt(type.length() - 2) == '>') {
onTypedLiteral(literalObj, type.substring(3, type.length() - 2 - trimSize));
} else {
logger.log(Level.SEVERE, "literal type '" + type + "' can not be parsed");
throw new IOException("literal type '" + type + "' can not be parsed");
}
parsingState = PARSING_OUTSIDE;
if (trimSize > 0) {
@ -190,7 +186,7 @@ public final class NTriplesParser implements CharSink {
break;
default:
if (!WHITESPACE.get(buffer[pos])) {
logger.log(Level.SEVERE, "unexpected character '" + buffer[pos] + "'");
throw new IOException("unexpected character '" + buffer[pos] + "'");
}
}
}
@ -199,13 +195,13 @@ public final class NTriplesParser implements CharSink {
if (waitingForSentenceEnd) {
waitingForSentenceEnd = false;
} else {
logger.log(Level.SEVERE, "unexpected end of sentence");
throw new IOException("unexpected end of sentence");
}
}
private void onNonLiteral(String uri) throws IOException {
if (waitingForSentenceEnd) {
logger.log(Level.SEVERE, "endStream of sentence expected");
throw new IOException("endStream of sentence expected");
}
if (subj == null) {
subj = uri;
@ -220,9 +216,9 @@ public final class NTriplesParser implements CharSink {
private void onPlainLiteral(String value, String lang) throws IOException {
if (subj == null || pred == null) {
if (waitingForSentenceEnd) {
logger.log(Level.SEVERE, "end of sentence expected");
throw new IOException("end of sentence expected");
} else {
logger.log(Level.SEVERE, "literal is not an object");
throw new IOException("literal is not an object");
}
}
sink.addPlainLiteral(subj, pred, value, lang);
@ -232,9 +228,9 @@ public final class NTriplesParser implements CharSink {
private void onTypedLiteral(String value, String type) throws IOException {
if (subj == null || pred == null) {
if (waitingForSentenceEnd) {
logger.log(Level.SEVERE, "end of sentence expected");
throw new IOException("end of sentence expected");
} else {
logger.log(Level.SEVERE, "literal is not an object");
throw new IOException("literal is not an object");
}
}
sink.addTypedLiteral(subj, pred, value, type);
@ -281,7 +277,7 @@ public final class NTriplesParser implements CharSink {
@Override
public void endStream() throws IOException {
if (tokenStartPos != -1 || waitingForSentenceEnd) {
logger.log(Level.SEVERE, "unexpected end of stream");
throw new IOException("unexpected end of stream");
}
sink.endStream();
}
@ -331,7 +327,7 @@ public final class NTriplesParser implements CharSink {
case 'U':
int sequenceLength = ch == 'u' ? 4 : 8;
if (i + sequenceLength >= limit) {
logger.log(Level.SEVERE, "error parsing escape sequence '\\" + ch + "'");
throw new IOException("error parsing escape sequence '\\" + ch + "'");
}
String code = str.substring(i + 1, i + 1 + sequenceLength);
i += sequenceLength;
@ -340,7 +336,7 @@ public final class NTriplesParser implements CharSink {
int value = Integer.parseInt(code, 16);
result.append((char) value);
} catch (NumberFormatException nfe) {
logger.log(Level.SEVERE, "error parsing escape sequence '\\" + ch + "'");
throw new IOException("error parsing escape sequence '\\" + ch + "'");
}
break;
default:

View file

@ -6,8 +6,6 @@ import org.xbib.content.rdf.io.sink.TripleSink;
import java.io.IOException;
import java.util.BitSet;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Implementation of {@link org.xbib.content.rdf.io.sink.TripleSink} which serializes triples to
@ -17,7 +15,6 @@ public class NTriplesSerializer implements TripleSink, RDF {
protected static final String DOT_EOL = ".\n";
protected static final char SPACE = ' ';
private static final Logger logger = Logger.getLogger(NTriplesSerializer.class.getName());
private static final char QUOTE = '"';
private static final char URI_START = '<';
private static final char URI_END = '>';
@ -118,7 +115,7 @@ public class NTriplesSerializer implements TripleSink, RDF {
return str;
}
StringBuilder result = new StringBuilder(limit);
result.append(str.substring(0, pos));
result.append(str, 0, pos);
for (; pos < limit; pos++) {
char ch = str.charAt(pos);
if (ch < 0x80) {
@ -151,41 +148,29 @@ public class NTriplesSerializer implements TripleSink, RDF {
}
@Override
public void addNonLiteral(String subj, String pred, String obj) {
try {
startTriple(subj, pred);
serializeBnodeOrUri(obj);
sink.process(DOT_EOL);
} catch (IOException e) {
logger.log(Level.FINE, e.getMessage(), e);
}
public void addNonLiteral(String subj, String pred, String obj) throws IOException {
startTriple(subj, pred);
serializeBnodeOrUri(obj);
sink.process(DOT_EOL);
}
@Override
public void addPlainLiteral(String subj, String pred, String content, String lang) {
try {
startTriple(subj, pred);
addContent(content);
if (lang != null) {
sink.process('@').process(lang);
}
sink.process(SPACE).process(DOT_EOL);
} catch (IOException e) {
logger.log(Level.FINE, e.getMessage(), e);
public void addPlainLiteral(String subj, String pred, String content, String lang) throws IOException {
startTriple(subj, pred);
addContent(content);
if (lang != null) {
sink.process('@').process(lang);
}
sink.process(SPACE).process(DOT_EOL);
}
@Override
public void addTypedLiteral(String subj, String pred, String content, String type) {
try {
startTriple(subj, pred);
addContent(content);
sink.process("^^");
serializeUri(type);
sink.process(DOT_EOL);
} catch (IOException e) {
logger.log(Level.FINE, e.getMessage(), e);
}
public void addTypedLiteral(String subj, String pred, String content, String type) throws IOException {
startTriple(subj, pred);
addContent(content);
sink.process("^^");
serializeUri(type);
sink.process(DOT_EOL);
}
@Override

View file

@ -18,16 +18,12 @@ import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* RDF/XML writer.
*/
public class RdfXmlContentGenerator implements RdfContentGenerator<RdfXmlContentParams>, Flushable, RdfConstants {
private static final Logger logger = Logger.getLogger(RdfXmlContentGenerator.class.getName());
private final Writer writer;
private boolean writingStarted;
@ -119,7 +115,9 @@ public class RdfXmlContentGenerator implements RdfContentGenerator<RdfXmlContent
}
startRDF();
writeHeader();
resource.triples().forEach(this::writeTriple);
for (Triple t : resource.triples()) {
writeTriple(t);
}
endRDF();
return this;
}
@ -213,74 +211,70 @@ public class RdfXmlContentGenerator implements RdfContentGenerator<RdfXmlContent
}
}
private RdfXmlContentGenerator writeTriple(Triple triple) {
try {
if (!writingStarted) {
throw new IOException("document writing has not yet been started");
}
Resource subj = triple.subject();
IRI pred = triple.predicate();
Node obj = triple.object();
String predString = pred.toString();
int predSplitIdx = findURISplitIndex(predString);
if (predSplitIdx == -1) {
throw new IOException("unable to create XML namespace-qualified name for predicate: " + predString);
}
String predNamespace = predString.substring(0, predSplitIdx);
String predLocalName = predString.substring(predSplitIdx);
if (!headerWritten) {
writeHeader();
}
if (!subj.equals(lastWrittenSubject)) {
flushPendingStatements();
writeNewLine();
writeStartOfStartTag(NS_URI, "Description");
if (subj.isEmbedded()) {
writeAttribute(NS_URI, "nodeID", subj.toString());
} else {
writeAttribute(NS_URI, "about", subj.toString());
}
writer.write(">");
writeNewLine();
lastWrittenSubject = subj;
}
writer.write("\t");
writeStartOfStartTag(predNamespace, predLocalName);
if (obj instanceof Resource) {
Resource objRes = (Resource) obj;
if (objRes.isEmbedded()) {
writeAttribute(NS_URI, "nodeID", objRes.id().toString());
} else {
writeAttribute(NS_URI, "resource", objRes.id().toString());
}
writer.write("/>");
} else if (obj instanceof Literal) {
Literal l = (Literal) obj;
if (l.lang() != null) {
writeAttribute("xml:lang", l.lang());
}
boolean isXMLLiteral = false;
IRI datatype = l.type();
if (datatype != null) {
isXMLLiteral = datatype.equals(RDF_XMLLITERAL);
if (isXMLLiteral) {
writeAttribute(NS_URI, "parseType", "Literal");
} else {
writeAttribute(NS_URI, "datatype", datatype.toString());
}
}
writer.write(">");
if (isXMLLiteral) {
writer.write(obj.toString());
} else {
writer.write(escapeCharacterData(obj.toString()));
}
writeEndTag(predNamespace, predLocalName);
}
writeNewLine();
} catch (IOException e) {
logger.log(Level.FINE, e.getMessage(), e);
private RdfXmlContentGenerator writeTriple(Triple triple) throws IOException {
if (!writingStarted) {
throw new IOException("document writing has not yet been started");
}
Resource subj = triple.subject();
IRI pred = triple.predicate();
Node obj = triple.object();
String predString = pred.toString();
int predSplitIdx = findURISplitIndex(predString);
if (predSplitIdx == -1) {
throw new IOException("unable to create XML namespace-qualified name for predicate: " + predString);
}
String predNamespace = predString.substring(0, predSplitIdx);
String predLocalName = predString.substring(predSplitIdx);
if (!headerWritten) {
writeHeader();
}
if (!subj.equals(lastWrittenSubject)) {
flushPendingStatements();
writeNewLine();
writeStartOfStartTag(NS_URI, "Description");
if (subj.isEmbedded()) {
writeAttribute(NS_URI, "nodeID", subj.toString());
} else {
writeAttribute(NS_URI, "about", subj.toString());
}
writer.write(">");
writeNewLine();
lastWrittenSubject = subj;
}
writer.write("\t");
writeStartOfStartTag(predNamespace, predLocalName);
if (obj instanceof Resource) {
Resource objRes = (Resource) obj;
if (objRes.isEmbedded()) {
writeAttribute(NS_URI, "nodeID", objRes.id().toString());
} else {
writeAttribute(NS_URI, "resource", objRes.id().toString());
}
writer.write("/>");
} else if (obj instanceof Literal) {
Literal l = (Literal) obj;
if (l.lang() != null) {
writeAttribute("xml:lang", l.lang());
}
boolean isXMLLiteral = false;
IRI datatype = l.type();
if (datatype != null) {
isXMLLiteral = datatype.equals(RDF_XMLLITERAL);
if (isXMLLiteral) {
writeAttribute(NS_URI, "parseType", "Literal");
} else {
writeAttribute(NS_URI, "datatype", datatype.toString());
}
}
writer.write(">");
if (isXMLLiteral) {
writer.write(obj.toString());
} else {
writer.write(escapeCharacterData(obj.toString()));
}
writeEndTag(predNamespace, predLocalName);
}
writeNewLine();
return this;
}

View file

@ -16,8 +16,8 @@ import org.xbib.content.rdf.internal.DefaultLiteral;
import org.xbib.content.rdf.internal.DefaultTriple;
import org.xbib.content.rdf.io.xml.XmlHandler;
import org.xbib.content.resource.IRI;
import org.xbib.content.resource.IRINamespaceContext;
import org.xbib.content.resource.IRISyntaxException;
import org.xbib.content.resource.NamespaceContext;
import org.xbib.content.resource.Node;
import org.xbib.content.xml.util.XMLUtil;
import org.xml.sax.Attributes;
@ -38,8 +38,6 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
@ -56,8 +54,6 @@ import javax.xml.parsers.SAXParserFactory;
*/
public class RdfXmlContentParser<R extends RdfContentParams> implements RdfConstants, RdfContentParser<R> {
private static final Logger logger = Logger.getLogger(RdfXmlContentParser.class.getName());
private final Reader reader;
private final Resource resource = new DefaultAnonymousResource();
@ -245,7 +241,6 @@ public class RdfXmlContentParser<R extends RdfContentParams> implements RdfConst
try {
uri = IRI.create(uriString);
} catch (IRISyntaxException e) {
logger.log(Level.FINE, e.getMessage(), e);
// illegal URI, try repair
uri = IRI.create(uriString
.replace(" ", "%20")
@ -418,18 +413,18 @@ public class RdfXmlContentParser<R extends RdfContentParams> implements RdfConst
private StringBuilder xmlLiteral = null;
private IRINamespaceContext namespaceContext;
private NamespaceContext namespaceContext;
private int literalLevel = 0; // level in XMLLiteral
@Override
public XmlHandler<R> setNamespaceContext(IRINamespaceContext namespaceContext) {
public XmlHandler<R> setNamespaceContext(NamespaceContext namespaceContext) {
this.namespaceContext = namespaceContext;
return this;
}
@Override
public IRINamespaceContext getNamespaceContext() {
public NamespaceContext getNamespaceContext() {
return namespaceContext;
}

View file

@ -1,5 +1,7 @@
package org.xbib.content.rdf.io.sink;
import java.io.IOException;
/**
* Interface for quad consuming.
*/
@ -12,8 +14,9 @@ public interface QuadSink extends TripleSink {
* @param pred predicate's IRI
* @param obj object's IRI or BNode name
* @param graph graph's IRI
* @throws IOException if handling of triple fails
*/
void addNonLiteral(String subj, String pred, String obj, String graph);
void addNonLiteral(String subj, String pred, String obj, String graph) throws IOException;
/**
* Callback for handling triples with plain literal objects.
@ -23,8 +26,9 @@ public interface QuadSink extends TripleSink {
* @param content unescaped string representation of content
* @param lang content's lang, can be null if no language specified
* @param graph graph's IRI
* @throws IOException if handling of triple fails
*/
void addPlainLiteral(String subj, String pred, String content, String lang, String graph);
void addPlainLiteral(String subj, String pred, String content, String lang, String graph) throws IOException;
/**
* Callback for handling triples with typed literal objects.
@ -34,7 +38,8 @@ public interface QuadSink extends TripleSink {
* @param content unescaped string representation of content
* @param type literal datatype's IRI
* @param graph graph's IRI
* @throws IOException if handling of triple fails
*/
void addTypedLiteral(String subj, String pred, String content, String type, String graph);
void addTypedLiteral(String subj, String pred, String content, String type, String graph) throws IOException;
}

View file

@ -13,16 +13,13 @@ import org.xbib.content.rdf.internal.DefaultTriple;
import org.xbib.content.resource.IRI;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.Iterator;
/**
*
*/
public class RdfContentBuilderSink implements QuadSink {
private static final Logger logger = Logger.getLogger(RdfContentBuilderSink.class.getName());
private final RdfGraph<RdfGraphParams> graph;
private final RdfContentBuilderProvider<RdfGraphParams> provider;
@ -34,81 +31,57 @@ public class RdfContentBuilderSink implements QuadSink {
}
@Override
public void addNonLiteral(String subj, String pred, String obj) {
try {
Resource s = DefaultResource.create(graph.getParams().getNamespaceContext(), subj);
IRI p = IRI.create(pred);
Resource o = DefaultResource.create(graph.getParams().getNamespaceContext(), obj);
Triple t = new DefaultTriple(s, p, o);
graph.receive(t);
} catch (IOException e) {
logger.log(Level.SEVERE, e.getMessage(), e);
}
public void addNonLiteral(String subj, String pred, String obj) throws IOException {
Resource s = DefaultResource.create(graph.getParams().getNamespaceContext(), subj);
IRI p = IRI.create(pred);
Resource o = DefaultResource.create(graph.getParams().getNamespaceContext(), obj);
Triple t = new DefaultTriple(s, p, o);
graph.receive(t);
}
@Override
public void addNonLiteral(String subj, String pred, String obj, String graphIRI) {
try {
Resource s = DefaultResource.create(graph.getParams().getNamespaceContext(), subj);
IRI p = IRI.create(pred);
Resource o = DefaultResource.create(graph.getParams().getNamespaceContext(), obj);
Triple t = new DefaultTriple(s, p, o);
graph.receive(t);
} catch (IOException e) {
logger.log(Level.SEVERE, e.getMessage(), e);
}
public void addNonLiteral(String subj, String pred, String obj, String graphIRI) throws IOException {
Resource s = DefaultResource.create(graph.getParams().getNamespaceContext(), subj);
IRI p = IRI.create(pred);
Resource o = DefaultResource.create(graph.getParams().getNamespaceContext(), obj);
Triple t = new DefaultTriple(s, p, o);
graph.receive(t);
}
@Override
public void addPlainLiteral(String subj, String pred, String content, String lang) {
try {
Resource s = DefaultResource.create(graph.getParams().getNamespaceContext(), subj);
IRI p = IRI.create(pred);
Literal o = new DefaultLiteral(content).lang(lang);
Triple t = new DefaultTriple(s, p, o);
graph.receive(t);
} catch (IOException e) {
logger.log(Level.SEVERE, e.getMessage(), e);
}
public void addPlainLiteral(String subj, String pred, String content, String lang) throws IOException {
Resource s = DefaultResource.create(graph.getParams().getNamespaceContext(), subj);
IRI p = IRI.create(pred);
Literal o = new DefaultLiteral(content).lang(lang);
Triple t = new DefaultTriple(s, p, o);
graph.receive(t);
}
@Override
public void addPlainLiteral(String subj, String pred, String content, String lang, String graphIRI) {
try {
Resource s = DefaultResource.create(graph.getParams().getNamespaceContext(), subj);
IRI p = IRI.create(pred);
Literal o = new DefaultLiteral(content).lang(lang);
Triple t = new DefaultTriple(s, p, o);
graph.receive(t);
} catch (IOException e) {
logger.log(Level.SEVERE, e.getMessage(), e);
}
public void addPlainLiteral(String subj, String pred, String content, String lang, String graphIRI) throws IOException {
Resource s = DefaultResource.create(graph.getParams().getNamespaceContext(), subj);
IRI p = IRI.create(pred);
Literal o = new DefaultLiteral(content).lang(lang);
Triple t = new DefaultTriple(s, p, o);
graph.receive(t);
}
@Override
public void addTypedLiteral(String subj, String pred, String content, String type) {
try {
Resource s = DefaultResource.create(graph.getParams().getNamespaceContext(), subj);
IRI p = IRI.create(pred);
Literal o = new DefaultLiteral(content).type(IRI.create(type));
Triple t = new DefaultTriple(s, p, o);
graph.receive(t);
} catch (IOException e) {
logger.log(Level.SEVERE, e.getMessage(), e);
}
public void addTypedLiteral(String subj, String pred, String content, String type) throws IOException {
Resource s = DefaultResource.create(graph.getParams().getNamespaceContext(), subj);
IRI p = IRI.create(pred);
Literal o = new DefaultLiteral(content).type(IRI.create(type));
Triple t = new DefaultTriple(s, p, o);
graph.receive(t);
}
@Override
public void addTypedLiteral(String subj, String pred, String content, String type, String graphIRI) {
try {
Resource s = DefaultResource.create(graph.getParams().getNamespaceContext(), subj);
IRI p = IRI.create(pred);
Literal o = new DefaultLiteral(content).type(IRI.create(type));
Triple t = new DefaultTriple(s, p, o);
graph.receive(t);
} catch (IOException e) {
logger.log(Level.SEVERE, e.getMessage(), e);
}
public void addTypedLiteral(String subj, String pred, String content, String type, String graphIRI) throws IOException {
Resource s = DefaultResource.create(graph.getParams().getNamespaceContext(), subj);
IRI p = IRI.create(pred);
Literal o = new DefaultLiteral(content).type(IRI.create(type));
Triple t = new DefaultTriple(s, p, o);
graph.receive(t);
}
@Override
@ -125,22 +98,16 @@ public class RdfContentBuilderSink implements QuadSink {
public void endStream() throws IOException {
if (graph.getResources() != null) {
if (provider != null) {
graph.getResources().forEachRemaining(resource -> {
Iterator<Resource> iterator = graph.getResources();
while (iterator.hasNext()) {
Resource resource = iterator.next();
RdfContentBuilder<RdfGraphParams> rdfContentBuilder;
try {
rdfContentBuilder = provider.newContentBuilder();
rdfContentBuilder.startStream();
rdfContentBuilder.receive(resource);
rdfContentBuilder.endStream();
} catch (IOException e) {
logger.log(Level.SEVERE, e.getMessage(), e);
}
});
} else {
logger.log(Level.WARNING, "no RDF content builder provider");
}
}
} else {
logger.log(Level.WARNING, "no graph resources");
}
}

View file

@ -1,5 +1,7 @@
package org.xbib.content.rdf.io.sink;
import java.io.IOException;
/**
* Interface for triple consuming.
*/
@ -11,8 +13,9 @@ public interface TripleSink extends Sink {
* @param subj subject's IRI or BNode name
* @param pred predicate's IRI
* @param obj object's IRI or BNode name
* @throws IOException if handling of triple fails
*/
void addNonLiteral(String subj, String pred, String obj);
void addNonLiteral(String subj, String pred, String obj) throws IOException;
/**
* Callback for handling triples with plain literal objects.
@ -21,8 +24,9 @@ public interface TripleSink extends Sink {
* @param pred predicate's IRI
* @param content unescaped string representation of content
* @param lang content's lang, can be null if no language specified
* @throws IOException if handling of triple fails
*/
void addPlainLiteral(String subj, String pred, String content, String lang);
void addPlainLiteral(String subj, String pred, String content, String lang) throws IOException;
/**
* Callback for handling triples with typed literal objects.
@ -31,7 +35,7 @@ public interface TripleSink extends Sink {
* @param pred predicate's IRI
* @param content unescaped string representation of content
* @param type literal datatype's IRI
* @throws IOException if handling of triple fails
*/
void addTypedLiteral(String subj, String pred, String content, String type);
void addTypedLiteral(String subj, String pred, String content, String type) throws IOException;
}

View file

@ -19,16 +19,12 @@ import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.util.LinkedList;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
*/
public class TurtleContentGenerator implements RdfContentGenerator<TurtleContentParams>, Flushable {
private static final Logger logger = Logger.getLogger(TurtleContentGenerator.class.getName());
private static final char LF = '\n';
private static final char TAB = '\t';
private static final String TYPE = RdfConstants.NS_URI + "type";
@ -43,15 +39,15 @@ public class TurtleContentGenerator implements RdfContentGenerator<TurtleContent
private Node lastObject;
private LinkedList<Resource> embedded;
private final LinkedList<Resource> embedded;
private LinkedList<Triple> triples;
private final LinkedList<Triple> triples;
private Triple triple;
private boolean nsWritten;
private StringBuilder sb;
private final StringBuilder sb;
private Resource resource;
@ -117,13 +113,9 @@ public class TurtleContentGenerator implements RdfContentGenerator<TurtleContent
@Override
public RdfContentGenerator<TurtleContentParams> receive(Resource resource) throws IOException {
resource.triples().forEach(t -> {
try {
for (Triple t : resource.triples()) {
writeTriple(t);
} catch (IOException e) {
logger.log(Level.FINE, e.getMessage(), e);
}
});
}
while (!embedded.isEmpty()) {
closeEmbeddedResource();
}

View file

@ -16,8 +16,9 @@ import org.xbib.content.rdf.internal.DefaultLiteral;
import org.xbib.content.rdf.internal.DefaultResource;
import org.xbib.content.rdf.internal.DefaultTriple;
import org.xbib.content.resource.IRI;
import org.xbib.content.resource.NamespaceContext;
import org.xbib.content.resource.Node;
import org.xbib.content.resource.XmlNamespaceContext;
import org.xbib.content.xml.XmlNamespaceContext;
import java.io.EOFException;
import java.io.IOException;
@ -29,8 +30,6 @@ import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Turtle - Terse RDF Triple Parser.
@ -41,8 +40,6 @@ import java.util.logging.Logger;
*/
public class TurtleContentParser<R extends RdfContentParams> implements RdfContentParser<R> {
private static final Logger logger = Logger.getLogger(TurtleContentParser.class.getName());
private final Resource resource = new DefaultAnonymousResource();
private final HashMap<String, Node> bnodes = new HashMap<>();
@ -93,7 +90,7 @@ public class TurtleContentParser<R extends RdfContentParams> implements RdfConte
/**
* The namespace context.
*/
private XmlNamespaceContext context = XmlNamespaceContext.newDefaultInstance();
private NamespaceContext context;
public TurtleContentParser(InputStream in) throws IOException {
this(new InputStreamReader(in, StandardCharsets.UTF_8));
@ -101,6 +98,7 @@ public class TurtleContentParser<R extends RdfContentParams> implements RdfConte
public TurtleContentParser(Reader reader) {
this.reader = new PushbackReader(reader, 2);
this.context = XmlNamespaceContext.newInstance();
}
public static String decode(String s, String encoding) throws UnsupportedEncodingException {
@ -154,7 +152,7 @@ public class TurtleContentParser<R extends RdfContentParams> implements RdfConte
return this;
}
public TurtleContentParser<R> context(XmlNamespaceContext context) {
public TurtleContentParser<R> context(NamespaceContext context) {
this.context = context;
return this;
}
@ -781,7 +779,7 @@ public class TurtleContentParser<R extends RdfContentParams> implements RdfConte
if ((char) ch != v) {
String message = (subject != null ? subject : "") + " unexpected character: '" +
(char) ch + "' expected: '" + v + "'";
logger.log(Level.WARNING, message);
throw new IOException(message);
}
}

View file

@ -8,8 +8,6 @@ import java.io.IOException;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Implementation of {@link org.xbib.content.rdf.io.sink.TripleSink} which serializes triples to {@link
@ -18,8 +16,6 @@ import java.util.logging.Logger;
*/
public final class TurtleSerializer implements TripleSink, RDF {
private static final Logger logger = Logger.getLogger(TurtleSerializer.class.getName());
private static final String DOT_EOL = " .\n";
private static final String COMMA_EOL = " ,\n";
private static final String SEMICOLON_EOL = " ;\n";
@ -58,47 +54,35 @@ public final class TurtleSerializer implements TripleSink, RDF {
}
@Override
public void addNonLiteral(String subj, String pred, String obj) {
try {
startTriple(subj, pred);
if (obj.startsWith(BNODE_PREFIX)) {
if (!namedBnodes.contains(obj) && obj.endsWith(SHORTENABLE_BNODE_SUFFIX)) {
openBnode(obj);
} else {
sink.process(obj);
}
public void addNonLiteral(String subj, String pred, String obj) throws IOException {
startTriple(subj, pred);
if (obj.startsWith(BNODE_PREFIX)) {
if (!namedBnodes.contains(obj) && obj.endsWith(SHORTENABLE_BNODE_SUFFIX)) {
openBnode(obj);
} else {
serializeUri(obj);
sink.process(obj);
}
} catch (IOException e) {
logger.log(Level.FINE, e.getMessage(), e);
} else {
serializeUri(obj);
}
}
@Override
public void addPlainLiteral(String subj, String pred, String content, String lang) {
try {
startTriple(subj, pred);
addContent(content);
if (lang != null) {
sink.process('@').process(lang);
}
} catch (IOException e) {
logger.log(Level.FINE, e.getMessage(), e);
public void addPlainLiteral(String subj, String pred, String content, String lang) throws IOException {
startTriple(subj, pred);
addContent(content);
if (lang != null) {
sink.process('@').process(lang);
}
}
@Override
public void addTypedLiteral(String subj, String pred, String content, String type) {
try {
startTriple(subj, pred);
addContent(content);
sink.process("^^");
serializeUri(type);
} catch (IOException e) {
logger.log(Level.FINE, e.getMessage(), e);
}
}
public void addTypedLiteral(String subj, String pred, String content, String type) throws IOException {
startTriple(subj, pred);
addContent(content);
sink.process("^^");
serializeUri(type);
}
@Override
public void startStream() throws IOException {

View file

@ -2,7 +2,7 @@ package org.xbib.content.rdf.io.xml;
import org.xbib.content.rdf.RdfContentBuilder;
import org.xbib.content.rdf.RdfContentParams;
import org.xbib.content.resource.IRINamespaceContext;
import org.xbib.content.resource.NamespaceContext;
import org.xml.sax.ContentHandler;
import org.xml.sax.DTDHandler;
import org.xml.sax.EntityResolver;
@ -15,9 +15,9 @@ import org.xml.sax.ErrorHandler;
public interface XmlHandler<P extends RdfContentParams>
extends EntityResolver, DTDHandler, ContentHandler, ErrorHandler {
IRINamespaceContext getNamespaceContext();
NamespaceContext getNamespaceContext();
XmlHandler<P> setNamespaceContext(IRINamespaceContext namespaceContext);
XmlHandler<P> setNamespaceContext(NamespaceContext namespaceContext);
XmlHandler<P> setDefaultNamespace(String prefix, String uri);

View file

@ -1,14 +1,14 @@
package org.xbib.content.rdf;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.xbib.content.resource.IRI;
import org.xbib.content.resource.IRINamespaceContext;
/**
*
*/
public class IRINamespaceCompactionTest extends Assert {
public class IRINamespaceCompactionTest {
@Test
public void testCompaction() throws Exception {

View file

@ -1,27 +1,32 @@
package org.xbib.content.rdf;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.xbib.content.resource.IRI;
import org.xbib.content.resource.IRISyntaxException;
/**
*
*/
public class IRITest extends Assert {
public class IRITest {
@Test
public void testJsonLd() {
IRI iri = IRI.create("@context");
assertEquals(null, iri.getScheme());
assertNull(iri.getScheme());
assertEquals("@context", iri.getSchemeSpecificPart());
}
@Test(expected = IRISyntaxException.class)
@Test
public void testIllegalBlankNodeIRI() {
IRI iri = IRI.create("_:a1");
assertEquals("_", iri.getScheme());
assertEquals("a1", iri.getSchemeSpecificPart());
Assertions.assertThrows(IRISyntaxException.class, () -> {
IRI iri = IRI.create("_:a1");
assertEquals("_", iri.getScheme());
assertEquals("a1", iri.getSchemeSpecificPart());
});
}
@Test

View file

@ -1,9 +1,9 @@
package org.xbib.content.rdf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.xbib.content.rdf.RdfXContentFactory.rdfXContentBuilder;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.xbib.content.rdf.internal.DefaultLiteral;
import org.xbib.content.rdf.internal.DefaultResource;
import org.xbib.content.resource.IRI;
@ -11,7 +11,7 @@ import org.xbib.content.resource.IRI;
/**
*
*/
public class RdfXContentGeneratorTest extends Assert {
public class RdfXContentGeneratorTest {
@Test
public void testContentBuilder() throws Exception {

View file

@ -1,13 +1,14 @@
package org.xbib.content.rdf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.xbib.content.rdf.RdfXContentFactory.routeRdfXContentBuilder;
import static org.xbib.content.rdf.StreamTester.assertStream;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.xbib.content.rdf.internal.DefaultLiteral;
import org.xbib.content.rdf.internal.DefaultResource;
import org.xbib.content.rdf.io.rdfxml.RdfXmlContentParser;
import org.xbib.content.resource.IRI;
import org.xbib.helper.StreamTester;
import java.io.IOException;
import java.io.InputStream;
@ -18,7 +19,7 @@ import java.nio.charset.StandardCharsets;
/**
*
*/
public class RouteRdfXContentBuilderTest extends StreamTester {
public class RouteRdfXContentBuilderTest {
@Test
public void testRoute() throws Exception {

View file

@ -1,26 +1,26 @@
package org.xbib.helper;
import org.junit.Assert;
package org.xbib.content.rdf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import java.io.InputStream;
import java.io.Reader;
/**
*
*/
public class StreamTester extends Assert {
public class StreamTester {
protected static void assertStream(InputStream expected, InputStream actual) {
public static void assertStream(InputStream expected, InputStream actual) {
int offset = 0;
try {
while (true) {
final int exp = expected.read();
if (exp == -1) {
assertEquals("Expecting end of actual stream at offset " + offset, -1, actual.read());
assertEquals(-1, actual.read());
break;
} else {
final int act = actual.read();
assertEquals("Expecting same data at offset " + offset, exp, act);
assertEquals(exp, act);
}
offset++;
}
@ -37,11 +37,11 @@ public class StreamTester extends Assert {
while (true) {
final int exp = expected.read();
if (exp == -1) {
assertEquals("Expecting end of actual stream at offset " + offset, -1, actual.read());
assertEquals(-1, actual.read(), "Expecting end of actual stream at offset " + offset);
break;
} else {
final int act = actual.read();
assertEquals("Expecting same data at offset " + offset, exp, act);
assertEquals(exp, act, "Expecting same data at offset " + offset);
}
offset++;
}

View file

@ -1,7 +1,7 @@
package org.xbib.content.rdf.internal;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.xbib.content.rdf.Resource;
import org.xbib.content.rdf.Triple;
import org.xbib.content.resource.IRI;
@ -11,7 +11,7 @@ import java.util.Iterator;
/**
*
*/
public class BlankNodeTest extends Assert {
public class BlankNodeTest {
@Test
public void testBlankNodeRenumbering() throws Exception {

View file

@ -1,13 +1,13 @@
package org.xbib.content.rdf.internal;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.xbib.content.resource.IRI;
/**
*
*/
public class LiteralTest extends Assert {
public class LiteralTest {
@Test
public void testLiteral() {

View file

@ -1,9 +1,11 @@
package org.xbib.content.rdf.internal;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.xbib.content.rdf.RdfContentFactory.ntripleBuilder;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.xbib.content.rdf.Literal;
import org.xbib.content.rdf.RdfContentBuilder;
import org.xbib.content.rdf.Resource;
@ -19,16 +21,16 @@ import java.util.Iterator;
/**
*
*/
public class ResourceTest extends Assert {
public class ResourceTest {
@Test
public void deleted() throws Exception {
Resource r = new DefaultAnonymousResource();
assertEquals(r.isDeleted(), false);
assertFalse(r.isDeleted());
r.setDeleted(true);
assertEquals(r.isDeleted(), true);
assertTrue(r.isDeleted());
r.setDeleted(false);
assertEquals(r.isDeleted(), false);
assertFalse(r.isDeleted());
}
@Test
@ -44,7 +46,7 @@ public class ResourceTest extends Assert {
@Test
public void testEmptyResources() throws Exception {
Resource r = new DefaultResource(IRI.create("urn:root"));
assertEquals(r.isEmpty(), true);
assertTrue(r.isEmpty());
assertEquals(r.toString(), "urn:root");
}
@ -52,14 +54,14 @@ public class ResourceTest extends Assert {
public void testEmptyProperty() throws Exception {
Resource r = new DefaultResource(IRI.create("urn:root"));
r.add("urn:property", (String) null);
assertEquals(r.isEmpty(), true);
assertTrue(r.isEmpty());
}
@Test
public void testStringLiteral() throws Exception {
Resource r = new DefaultResource(IRI.create("urn:root"));
r.add("urn:property", "Hello World");
assertEquals(r.isEmpty(), false);
assertFalse(r.isEmpty());
assertEquals(r.triples().get(0).object().toString(), "Hello World");
}
@ -68,7 +70,7 @@ public class ResourceTest extends Assert {
Resource r = new DefaultResource(IRI.create("urn:root"));
DefaultLiteral literal = new DefaultLiteral(123).type(Literal.INT);
r.add("urn:property", literal);
assertEquals(r.isEmpty(), false);
assertFalse(r.isEmpty());
assertEquals(r.triples().get(0).object().toString(), "123^^xsd:int");
}

View file

@ -1,7 +1,7 @@
package org.xbib.content.rdf.internal;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.xbib.content.rdf.Resource;
import org.xbib.content.resource.IRI;
import org.xbib.content.resource.Node;
@ -9,7 +9,7 @@ import org.xbib.content.resource.Node;
/**
*
*/
public class TripleTest extends Assert {
public class TripleTest {
@Test
public void testSimpleTriple() {

View file

@ -2,12 +2,13 @@ package org.xbib.content.rdf.io.json;
import static org.xbib.content.rdf.RdfContentFactory.jsonBuilder;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.xbib.content.rdf.RdfContentBuilder;
import org.xbib.content.rdf.io.xml.XmlHandler;
import org.xbib.content.resource.IRI;
import org.xbib.content.resource.IRINamespaceContext;
import org.xbib.helper.StreamTester;
import org.xbib.content.resource.NamespaceContext;
import org.xbib.content.rdf.StreamTester;
import java.io.IOException;
import java.io.InputStream;
@ -55,7 +56,7 @@ public class JsonReaderTest extends StreamTester {
}
@Override
public XmlHandler<JsonContentParams> setNamespaceContext(IRINamespaceContext namespaceContext) {
public XmlHandler<JsonContentParams> setNamespaceContext(NamespaceContext namespaceContext) {
return this;
}

View file

@ -2,9 +2,9 @@ package org.xbib.content.rdf.io.ntriple;
import static org.xbib.content.rdf.RdfContentFactory.ntripleBuilder;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.xbib.content.rdf.RdfContentBuilder;
import org.xbib.helper.StreamTester;
import org.xbib.content.rdf.StreamTester;
import java.io.IOException;
import java.io.InputStream;

View file

@ -1,9 +1,10 @@
package org.xbib.content.rdf.io.ntriple;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.xbib.content.rdf.RdfContentFactory.ntripleBuilder;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.xbib.content.rdf.RdfContentBuilder;
import org.xbib.content.rdf.Resource;
import org.xbib.content.rdf.XSDResourceIdentifiers;
@ -14,7 +15,7 @@ import org.xbib.content.resource.IRI;
/**
*
*/
public class NTripleTest extends Assert {
public class NTripleTest {
@Test
public void testNTripleBuilder() throws Exception {

View file

@ -2,8 +2,7 @@ package org.xbib.content.rdf.io.rdfxml;
import static org.xbib.content.rdf.RdfContentFactory.ntripleBuilder;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Test;
import org.xbib.content.rdf.RdfContent;
import org.xbib.content.rdf.RdfContentBuilder;
import org.xbib.content.rdf.Resource;
@ -11,12 +10,11 @@ import org.xbib.content.rdf.Triple;
import org.xbib.content.rdf.internal.DefaultLiteral;
import org.xbib.content.rdf.internal.DefaultRdfGraph;
import org.xbib.content.rdf.internal.DefaultTriple;
import org.xbib.content.rdf.io.IOTests;
import org.xbib.content.rdf.io.ntriple.NTripleContent;
import org.xbib.content.rdf.io.ntriple.NTripleContentParams;
import org.xbib.content.resource.IRI;
import org.xbib.content.resource.Node;
import org.xbib.helper.StreamTester;
import org.xbib.content.rdf.StreamTester;
import java.io.IOException;
import java.io.InputStream;
@ -25,14 +23,12 @@ import java.util.Iterator;
/**
*
*/
@Category(IOTests.class)
public class EuropeanaEDMReaderTest extends StreamTester {
private static final IRI GEO_LAT = IRI.create("http://www.w3.org/2003/01/geo/wgs84_pos#lat");
private static final IRI GEO_LON = IRI.create("http://www.w3.org/2003/01/geo/wgs84_pos#long");
private static final IRI location = IRI.create("location");
@SuppressWarnings("unchecked")
@Test
public void testEuropeana() throws Exception {
String filename = "oai_edm.xml";
@ -56,7 +52,7 @@ public class EuropeanaEDMReaderTest extends StreamTester {
builder.streamInput());
}
private class GeoJSONFilter extends RdfContentBuilder<NTripleContentParams> {
private static class GeoJSONFilter extends RdfContentBuilder<NTripleContentParams> {
DefaultRdfGraph graph;

View file

@ -2,28 +2,22 @@ package org.xbib.content.rdf.io.rdfxml;
import static org.xbib.content.rdf.RdfContentFactory.turtleBuilder;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Test;
import org.xbib.content.rdf.RdfContentFactory;
import org.xbib.content.rdf.io.IOTests;
import org.xbib.content.rdf.io.ntriple.NTripleContentParams;
import org.xbib.content.rdf.io.turtle.TurtleContentParams;
import org.xbib.content.resource.IRINamespaceContext;
import org.xbib.helper.StreamTester;
import org.xbib.content.rdf.StreamTester;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.util.logging.Logger;
/**
*
*/
@Category(IOTests.class)
public class GNDRdfXmlReaderTest extends StreamTester {
private static final Logger logger = Logger.getLogger(GNDRdfXmlReaderTest.class.getName());
@Test
public void testGNDfromRdfXmltoTurtle() throws Exception {
String filename = "GND.rdf";

View file

@ -2,28 +2,22 @@ package org.xbib.content.rdf.io.rdfxml;
import static org.xbib.content.rdf.RdfContentFactory.turtleBuilder;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Test;
import org.xbib.content.rdf.internal.DefaultAnonymousResource;
import org.xbib.content.rdf.io.IOTests;
import org.xbib.content.rdf.io.turtle.TurtleContentParams;
import org.xbib.content.resource.IRINamespaceContext;
import org.xbib.helper.StreamTester;
import org.xbib.content.rdf.StreamTester;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.util.logging.Logger;
/**
*
*/
@Category(IOTests.class)
public class RdfXmlReaderTest extends StreamTester {
private static final Logger logger = Logger.getLogger(RdfXmlReaderTest.class.getName());
@Test
public void testReader() throws Exception {
String filename = "118540238.xml";

View file

@ -2,12 +2,10 @@ package org.xbib.content.rdf.io.rdfxml;
import static org.xbib.content.rdf.RdfContentFactory.turtleBuilder;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.xbib.content.rdf.io.IOTests;
import org.junit.jupiter.api.Test;
import org.xbib.content.rdf.io.turtle.TurtleContentParams;
import org.xbib.content.resource.IRINamespaceContext;
import org.xbib.helper.StreamTester;
import org.xbib.content.rdf.StreamTester;
import java.io.IOException;
import java.io.InputStream;
@ -17,7 +15,6 @@ import java.io.StringReader;
/**
*
*/
@Category(IOTests.class)
public class VIAFRdfXmlReaderTest extends StreamTester {
@Test

View file

@ -1,22 +1,18 @@
package org.xbib.content.rdf.io.turtle;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.xbib.content.rdf.RdfContentFactory;
import org.xbib.content.resource.IRI;
import org.xbib.helper.StreamTester;
import org.xbib.content.rdf.StreamTester;
import java.io.InputStream;
import java.text.MessageFormat;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
*/
public class TurtleConformanceTest extends StreamTester {
private static final Logger logger = Logger.getLogger(TurtleConformanceTest.class.getName());
@Test
public void conformance() throws Exception {
for (int n = 0; n < 30; n++) {
@ -26,10 +22,9 @@ public class TurtleConformanceTest extends StreamTester {
.setBaseIRI(IRI.create("http://example/base/"));
turtleParser.setRdfContentBuilderProvider(RdfContentFactory::turtleBuilder);
turtleParser.setRdfContentBuilderHandler(b -> {
logger.log(Level.INFO, MessageFormat.format("turtle test {0}", b.string()));
//logger.log(Level.INFO, MessageFormat.format("turtle test {0}", b.string()));
});
turtleParser.parse();
}
}
}

View file

@ -1,17 +1,17 @@
package org.xbib.content.rdf.io.turtle;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.xbib.content.rdf.RdfContentFactory.turtleBuilder;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Test;
import org.xbib.content.rdf.RdfContentBuilder;
import org.xbib.content.rdf.RdfContentFactory;
import org.xbib.content.rdf.Resource;
import org.xbib.content.rdf.internal.DefaultResource;
import org.xbib.content.rdf.io.IOTests;
import org.xbib.content.resource.IRI;
import org.xbib.content.resource.IRINamespaceContext;
import org.xbib.helper.StreamTester;
import org.xbib.content.resource.NamespaceContext;
import org.xbib.content.rdf.StreamTester;
import java.io.BufferedReader;
import java.io.InputStream;
@ -21,12 +21,11 @@ import java.nio.charset.StandardCharsets;
/**
*
*/
@Category(IOTests.class)
public class TurtleTest extends StreamTester {
@Test
public void testTurtleGND() throws Exception {
IRINamespaceContext context = IRINamespaceContext.newInstance();
NamespaceContext context = IRINamespaceContext.newInstance();
context.addNamespace("gnd", "http://d-nb.info/gnd/");
InputStream in = getClass().getResourceAsStream("GND.ttl");
TurtleContentParser<TurtleContentParams> reader = new TurtleContentParser<TurtleContentParams>(in)

View file

@ -2,21 +2,18 @@ package org.xbib.content.rdf.io.xml;
import static org.xbib.content.rdf.RdfContentFactory.turtleBuilder;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Test;
import org.xbib.content.rdf.RdfContentBuilder;
import org.xbib.content.rdf.io.IOTests;
import org.xbib.content.rdf.io.turtle.TurtleContentParams;
import org.xbib.content.resource.IRI;
import org.xbib.content.resource.IRINamespaceContext;
import org.xbib.helper.StreamTester;
import org.xbib.content.resource.NamespaceContext;
import org.xbib.content.rdf.StreamTester;
import org.xbib.net.PercentEncoders;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
@ -25,10 +22,7 @@ import javax.xml.namespace.QName;
*/
public class OAITest extends StreamTester {
private static final Logger logger = Logger.getLogger(OAITest.class.getName());
@Test
@Category(IOTests.class)
public void testOAIListRecordsToTurtle() throws Exception {
String filename = "oai-listrecords.xml";
InputStream in = getClass().getResourceAsStream(filename);
@ -38,7 +32,7 @@ public class OAITest extends StreamTester {
IRINamespaceContext context = IRINamespaceContext.newInstance();
XmlContentParams params = new XmlContentParams(context);
XmlHandler<TurtleContentParams> xmlHandler = new AbstractXmlResourceHandler<TurtleContentParams>(params) {
XmlHandler<TurtleContentParams> xmlHandler = new AbstractXmlResourceHandler<>(params) {
@Override
public boolean isResourceDelimiter(QName name) {
@ -53,7 +47,7 @@ public class OAITest extends StreamTester {
getResource().setId(IRI.create("id:" +
PercentEncoders.getRegNameEncoder(StandardCharsets.UTF_8).encode(value)));
} catch (IOException e) {
logger.log(Level.FINE, e.getMessage(), e);
// ignore
}
}
}
@ -64,7 +58,7 @@ public class OAITest extends StreamTester {
}
@Override
public XmlHandler<TurtleContentParams> setNamespaceContext(IRINamespaceContext namespaceContext) {
public XmlHandler<TurtleContentParams> setNamespaceContext(NamespaceContext namespaceContext) {
return this;
}

View file

@ -1,21 +1,21 @@
package org.xbib.content.rdf.io.xml;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.xbib.content.rdf.RdfContentFactory.turtleBuilder;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Test;
import org.xbib.content.rdf.RdfContentBuilder;
import org.xbib.content.rdf.Resource;
import org.xbib.content.rdf.Triple;
import org.xbib.content.rdf.internal.DefaultAnonymousResource;
import org.xbib.content.rdf.internal.DefaultResource;
import org.xbib.content.rdf.io.IOTests;
import org.xbib.content.rdf.io.ntriple.NTripleContent;
import org.xbib.content.rdf.io.ntriple.NTripleContentParams;
import org.xbib.content.rdf.io.turtle.TurtleContentParams;
import org.xbib.content.resource.IRI;
import org.xbib.content.resource.IRINamespaceContext;
import org.xbib.helper.StreamTester;
import org.xbib.content.resource.NamespaceContext;
import org.xbib.content.rdf.StreamTester;
import org.xbib.net.PercentEncoders;
import java.io.IOException;
@ -23,19 +23,14 @@ import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
/**
*
*/
@Category(IOTests.class)
public class XmlReaderTest extends StreamTester {
private static final Logger logger = Logger.getLogger(XmlReaderTest.class.getName());
@Test
public void testOAIDC() throws Exception {
String filename = "oro-eprint-25656.xml";
@ -49,7 +44,7 @@ public class XmlReaderTest extends StreamTester {
namespaceContext.addNamespace("dc", "http://purl.org/dc/elements/1.1/");
XmlContentParams params = new XmlContentParams(namespaceContext);
XmlHandler<TurtleContentParams> xmlHandler = new AbstractXmlResourceHandler<TurtleContentParams>(params) {
XmlHandler<TurtleContentParams> xmlHandler = new AbstractXmlResourceHandler<>(params) {
@Override
public boolean isResourceDelimiter(QName name) {
@ -64,7 +59,7 @@ public class XmlReaderTest extends StreamTester {
getResource().setId(IRI.create("id:" +
PercentEncoders.getRegNameEncoder(StandardCharsets.UTF_8).encode(value)));
} catch (IOException e) {
logger.log(Level.FINE, e.getMessage(), e);
// swallow
}
}
}
@ -76,7 +71,7 @@ public class XmlReaderTest extends StreamTester {
}
@Override
public XmlHandler<TurtleContentParams> setNamespaceContext(IRINamespaceContext namespaceContext) {
public XmlHandler<TurtleContentParams> setNamespaceContext(NamespaceContext namespaceContext) {
return this;
}
@ -104,7 +99,7 @@ public class XmlReaderTest extends StreamTester {
}
IRINamespaceContext namespaceContext = IRINamespaceContext.newInstance();
XmlContentParams params = new XmlContentParams(namespaceContext);
AbstractXmlHandler<NTripleContentParams> xmlHandler = new AbstractXmlResourceHandler<NTripleContentParams>(params) {
AbstractXmlHandler<NTripleContentParams> xmlHandler = new AbstractXmlResourceHandler<>(params) {
@Override
public boolean isResourceDelimiter(QName name) {
@ -122,7 +117,7 @@ public class XmlReaderTest extends StreamTester {
}
@Override
public XmlHandler<NTripleContentParams> setNamespaceContext(IRINamespaceContext namespaceContext) {
public XmlHandler<NTripleContentParams> setNamespaceContext(NamespaceContext namespaceContext) {
return this;
}
@ -153,7 +148,7 @@ public class XmlReaderTest extends StreamTester {
}
IRINamespaceContext namespaceContext = IRINamespaceContext.newInstance();
XmlContentParams params = new XmlContentParams(namespaceContext);
AbstractXmlHandler<NTripleContentParams> xmlHandler = new AbstractXmlResourceHandler<NTripleContentParams>(params) {
AbstractXmlHandler<NTripleContentParams> xmlHandler = new AbstractXmlResourceHandler<>(params) {
@Override
public boolean isResourceDelimiter(QName name) {
return false;
@ -170,7 +165,7 @@ public class XmlReaderTest extends StreamTester {
}
@Override
public XmlHandler<NTripleContentParams> setNamespaceContext(IRINamespaceContext namespaceContext) {
public XmlHandler<NTripleContentParams> setNamespaceContext(NamespaceContext namespaceContext) {
return this;
}
@ -194,7 +189,7 @@ public class XmlReaderTest extends StreamTester {
);
}
private class MyBuilder extends RdfContentBuilder<NTripleContentParams> {
private static class MyBuilder extends RdfContentBuilder<NTripleContentParams> {
final List<Triple> triples = new LinkedList<>();

View file

@ -1,22 +1,19 @@
package org.xbib.content.rdf.io.xml;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.xbib.content.rdf.RdfContentFactory.xmlBuilder;
import org.junit.Assert;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Test;
import org.xbib.content.rdf.RdfContentBuilder;
import org.xbib.content.rdf.Resource;
import org.xbib.content.rdf.internal.DefaultAnonymousResource;
import org.xbib.content.rdf.internal.DefaultResource;
import org.xbib.content.rdf.io.IOTests;
import org.xbib.content.resource.IRI;
/**
*
*/
@Category(IOTests.class)
public class XmlResourceWriterTest extends Assert {
public class XmlResourceWriterTest {
@Test
public void testXMLResourceWriter() throws Exception {

View file

@ -1,10 +1,8 @@
package org.xbib.content.rdf.util;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
/**

View file

@ -1,4 +0,0 @@
/**
* Classes for helpting the testing of RDF content.
*/
package org.xbib.helper;

View file

@ -1,4 +1,4 @@
dependencies {
compile "org.xbib:net-url:${project.property('xbib-net.version')}"
testCompile "com.fasterxml.jackson.core:jackson-databind:${project.property('jackson.version')}"
api "org.xbib:net-url:${project.property('xbib.net.version')}"
testImplementation "com.fasterxml.jackson.core:jackson-databind:${project.property('jackson.version')}"
}

View file

@ -0,0 +1,5 @@
module org.xbib.content.resource {
exports org.xbib.content.resource;
exports org.xbib.content.resource.text;
requires org.xbib.net.url;
}

View file

@ -1,36 +1,39 @@
package org.xbib.content.resource;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
/**
*
*/
public final class IRINamespaceContext extends XmlNamespaceContext {
public final class IRINamespaceContext implements NamespaceContext {
/**
* Share namespace.properties with {@link XmlNamespaceContext}.
*/
private static final String DEFAULT_RESOURCE =
XmlNamespaceContext.class.getPackage().getName().replace('.', '/') + '/' + "namespace";
IRINamespaceContext.class.getPackage().getName().replace('.', '/') + '/' + "namespace";
private static IRINamespaceContext instance;
private static final IRINamespaceContext DEFAULT_CONTEXT = newInstance(DEFAULT_RESOURCE);
// sort namespace by length in descending order, useful for compacting prefix
private final SortedMap<String, String> namespaces;
private final SortedMap<String, Set<String>> prefixes;
protected final Object lock;
private List<String> sortedNamespacesByPrefixLength;
private IRINamespaceContext() {
super();
}
private IRINamespaceContext(ResourceBundle bundle) {
super(bundle);
}
public static IRINamespaceContext getInstance() {
return DEFAULT_CONTEXT;
@ -55,9 +58,36 @@ public final class IRINamespaceContext extends XmlNamespaceContext {
return new IRINamespaceContext();
}
protected IRINamespaceContext() {
this.namespaces = new TreeMap<>();
this.prefixes = new TreeMap<>();
this.lock = new Object();
}
private IRINamespaceContext(ResourceBundle bundle) {
this();
Enumeration<String> en = bundle.getKeys();
while (en.hasMoreElements()) {
String prefix = en.nextElement();
String namespace = bundle.getString(prefix);
addNamespace(prefix, namespace);
}
}
@Override
public void addNamespace(String prefix, String namespace) {
super.addNamespace(prefix, namespace);
if (prefix != null && namespace != null) {
synchronized (lock) {
namespaces.put(prefix, namespace);
if (prefixes.containsKey(namespace)) {
prefixes.get(namespace).add(prefix);
} else {
Set<String> set = new HashSet<>();
set.add(prefix);
prefixes.put(namespace, set);
}
}
}
synchronized (lock) {
sortedNamespacesByPrefixLength = new ArrayList<>(getNamespaces().values());
// sort from longest to shortest prefix for successful matching
@ -71,7 +101,7 @@ public final class IRINamespaceContext extends XmlNamespaceContext {
public IRINamespaceContext add(Map<String, String> map) {
for (Map.Entry<String, String> e : map.entrySet()) {
super.addNamespace(e.getKey(), e.getValue());
addNamespace(e.getKey(), e.getValue());
}
synchronized (lock) {
sortedNamespacesByPrefixLength = new ArrayList<>(getNamespaces().values());
@ -131,4 +161,37 @@ public final class IRINamespaceContext extends XmlNamespaceContext {
public String getPrefix(IRI uri) {
return getNamespaceURI(uri.getScheme()) != null ? uri.getScheme() : getPrefix(uri.toString());
}
@Override
public SortedMap<String, String> getNamespaces() {
return namespaces;
}
@Override
public String getNamespaceURI(String prefix) {
if (prefix == null) {
return null;
}
return namespaces.getOrDefault(prefix, null);
}
@Override
public String getPrefix(String namespaceURI) {
Iterator<String> it = getPrefixes(namespaceURI);
return it != null && it.hasNext() ? it.next() : null;
}
@Override
public Iterator<String> getPrefixes(String namespace) {
if (namespace == null) {
throw new IllegalArgumentException("namespace URI cannot be null");
}
return prefixes.containsKey(namespace) ?
prefixes.get(namespace).iterator() : null;
}
@Override
public String toString() {
return namespaces.toString();
}
}

View file

@ -0,0 +1,17 @@
package org.xbib.content.resource;
import java.util.Iterator;
import java.util.SortedMap;
public interface NamespaceContext {
String getNamespaceURI(String prefix);
String getPrefix(String namespaceURI);
Iterator<String> getPrefixes(String namespaceURI);
SortedMap<String, String> getNamespaces();
void addNamespace(String prefix, String namespace);
}

View file

@ -1,4 +1,4 @@
dependencies {
compile project(':content-core')
compile "com.fasterxml.jackson.dataformat:jackson-dataformat-smile:${project.property('jackson.version')}"
implementation project(':content-core')
api "com.fasterxml.jackson.dataformat:jackson-dataformat-smile:${project.property('jackson.version')}"
}

View file

@ -0,0 +1,7 @@
module org.xbib.content.smile {
exports org.xbib.content.smile;
requires org.xbib.content.core;
requires com.fasterxml.jackson.dataformat.smile;
provides org.xbib.content.XContent with
org.xbib.content.smile.SmileXContent;
}

View file

@ -1,7 +1,6 @@
dependencies {
compile project(':content-core')
compile project(':content-resource')
compile "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${project.property('jackson.version')}"
compile "com.fasterxml.jackson.core:jackson-databind:${project.property('jackson-databind.version')}"
compile "com.fasterxml.woodstox:woodstox-core:${project.property('woodstox.version')}"
implementation project(':content-core')
implementation project(':content-resource')
api "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${project.property('jackson.version')}"
implementation "com.fasterxml.woodstox:woodstox-core:${project.property('woodstox.version')}"
}

View file

@ -0,0 +1,15 @@
module org.xbib.content.xml {
exports org.xbib.content.xml;
exports org.xbib.content.xml.json;
exports org.xbib.content.xml.json.events;
exports org.xbib.content.xml.stream;
exports org.xbib.content.xml.transform;
exports org.xbib.content.xml.util;
requires java.xml;
requires org.xbib.content.core;
requires org.xbib.content.resource;
requires com.fasterxml.jackson.core;
requires com.fasterxml.jackson.dataformat.xml;
provides org.xbib.content.XContent with
org.xbib.content.xml.XmlXContent;
}

View file

@ -1,4 +1,4 @@
package org.xbib.content.resource;
package org.xbib.content.xml;
import java.util.Enumeration;
import java.util.HashSet;
@ -15,12 +15,7 @@ import javax.xml.namespace.NamespaceContext;
/**
* Contains a simple context for XML namespaces.
*/
public class XmlNamespaceContext implements NamespaceContext {
private static final String DEFAULT_RESOURCE =
XmlNamespaceContext.class.getPackage().getName().replace('.', '/') + '/' + "namespace";
private static final XmlNamespaceContext DEFAULT_CONTEXT = newDefaultInstance();
public class XmlNamespaceContext implements NamespaceContext, org.xbib.content.resource.NamespaceContext {
// sort namespace by length in descending order, useful for compacting prefix
private final SortedMap<String, String> namespaces;
@ -45,10 +40,6 @@ public class XmlNamespaceContext implements NamespaceContext {
}
}
public static XmlNamespaceContext getInstance() {
return DEFAULT_CONTEXT;
}
/**
* Empty namespace context.
*
@ -58,22 +49,10 @@ public class XmlNamespaceContext implements NamespaceContext {
return new XmlNamespaceContext();
}
public static XmlNamespaceContext newDefaultInstance() {
return newInstance(DEFAULT_RESOURCE);
}
/**
* Use thread context class laoder to instantiate a namespace context.
* @param bundleName the resource bundle name
* @return XML namespace context
*/
public static XmlNamespaceContext newInstance(String bundleName) {
return newInstance(bundleName, Locale.getDefault(), Thread.currentThread().getContextClassLoader());
}
public static XmlNamespaceContext newInstance(String bundleName, Locale locale, ClassLoader classLoader) {
try {
return new XmlNamespaceContext(ResourceBundle.getBundle(bundleName, locale, classLoader));
ResourceBundle bundle = ResourceBundle.getBundle(bundleName, locale, classLoader);
return new XmlNamespaceContext(bundle);
} catch (MissingResourceException e) {
return new XmlNamespaceContext();
}

View file

@ -17,8 +17,6 @@ import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
@ -29,8 +27,6 @@ import javax.xml.stream.XMLStreamException;
*/
public class XmlXContentGenerator extends AbstractXContentGenerator {
private static final Logger logger = Logger.getLogger(XmlXContentGenerator.class.getName());
private final XmlXContentGeneratorDelegate delegate;
private XmlXParams params;
@ -50,7 +46,7 @@ public class XmlXContentGenerator extends AbstractXContentGenerator {
return params;
}
public XmlXContentGenerator setParams(XmlXParams params) {
public XmlXContentGenerator setParams(XmlXParams params) throws IOException {
delegate.setParams(params);
return this;
}
@ -138,12 +134,12 @@ public class XmlXContentGenerator extends AbstractXContentGenerator {
this.params = params;
}
public void setParams(XmlXParams params) {
public void setParams(XmlXParams params) throws IOException {
this.params = params;
try {
generator.getStaxWriter().setPrefix(params.getRoot().getPrefix(), params.getRoot().getNamespaceURI());
} catch (XMLStreamException e) {
logger.log(Level.SEVERE, e.getMessage(), e);
throw new IOException(e);
}
}
@ -183,7 +179,7 @@ public class XmlXContentGenerator extends AbstractXContentGenerator {
generator.getStaxWriter().writeNamespace(prefix, uri);
}
} catch (XMLStreamException e) {
logger.log(Level.SEVERE, e.getMessage(), e);
throw new IOException(e);
}
rootUsed = true;
}

View file

@ -2,10 +2,6 @@ package org.xbib.content.xml;
import com.fasterxml.jackson.dataformat.xml.XmlFactory;
import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator;
import org.xbib.content.resource.XmlNamespaceContext;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLInputFactory;
@ -16,8 +12,6 @@ import javax.xml.stream.XMLOutputFactory;
*/
public class XmlXParams {
private static final Logger logger = Logger.getLogger(XmlXParams.class.getName());
private static final XmlXParams DEFAULT_PARAMS =
new XmlXParams(new QName("root"),
XmlNamespaceContext.newInstance(),
@ -69,35 +63,23 @@ public class XmlXParams {
// load from service factories in META-INF/services
// default impl is "com.sun.xml.internal.stream.XMLInputFactoryImpl"
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
try {
inputFactory.setProperty("javax.xml.stream.isNamespaceAware", Boolean.TRUE);
inputFactory.setProperty("javax.xml.stream.isValidating", Boolean.FALSE);
inputFactory.setProperty("javax.xml.stream.isCoalescing", Boolean.TRUE);
inputFactory.setProperty("javax.xml.stream.isReplacingEntityReferences", Boolean.FALSE);
inputFactory.setProperty("javax.xml.stream.isSupportingExternalEntities", Boolean.FALSE);
} catch (Exception e) {
logger.log(Level.SEVERE, e.getMessage(), e);
}
inputFactory.setProperty("javax.xml.stream.isNamespaceAware", Boolean.TRUE);
inputFactory.setProperty("javax.xml.stream.isValidating", Boolean.FALSE);
inputFactory.setProperty("javax.xml.stream.isCoalescing", Boolean.TRUE);
inputFactory.setProperty("javax.xml.stream.isReplacingEntityReferences", Boolean.FALSE);
inputFactory.setProperty("javax.xml.stream.isSupportingExternalEntities", Boolean.FALSE);
return inputFactory;
}
protected static XMLOutputFactory createXMLOutputFactory() {
XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
try {
outputFactory.setProperty("javax.xml.stream.isRepairingNamespaces", Boolean.FALSE);
} catch (Exception e) {
logger.log(Level.SEVERE, e.getMessage(), e);
}
outputFactory.setProperty("javax.xml.stream.isRepairingNamespaces", Boolean.FALSE);
return outputFactory;
}
protected static XmlFactory createXmlFactory(XMLInputFactory inputFactory, XMLOutputFactory outputFactory) {
XmlFactory xmlFactory = new XmlFactory(inputFactory, outputFactory);
try {
xmlFactory.configure(ToXmlGenerator.Feature.WRITE_XML_1_1, true);
} catch (Exception e) {
logger.log(Level.SEVERE, e.getMessage(), e);
}
xmlFactory.configure(ToXmlGenerator.Feature.WRITE_XML_1_1, true);
return xmlFactory;
}

View file

@ -11,7 +11,7 @@ import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import org.xbib.content.resource.XmlNamespaceContext;
import org.xbib.content.resource.NamespaceContext;
import org.xbib.content.xml.util.ToQName;
import org.xml.sax.ContentHandler;
import org.xml.sax.Locator;
@ -51,7 +51,7 @@ public class JsonSaxAdapter {
private QName root = new QName("root");
private XmlNamespaceContext context = XmlNamespaceContext.newDefaultInstance();
private NamespaceContext context;
public JsonSaxAdapter(Reader reader, ContentHandler contentHandler) throws IOException {
this(factory.createParser(reader), contentHandler);
@ -68,7 +68,7 @@ public class JsonSaxAdapter {
return this;
}
public JsonSaxAdapter context(XmlNamespaceContext context) {
public JsonSaxAdapter context(NamespaceContext context) {
this.context = context;
return this;
}
@ -163,7 +163,7 @@ public class JsonSaxAdapter {
qname.getLocalPart(), qname.getPrefix() + ":" + qname.getLocalPart());
}
private void writeNamespaceDeclarations(XmlNamespaceContext context) throws SAXException {
private void writeNamespaceDeclarations(NamespaceContext context) throws SAXException {
Set<String> keys = new TreeSet<>(context.getNamespaces().keySet());
if (root != null && !keys.contains(root.getPrefix())) {
contentHandler.startPrefixMapping(root.getPrefix(), root.getNamespaceURI());

View file

@ -1,6 +1,6 @@
package org.xbib.content.xml.json;
import org.xbib.content.resource.XmlNamespaceContext;
import org.xbib.content.xml.XmlNamespaceContext;
import org.xbib.content.xml.transform.StylesheetTransformer;
import org.xml.sax.InputSource;
@ -9,6 +9,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import javax.xml.namespace.QName;
@ -24,7 +25,7 @@ public class JsonStylesheet {
private QName root = new QName("root");
private XmlNamespaceContext context = XmlNamespaceContext.newDefaultInstance();
private XmlNamespaceContext context;
private StylesheetTransformer transformer;
@ -51,7 +52,7 @@ public class JsonStylesheet {
}
public JsonStylesheet transform(InputStream in, OutputStream out) throws IOException {
return transform(in, new OutputStreamWriter(out, "UTF-8"));
return transform(in, new OutputStreamWriter(out, StandardCharsets.UTF_8));
}
public JsonStylesheet transform(InputStream in, Writer out) throws IOException {
@ -78,7 +79,7 @@ public class JsonStylesheet {
}
public JsonStylesheet toXML(InputStream in, OutputStream out) throws IOException {
return toXML(in, new OutputStreamWriter(out, "UTF-8"));
return toXML(in, new OutputStreamWriter(out, StandardCharsets.UTF_8));
}
public JsonStylesheet toXML(InputStream in, Writer out) throws IOException {

View file

@ -1,6 +1,6 @@
package org.xbib.content.xml.json;
import org.xbib.content.resource.XmlNamespaceContext;
import org.xbib.content.xml.XmlNamespaceContext;
import org.xml.sax.ContentHandler;
import org.xml.sax.DTDHandler;
import org.xml.sax.EntityResolver;
@ -33,9 +33,9 @@ public class JsonXmlReader implements XMLReader {
private QName root = new QName("root");
private XmlNamespaceContext context = XmlNamespaceContext.newDefaultInstance();
private XmlNamespaceContext context;
private Map<String, Boolean> map = new HashMap<>();
private final Map<String, Boolean> map;
private ContentHandler contentHandler;
@ -45,6 +45,10 @@ public class JsonXmlReader implements XMLReader {
private ErrorHandler errorHandler;
public JsonXmlReader() {
this.map = new HashMap<>();
}
public JsonXmlReader root(QName root) {
this.root = root;
return this;

View file

@ -4,7 +4,8 @@ import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import org.xbib.content.resource.XmlNamespaceContext;
import org.xbib.content.resource.NamespaceContext;
import org.xbib.content.xml.XmlNamespaceContext;
import org.xbib.content.xml.util.ToQName;
import java.io.IOException;
@ -39,12 +40,12 @@ public class JsonXmlStreamer {
private QName root;
private XmlNamespaceContext context;
private NamespaceContext context;
private Deque<QName> elements;
private final Deque<QName> elements;
public JsonXmlStreamer() {
context = XmlNamespaceContext.newDefaultInstance();
context = XmlNamespaceContext.newInstance();
root = new QName("root");
eventFactory = XMLEventFactory.newInstance();
outputFactory = XMLOutputFactory.newInstance();
@ -58,7 +59,7 @@ public class JsonXmlStreamer {
return this;
}
public JsonXmlStreamer context(XmlNamespaceContext context) {
public JsonXmlStreamer context(NamespaceContext context) {
this.context = context;
return this;
}

View file

@ -1,8 +1,6 @@
package org.xbib.content.xml.stream;
import java.io.StringWriter;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
import javax.xml.stream.Location;
@ -17,8 +15,6 @@ import javax.xml.stream.events.XMLEvent;
*/
public abstract class AbstractXMLEvent implements XMLEvent {
private static final Logger logger = Logger.getLogger(AbstractXMLEvent.class.getName());
/**
* The event location.
*/
@ -115,7 +111,7 @@ public abstract class AbstractXMLEvent implements XMLEvent {
try {
this.writeAsEncodedUnicode(writer);
} catch (XMLStreamException e) {
logger.log(Level.WARNING, e.getMessage(), e);
// ignore
}
return writer.toString();
}

View file

@ -3,8 +3,6 @@ package org.xbib.content.xml.stream;
import java.io.IOException;
import java.io.Writer;
import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import javax.xml.stream.XMLEventWriter;
@ -42,8 +40,6 @@ import javax.xml.stream.events.XMLEvent;
*/
public class IndentingXMLEventWriter extends EventWriterDelegate implements Indentation {
private static final Logger logger = Logger.getLogger(IndentingXMLEventWriter.class.getName());
private static final int WROTE_MARKUP = 1;
private static final int WROTE_DATA = 2;
/**
@ -153,7 +149,7 @@ public class IndentingXMLEventWriter extends EventWriterDelegate implements Inde
try {
newLineEvent.write(out, depth - 1);
} catch (Exception e) {
logger.log(Level.FINE, e.getMessage(), e);
// swallow
}
}
}

View file

@ -1,8 +1,5 @@
package org.xbib.content.xml.stream;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
@ -35,8 +32,6 @@ import javax.xml.stream.XMLStreamWriter;
*/
public class IndentingXMLStreamWriter extends StreamWriterDelegate implements Indentation {
private static final Logger logger = Logger.getLogger(IndentingXMLStreamWriter.class.getName());
private static final int WROTE_MARKUP = 1;
private static final int WROTE_DATA = 2;
/**
@ -254,7 +249,7 @@ public class IndentingXMLStreamWriter extends StreamWriterDelegate implements In
try {
writeNewLine(depth - 1);
} catch (XMLStreamException e) {
logger.log(Level.FINE, e.getMessage(), e);
// swallow
}
}
}
@ -270,7 +265,7 @@ public class IndentingXMLStreamWriter extends StreamWriterDelegate implements In
try {
writeNewLine(0);
} catch (XMLStreamException e) {
logger.log(Level.FINE, e.getMessage(), e);
// swallow
}
}
stack[depth] = 0; // start fresh

View file

@ -5,8 +5,6 @@ import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
@ -32,8 +30,6 @@ import javax.xml.stream.events.XMLEvent;
*/
public class StaxEventXMLReader extends AbstractStaxXMLReader {
private static final Logger logger = Logger.getLogger(StaxEventXMLReader.class.getName());
private final XMLEventReader reader;
/**
@ -52,7 +48,6 @@ public class StaxEventXMLReader extends AbstractStaxXMLReader {
throw new IllegalStateException("XMLEventReader not at start of document or element");
}
} catch (XMLStreamException ex) {
logger.log(Level.FINE, ex.getMessage(), ex);
throw new IllegalStateException("Could not read first element: " + ex.getMessage());
}
this.reader = reader;

View file

@ -1,26 +1,21 @@
package org.xbib.content.xml.transform;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.transform.ErrorListener;
import javax.xml.transform.TransformerException;
/**
* An {@link javax.xml.transform.ErrorListener} that reacts to errors when parsing (compiling) the stylesheet.
*/
public final class StylesheetErrorListener implements ErrorListener {
private static final Logger logger = Logger.getLogger(StylesheetErrorListener.class.getName());
public class DefaultStylesheetErrorListener implements ErrorListener {
@Override
public void warning(TransformerException e) throws TransformerException {
logger.log(Level.WARNING, "warning (recoverable): " + e.getMessage(), e);
//logger.log(Level.WARNING, "warning (recoverable): " + e.getMessage(), e);
}
@Override
public void error(TransformerException e) throws TransformerException {
logger.log(Level.WARNING, "error (recoverable): " + e.getMessage(), e);
//logger.log(Level.WARNING, "error (recoverable): " + e.getMessage(), e);
}
/**
@ -28,7 +23,7 @@ public final class StylesheetErrorListener implements ErrorListener {
*/
@Override
public void fatalError(TransformerException e) throws TransformerException {
logger.log(Level.WARNING, "fatal error: " + e.getMessage(), e);
//logger.log(Level.WARNING, "fatal error: " + e.getMessage(), e);
throw e;
}
}

View file

@ -3,8 +3,6 @@ package org.xbib.content.xml.transform;
import java.text.MessageFormat;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.transform.Source;
import javax.xml.transform.Templates;
@ -18,8 +16,6 @@ import javax.xml.transform.stream.StreamSource;
*/
public final class StylesheetPool {
private static final Logger logger = Logger.getLogger(StylesheetPool.class.getName());
/**
* A map of precompiled stylesheets ({@link javax.xml.transform.Templates} objects).
*/
@ -61,8 +57,6 @@ public final class StylesheetPool {
String systemId = source.getSystemId();
Templates template = stylesheets.get(systemId);
if (template == null) {
logger.log(Level.FINE, MessageFormat.format("new source={0} {1}",
source.getSystemId(), source.getClass().getName()));
template = transformerFactory.newTemplates(source);
stylesheets.put(systemId, template);
}

View file

@ -51,7 +51,7 @@ public class StylesheetTransformer implements Closeable {
if (transformerFactory == null) {
transformerFactory = (SAXTransformerFactory) TransformerFactory.newInstance();
}
transformerFactory.setErrorListener(new StylesheetErrorListener());
transformerFactory.setErrorListener(new DefaultStylesheetErrorListener());
setResolver(path == null ? new TransformerURIResolver() : new TransformerURIResolver(path));
return this;
}

View file

@ -1,8 +1,5 @@
package org.xbib.content.xml.transform;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.transform.ErrorListener;
import javax.xml.transform.TransformerException;
@ -12,8 +9,6 @@ import javax.xml.transform.TransformerException;
*/
public final class TransformerErrorListener implements ErrorListener {
private static final Logger logger = Logger.getLogger(TransformerErrorListener.class.getName());
/**
* We store the exception internally as a workaround to xalan, which reports
* {@link javax.xml.transform.TransformerException} as {@link RuntimeException} (wrapped).
@ -25,7 +20,7 @@ public final class TransformerErrorListener implements ErrorListener {
*/
@Override
public void warning(TransformerException e) throws TransformerException {
logger.log(Level.WARNING, "Warning (recoverable): " + e.getMessage(), e);
//logger.log(Level.WARNING, "Warning (recoverable): " + e.getMessage(), e);
}
/*
@ -33,7 +28,7 @@ public final class TransformerErrorListener implements ErrorListener {
*/
@Override
public void error(TransformerException e) throws TransformerException {
logger.log(Level.WARNING, "Error (recoverable): " + e.getMessage(), e);
//logger.log(Level.WARNING, "Error (recoverable): " + e.getMessage(), e);
}
/**
@ -41,7 +36,7 @@ public final class TransformerErrorListener implements ErrorListener {
*/
@Override
public void fatalError(TransformerException e) throws TransformerException {
logger.log(Level.SEVERE, "Fatal error: " + e.getMessage(), e);
//logger.log(Level.SEVERE, "Fatal error: " + e.getMessage(), e);
this.exception = e;
throw e;
}

View file

@ -14,8 +14,6 @@ import java.net.URL;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
@ -30,8 +28,6 @@ import javax.xml.transform.sax.SAXSource;
*/
public class TransformerURIResolver implements URIResolver, Closeable {
private static final Logger logger = Logger.getLogger(TransformerURIResolver.class.getName());
private List<InputStream> inputStreams = new LinkedList<>();
private List<String> bases = new LinkedList<>();
@ -78,7 +74,7 @@ public class TransformerURIResolver implements URIResolver, Closeable {
try {
in = url.openStream();
} catch (IOException e) {
logger.log(Level.WARNING, "error while opening stream", e);
// ignore
}
}
if (in == null) {

View file

@ -1,6 +1,6 @@
package org.xbib.content.xml.util;
import javax.xml.namespace.NamespaceContext;
import org.xbib.content.resource.NamespaceContext;
import javax.xml.namespace.QName;
/**

View file

@ -1,10 +1,9 @@
package org.xbib.content.xml;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.xbib.content.XContentBuilder;
import org.xbib.content.XContentHelper;
import org.xbib.content.resource.XmlNamespaceContext;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
@ -15,7 +14,7 @@ import javax.xml.namespace.QName;
/**
*
*/
public class XContentXmlBuilderTest extends Assert {
public class XContentXmlBuilderTest {
@Test
public void testConstructorForServiceLoader() {
@ -124,7 +123,7 @@ public class XContentXmlBuilderTest extends Assert {
@Test
public void testParseJson() throws Exception {
XmlNamespaceContext context = XmlNamespaceContext.newDefaultInstance();
XmlNamespaceContext context = XmlNamespaceContext.newInstance();
context.addNamespace("bib", "info:srw/cql-context-set/1/bib-v1/");
context.addNamespace("xbib", "http://xbib.org/");
context.addNamespace("abc", "http://localhost/");

View file

@ -1,10 +1,10 @@
package org.xbib.content.xml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.xbib.content.XContentBuilder;
import org.xbib.content.resource.XmlNamespaceContext;
import org.xbib.content.xml.transform.StylesheetTransformer;
import java.util.Locale;
import javax.xml.namespace.QName;
/**
@ -15,14 +15,14 @@ public class XmlNamespaceContextTest {
@Test
public void testDefaultNamespace() {
XmlNamespaceContext context = XmlNamespaceContext.newInstance();
assertTrue(context.getNamespaces().size() == 0);
context = XmlNamespaceContext.newDefaultInstance();
assertTrue(context.getNamespaces().size() > 0);
assertEquals(0, context.getNamespaces().size());
}
@Test
public void testDefaultNamespaces() throws Exception {
XmlNamespaceContext context = XmlNamespaceContext.newDefaultInstance();
XmlNamespaceContext context =
XmlNamespaceContext.newInstance("org/xbib/content/resource/namespace",
Locale.getDefault(), StylesheetTransformer.class.getClassLoader());
XmlXParams params = new XmlXParams(context);
XContentBuilder builder = XmlXContent.contentBuilder(params);
builder.startObject()

View file

@ -1,7 +1,7 @@
package org.xbib.content.xml.json;
import org.junit.Test;
import org.xbib.content.resource.XmlNamespaceContext;
import org.junit.jupiter.api.Test;
import org.xbib.content.xml.XmlNamespaceContext;
import org.xml.sax.InputSource;
import java.io.File;
import java.io.FileOutputStream;
@ -12,6 +12,7 @@ import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.util.Locale;
import javax.xml.namespace.QName;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
@ -70,7 +71,7 @@ public class Json2XmlTest {
private Writer getOutput(String path) throws IOException {
File file = File.createTempFile(path, ".dat");
return new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
return new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8);
}
private QName root() {
@ -78,12 +79,14 @@ public class Json2XmlTest {
}
private XmlNamespaceContext context() {
XmlNamespaceContext nsContext = XmlNamespaceContext.newDefaultInstance();
nsContext.addNamespace("bib", "info:srw/cql-context-set/1/bib-v1/");
nsContext.addNamespace("xbib", "http://xbib.org/");
nsContext.addNamespace("abc", "http://localhost/");
nsContext.addNamespace("lia", "http://xbib.org/namespaces/lia/");
return nsContext;
XmlNamespaceContext context =
XmlNamespaceContext.newInstance("org/xbib/content/resource/namespace",
Locale.getDefault(), Json2XmlTest.class.getClassLoader());
context.addNamespace("bib", "info:srw/cql-context-set/1/bib-v1/");
context.addNamespace("xbib", "http://xbib.org/");
context.addNamespace("abc", "http://localhost/");
context.addNamespace("lia", "http://xbib.org/namespaces/lia/");
return context;
}
}

View file

@ -1,13 +1,14 @@
package org.xbib.content.xml.json;
import org.junit.Test;
import org.xbib.content.resource.XmlNamespaceContext;
import org.junit.jupiter.api.Test;
import org.xbib.content.xml.XmlNamespaceContext;
import org.xbib.content.xml.transform.StylesheetTransformer;
import org.xml.sax.InputSource;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.Locale;
import javax.xml.namespace.QName;
import javax.xml.transform.sax.SAXSource;
@ -18,7 +19,9 @@ public class StylesheetTransformerTest {
private final QName root = new QName("http://example.org", "result", "ex");
private final XmlNamespaceContext context = XmlNamespaceContext.newDefaultInstance();
private final XmlNamespaceContext context =
XmlNamespaceContext.newInstance("org/xbib/content/resource/namespace",
Locale.getDefault(), StylesheetTransformer.class.getClassLoader());
@Test
public void testJsonAsXML() throws Exception {

View file

@ -1,6 +1,6 @@
package org.xbib.content.xml.util;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.xbib.content.xml.stream.SaxEventConsumer;
import org.xml.sax.helpers.DefaultHandler;
import java.util.LinkedList;

View file

@ -1,12 +1,12 @@
package org.xbib.content.xml.util;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
/**
*
*/
public class XMLUtilTest extends Assert {
public class XMLUtilTest {
@Test
public void testWhitespaceCleaner() {

View file

@ -1,4 +1,4 @@
dependencies {
compile project(':content-core')
compile "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${project.property('jackson.version')}"
}
api project(':content-core')
api "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${project.property('jackson.version')}"
}

View file

@ -0,0 +1,9 @@
module org.xbib.content.yaml {
exports org.xbib.content.yaml;
requires org.xbib.content.core;
requires com.fasterxml.jackson.dataformat.yaml;
provides org.xbib.content.XContent with
org.xbib.content.yaml.YamlXContent;
provides org.xbib.content.settings.SettingsLoader with
org.xbib.content.yaml.YamlSettingsLoader;
}

View file

@ -1,17 +1,12 @@
group = org.xbib
name = content
version = 2.1.0
version = 2.2.0
xbib-net.version = 2.0.3
gradle.wrapper.version = 6.4.1
xbib.net.version = 2.0.4
jackson.version = 2.9.10
jackson-databind.version = 2.9.10.1
woodstox.version = 6.0.2
# test
junit.version = 5.6.2
junit4.version = 4.13
hamcrest.version = 2.2
jackson.databind.version = 2.9.10.1
woodstox.version = 6.2.1
mockito.version = 3.1.0
# doc
junit4.version = 4.13
asciidoclet.version = 1.5.6

View file

@ -0,0 +1,35 @@
apply plugin: 'java-library'
java {
modularity.inferModulePath.set(true)
}
compileJava {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
compileTestJava {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
jar {
manifest {
attributes('Implementation-Version': project.version)
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier 'javadoc'
}
artifacts {
archives sourcesJar, javadocJar
}

View file

@ -0,0 +1,36 @@
apply plugin: 'org.xbib.gradle.plugin.asciidoctor'
configurations {
asciidoclet
}
dependencies {
asciidoclet "org.asciidoctor:asciidoclet:${project.property('asciidoclet.version')}"
}
subprojects {
/*javadoc {
options.docletpath = configurations.asciidoclet.files.asType(List)
options.doclet = 'org.asciidoctor.Asciidoclet'
//options.overview = "src/docs/asciidoclet/overview.adoc"
options.addStringOption "-base-dir", "${projectDir}"
options.addStringOption "-attribute",
"name=${project.name},version=${project.version},title-link=https://github.com/xbib/${project.name}"
configure(options) {
noTimestamp = true
}
}*/
asciidoctor {
attributes 'source-highlighter': 'coderay',
toc: 'left',
doctype: 'book',
icons: 'font',
encoding: 'utf-8',
sectlink: true,
sectanchors: true,
linkattrs: true,
imagesdir: 'img'
}
}

13
gradle/ide/idea.gradle Normal file
View file

@ -0,0 +1,13 @@
apply plugin: 'idea'
idea {
module {
outputDir file('build/classes/java/main')
testOutputDir file('build/classes/java/test')
}
}
if (project.convention.findPlugin(JavaPluginConvention)) {
//sourceSets.main.output.classesDirs = file("build/classes/java/main")
//sourceSets.test.output.classesDirs = file("build/classes/java/test")
}

View file

@ -0,0 +1,64 @@
apply plugin: "de.marcphilipp.nexus-publish"
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
pom {
name = project.name
description = rootProject.ext.description
url = rootProject.ext.url
inceptionYear = rootProject.ext.inceptionYear
packaging = 'jar'
organization {
name = 'xbib'
url = 'https://xbib.org'
}
developers {
developer {
id = 'jprante'
name = 'Jörg Prante'
email = 'joergprante@gmail.com'
url = 'https://github.com/jprante'
}
}
scm {
url = rootProject.ext.scmUrl
connection = rootProject.ext.scmConnection
developerConnection = rootProject.ext.scmDeveloperConnection
}
issueManagement {
system = rootProject.ext.issueManagementSystem
url = rootProject.ext.issueManagementUrl
}
licenses {
license {
name = rootProject.ext.licenseName
url = rootProject.ext.licenseUrl
distribution = 'repo'
}
}
}
}
}
}
if (project.hasProperty("signing.keyId")) {
apply plugin: 'signing'
signing {
sign publishing.publications.mavenJava
}
}
nexusPublishing {
repositories {
sonatype {
username = project.property('ossrhUsername')
password = project.property('ossrhPassword')
packageGroup = "org.xbib"
}
}
}

View file

@ -0,0 +1,11 @@
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"
}
}

27
gradle/test/junit5.gradle Normal file
View file

@ -0,0 +1,27 @@
def junitVersion = project.hasProperty('junit.version')?project.property('junit.version'):'5.6.2'
def hamcrestVersion = project.hasProperty('hamcrest.version')?project.property('hamcrest.version'):'2.2'
dependencies {
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-params:${junitVersion}"
testImplementation "org.hamcrest:hamcrest-library:${hamcrestVersion}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
}
test {
useJUnitPlatform()
failFast = true
testLogging {
events 'STARTED', 'PASSED', 'FAILED', 'SKIPPED'
}
afterSuite { desc, result ->
if (!desc.parent) {
println "\nTest result: ${result.resultType}"
println "Test summary: ${result.testCount} tests, " +
"${result.successfulTestCount} succeeded, " +
"${result.failedTestCount} failed, " +
"${result.skippedTestCount} skipped"
}
}
}

Binary file not shown.

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

31
gradlew vendored
View file

@ -82,6 +82,7 @@ esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@ -129,6 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
@ -154,19 +156,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
i=`expr $i + 1`
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
@ -175,14 +177,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

Some files were not shown because too many files have changed in this diff Show more