Skip to content

Commit

Permalink
Merge pull request #3562 from Fedict/GH-1841-ntripleparser-deprecated…
Browse files Browse the repository at this point in the history
…-settings

GH-1841: remove deprecated NTriples / Trix parser settings
  • Loading branch information
abrokenjester authored Jan 5, 2022
2 parents 04cb36a + 7b6cdce commit 4f3cee4
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ public ParserConfig(boolean verifyData, boolean stopAtFirstError, boolean preser
// parser to attempt to recover.
if (!stopAtFirstError) {
Set<RioSetting<?>> nonFatalErrors = new HashSet<>();
nonFatalErrors.add(TriXParserSettings.FAIL_ON_TRIX_INVALID_STATEMENT);
nonFatalErrors.add(TriXParserSettings.FAIL_ON_TRIX_MISSING_DATATYPE);
nonFatalErrors.add(NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES);
nonFatalErrors.add(TriXParserSettings.FAIL_ON_INVALID_STATEMENT);
nonFatalErrors.add(TriXParserSettings.FAIL_ON_MISSING_DATATYPE);
nonFatalErrors.add(NTriplesParserSettings.FAIL_ON_INVALID_LINES);
if (verifyData) {
nonFatalErrors.add(BasicParserSettings.VERIFY_RELATIVE_URIS);
if (datatypeHandling == DatatypeHandling.IGNORE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,14 @@ public boolean preserveBNodeIDs() {
@Deprecated
@Override
public void setStopAtFirstError(boolean stopAtFirstError) {
getParserConfig().set(NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES, stopAtFirstError);
getParserConfig().set(NTriplesParserSettings.FAIL_ON_INVALID_LINES, stopAtFirstError);
if (!stopAtFirstError) {
getParserConfig().addNonFatalError(NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES);
getParserConfig().addNonFatalError(NTriplesParserSettings.FAIL_ON_INVALID_LINES);
} else {
// TODO: Add a ParserConfig.removeNonFatalError function to avoid
// this
Set<RioSetting<?>> set = new HashSet<>(getParserConfig().getNonFatalErrors());
set.remove(NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES);
set.remove(NTriplesParserSettings.FAIL_ON_INVALID_LINES);
getParserConfig().setNonFatalErrors(set);
}
}
Expand Down Expand Up @@ -293,16 +293,6 @@ public void setDatatypeHandling(DatatypeHandling datatypeHandling) {
}
}

/**
* @deprecated Use {@link BasicParserSettings#VERIFY_DATATYPE_VALUES} and
* {@link BasicParserSettings#FAIL_ON_UNKNOWN_DATATYPES} and
* {@link BasicParserSettings#NORMALIZE_DATATYPE_VALUES} instead.
*/
@Deprecated
public DatatypeHandling datatypeHandling() {
return this.parserConfig.datatypeHandling();
}

/**
* Parses the supplied URI-string and sets it as the base URI for resolving relative URIs.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,6 @@ public class NTriplesParserSettings {
public static final RioSetting<Boolean> FAIL_ON_INVALID_LINES = new BooleanRioSetting(
"org.eclipse.rdf4j.rio.ntriples.fail_on_invalid_lines", "Fail on N-Triples invalid lines", Boolean.TRUE);

/**
* Boolean setting for parser to determine whether syntactically invalid lines in N-Triples and N-Quads documents
* generate a parse error.
* <p>
* Defaults to true.
* <p>
* Can be overridden by setting system property {@code org.eclipse.rdf4j.rio.ntriples.fail_on_invalid_lines}
*
* @deprecated use {@link #FAIL_ON_INVALID_LINES} instead.
*/
@Deprecated
public static final RioSetting<Boolean> FAIL_ON_NTRIPLES_INVALID_LINES = FAIL_ON_INVALID_LINES;

/**
* Private constructor
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ public class TriXParserSettings {
public static final RioSetting<Boolean> FAIL_ON_MISSING_DATATYPE = new BooleanRioSetting(
"org.eclipse.rdf4j.rio.trix.fail_on_missing_datatype", "Fail on TriX missing datatype", Boolean.TRUE);

/**
* @deprecated use {@link #FAIL_ON_MISSING_DATATYPE} instead.
*/
@Deprecated
public static final RioSetting<Boolean> FAIL_ON_TRIX_MISSING_DATATYPE = FAIL_ON_MISSING_DATATYPE;

/**
* Boolean setting for parser to determine whether the TriX parser should treat invalid statements as an error.
* <p>
Expand All @@ -44,12 +38,6 @@ public class TriXParserSettings {
public static final RioSetting<Boolean> FAIL_ON_INVALID_STATEMENT = new BooleanRioSetting(
"org.eclipse.rdf4j.rio.trix.fail_on_invalid_statement", "Fail on TriX invalid statement", Boolean.TRUE);

/**
* @deprecated use {@link #FAIL_ON_INVALID_STATEMENT} instead
*/
@Deprecated
public static final RioSetting<Boolean> FAIL_ON_TRIX_INVALID_STATEMENT = FAIL_ON_INVALID_STATEMENT;

/**
* Private constructor
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public final void testStopAtFirstError() {

assertTrue(testConfig.stopAtFirstError());

testConfig.addNonFatalError(NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES);
testConfig.addNonFatalError(NTriplesParserSettings.FAIL_ON_INVALID_LINES);

assertFalse(testConfig.stopAtFirstError());
}
Expand All @@ -239,20 +239,6 @@ public final void testIsPreserveBNodeIDs() {
assertTrue(testConfig.isPreserveBNodeIDs());
}

/**
* Test method for {@link org.eclipse.rdf4j.rio.ParserConfig#datatypeHandling()}.
*/
@Test
public final void testDatatypeHandling() {
ParserConfig testConfig = new ParserConfig();

try {
testConfig.datatypeHandling();
fail("Did not receive expected exception");
} catch (Exception e) {
}
}

/**
* Test method for {@link org.eclipse.rdf4j.rio.ParserConfig#get(org.eclipse.rdf4j.rio.RioSetting)}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ public void testStopAtFirstErrorStrictParsing() throws RDFHandlerException, IOEx
// error.
"<http://s1> <http://p1> <http://o1> <http://g1> .\n").getBytes());

parser.getParserConfig().set(NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES, false);
parser.getParserConfig().set(NTriplesParserSettings.FAIL_ON_INVALID_LINES, false);

try {
parser.parse(bais, "http://test.base.uri");
Expand All @@ -566,8 +566,8 @@ public void testStopAtFirstErrorTolerantParsing() throws RDFHandlerException, IO
final TestRDFHandler rdfHandler = new TestRDFHandler();
parser.setRDFHandler(rdfHandler);

parser.getParserConfig().set(NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES, false);
parser.getParserConfig().addNonFatalError(NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES);
parser.getParserConfig().set(NTriplesParserSettings.FAIL_ON_INVALID_LINES, false);
parser.getParserConfig().addNonFatalError(NTriplesParserSettings.FAIL_ON_INVALID_LINES);

parser.parse(bais, "http://base-uri");
rdfHandler.assertHandler(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void testExceptionHandlingWithStopAtFirstError() throws Exception {
String data = "invalid nt";

RDFParser ntriplesParser = createRDFParser();
ntriplesParser.getParserConfig().set(NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES, Boolean.TRUE);
ntriplesParser.getParserConfig().set(NTriplesParserSettings.FAIL_ON_INVALID_LINES, Boolean.TRUE);

Model model = new LinkedHashModel();
ntriplesParser.setRDFHandler(new StatementCollector(model));
Expand All @@ -103,7 +103,7 @@ public void testExceptionHandlingWithoutStopAtFirstError() throws Exception {
String data = "invalid nt";

RDFParser ntriplesParser = createRDFParser();
ntriplesParser.getParserConfig().addNonFatalError(NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES);
ntriplesParser.getParserConfig().addNonFatalError(NTriplesParserSettings.FAIL_ON_INVALID_LINES);

Model model = new LinkedHashModel();
ntriplesParser.setRDFHandler(new StatementCollector(model));
Expand All @@ -121,7 +121,7 @@ public void testExceptionHandlingWithoutStopAtFirstError2() throws Exception {
String data = "invalid nt";

RDFParser ntriplesParser = createRDFParser();
ntriplesParser.getParserConfig().set(NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES, false);
ntriplesParser.getParserConfig().set(NTriplesParserSettings.FAIL_ON_INVALID_LINES, false);

Model model = new LinkedHashModel();
ntriplesParser.setRDFHandler(new StatementCollector(model));
Expand Down
11 changes: 11 additions & 0 deletions site/content/release-notes/4.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,17 @@ The following methods were removed from `org.eclipse.rdf4j.sail.solr.SolrIndex`
- `endReading()`
- `parseQuery(String, IRI)`

### Removed deprecated RIO parser settings

The following deprecated settings were removed from `org.eclipse.rdf4j.rio.helpers.NTriplesParserSettings`:

- `FAIL_ON_NTRIPLES_INVALID_LINES` (use `FAIL_ON_INVALID_LINES` instead)

The following deprecated settings were removed from `org.eclipse.rdf4j.rio.helpers.TriXParserSettings`:

- `FAIL_ON_TRIX_MISSING_DATATYPE` (use `FAIL_ON_MISSING_DATATYPE` instead)
- `FAIL_ON_TRIX_INVALID_STATEMENT` (use `FAIL_ON_INVALID_STATEMENT` instead)

### Removed deprecated utility methods

The following methods were removed from `org.eclipse.rdf4j.common.io.FileUtil`
Expand Down

0 comments on commit 4f3cee4

Please sign in to comment.