public SesameTripleCallback(RDFHandler nextHandler, ValueFactory vf) { this(nextHandler, vf, new ParserConfig(), new ParseErrorLogger()); }
public void setStopAtFirstError(final boolean stopAtFirstError) { config = new ParserConfig(config.verifyData(), stopAtFirstError, config.isPreserveBNodeIDs(), config.datatypeHandling()); }
private Model getResource(UriBuilder uriBuilder) { RDFFormat format = RDFFormat.TURTLE; try { java.net.URI target = credentials.buildUrl(uriBuilder); log.debug("Exporting {} data from resource {}", format.getName(), target.toString()); String entity = client.get(target, format.getDefaultMIMEType()); return Rio.parse(new StringReader(entity), target.toString(), format, new ParserConfig(), ValueFactoryImpl.getInstance(), new ParseErrorLogger()); } catch (IllegalArgumentException | URISyntaxException | RDFParseException | IOException e) { if (e instanceof ClientProtocolException && "Unexpected response status: 404".compareTo(e.getMessage())==0) { //keeping old behavior, should not be silently fail (i.e. return empty model)? return new LinkedHashModel(); } else { throw new RuntimeException(e); } } }
public void setVerifyData(final boolean verifyData) { config = new ParserConfig(verifyData, config.stopAtFirstError(), config.isPreserveBNodeIDs(), config.datatypeHandling()); }
public void setPreserveBNodeIDs(final boolean preserveBNodeIDs) { config = new ParserConfig(config.verifyData(), config.stopAtFirstError(), preserveBNodeIDs, config.datatypeHandling()); }
public void setDatatypeHandling(final DatatypeHandling datatypeHandling) { config = new ParserConfig(config.verifyData(), config.stopAtFirstError(), config.isPreserveBNodeIDs(), datatypeHandling); }
/** * Test method for {@link org.openrdf.rio.ParserConfig#datatypeHandling()}. */ @Test public final void testDatatypeHandling() { ParserConfig testConfig = new ParserConfig(); try { testConfig.datatypeHandling(); fail("Did not receive expected exception"); } catch (Exception e) { } }
@Override public Model exportDataset(String dataset) { RDFFormat format = RDFFormat.TURTLE; try { final java.net.URI target = credentials.buildUrl(getDatasetUriBuilder(dataset)); log.debug("Exporting {} data from dataset {}", format.getName(), dataset); final String entity = client.get(target, format.getDefaultMIMEType()); return Rio.parse(new StringReader(entity), target.toString(), format, new ParserConfig(), ValueFactoryImpl.getInstance(), new ParseErrorLogger()); } catch (IllegalArgumentException | URISyntaxException | RDFParseException | IOException e) { throw new RuntimeException(e); } }
/** * Test method for * {@link org.openrdf.rio.ParserConfig#addNonFatalError(org.openrdf.rio.RioSetting)} * . */ @Test public final void testAddNonFatalError() { ParserConfig testConfig = new ParserConfig(); assertTrue(testConfig.getNonFatalErrors().isEmpty()); testConfig.addNonFatalError(BasicParserSettings.PRESERVE_BNODE_IDS); assertTrue(testConfig.getNonFatalErrors().contains(BasicParserSettings.PRESERVE_BNODE_IDS)); }
/** * Test method for {@link org.openrdf.rio.ParserConfig#getNonFatalErrors()}. */ @Test public final void testGetNonFatalErrors() { ParserConfig testConfig = new ParserConfig(); assertTrue(testConfig.getNonFatalErrors().isEmpty()); testConfig.addNonFatalError(BasicParserSettings.PRESERVE_BNODE_IDS); assertFalse(testConfig.getNonFatalErrors().isEmpty()); }
/** * Test method for {@link org.openrdf.rio.ParserConfig#verifyData()}. */ @Test public final void testVerifyData() { ParserConfig testConfig = new ParserConfig(); assertTrue(testConfig.verifyData()); testConfig.set(BasicParserSettings.VERIFY_RELATIVE_URIS, false); assertFalse(testConfig.verifyData()); }
/** * Test method for {@link org.openrdf.rio.ParserConfig#isPreserveBNodeIDs()}. */ @Test public final void testIsPreserveBNodeIDs() { ParserConfig testConfig = new ParserConfig(); assertFalse(testConfig.isPreserveBNodeIDs()); testConfig.set(BasicParserSettings.PRESERVE_BNODE_IDS, true); assertTrue(testConfig.isPreserveBNodeIDs()); }
/** * Test method for * {@link org.openrdf.rio.ParserConfig#set(org.openrdf.rio.RioSetting, java.lang.Object)} * . */ @Test public final void testSet() { ParserConfig testConfig = new ParserConfig(); assertFalse(testConfig.isSet(BasicParserSettings.VERIFY_RELATIVE_URIS)); testConfig.set(BasicParserSettings.VERIFY_RELATIVE_URIS, false); assertTrue(testConfig.isSet(BasicParserSettings.VERIFY_RELATIVE_URIS)); }
/** * Test method for * {@link org.openrdf.rio.ParserConfig#isNonFatalError(org.openrdf.rio.RioSetting)} * . */ @Test public final void testIsNonFatalError() { ParserConfig testConfig = new ParserConfig(); assertTrue(testConfig.getNonFatalErrors().isEmpty()); assertFalse(testConfig.isNonFatalError(BasicParserSettings.PRESERVE_BNODE_IDS)); testConfig.addNonFatalError(BasicParserSettings.PRESERVE_BNODE_IDS); assertTrue(testConfig.isNonFatalError(BasicParserSettings.PRESERVE_BNODE_IDS)); }
/** * Test method for * {@link org.openrdf.rio.ParserConfig#get(org.openrdf.rio.RioSetting)}. */ @Test public final void testGet() { ParserConfig testConfig = new ParserConfig(); assertTrue(testConfig.get(BasicParserSettings.VERIFY_RELATIVE_URIS)); testConfig.set(BasicParserSettings.VERIFY_RELATIVE_URIS, false); assertFalse(testConfig.get(BasicParserSettings.VERIFY_RELATIVE_URIS)); }
/** * Test method for * {@link org.openrdf.rio.ParserConfig#isSet(org.openrdf.rio.RioSetting)}. */ @Test public final void testIsSet() { ParserConfig testConfig = new ParserConfig(); assertFalse(testConfig.isSet(BasicParserSettings.PRESERVE_BNODE_IDS)); testConfig.set(BasicParserSettings.PRESERVE_BNODE_IDS, true); assertTrue(testConfig.isSet(BasicParserSettings.PRESERVE_BNODE_IDS)); } }
/** * Test method for {@link org.openrdf.rio.ParserConfig#stopAtFirstError()}. * Test specifically for SES-1947 */ @Test public final void testStopAtFirstError() { ParserConfig testConfig = new ParserConfig(); assertTrue(testConfig.stopAtFirstError()); testConfig.addNonFatalError(NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES); assertFalse(testConfig.stopAtFirstError()); }
/** * Default constructor. Creates RDFa parser in 1.1 mode with disabled vocabulary expansion feature. * <p> * Supported settings can be found using {@link #getSupportedSettings()} and can be modified using * the {@link ParserConfig} object returned from the {@link #getParserConfig()} method. */ public SesameRDFaParser() { streamProcessor = new StreamProcessor(RdfaParser.connect(SesameSink.connect(null))); streamProcessor.setProperty(StreamProcessor.PROCESSOR_GRAPH_HANDLER_PROPERTY, this); setParserConfig(new ParserConfig()); // by default this would be set to false if not set here setPreserveBNodeIDs(true); parseErrorListener = null; }
/** * Test that the explicit constructor sets all of the basic settings using * the default values. */ @Test public final void testParserConfigSameAsDefaults() { ParserConfig testConfig = new ParserConfig(true, true, false, DatatypeHandling.VERIFY); // check that the basic settings are explicitly set assertTrue(testConfig.isSet(BasicParserSettings.PRESERVE_BNODE_IDS)); // check that the basic settings all return their expected default values assertFalse(testConfig.get(BasicParserSettings.PRESERVE_BNODE_IDS)); assertFalse(testConfig.isPreserveBNodeIDs()); }
/** * Test that the explicit constructor sets all of the basic settings using * non-default values. */ @Test public final void testParserConfigNonDefaults() { ParserConfig testConfig = new ParserConfig(false, false, true, DatatypeHandling.IGNORE); // check that the basic settings are explicitly set assertTrue(testConfig.isSet(BasicParserSettings.PRESERVE_BNODE_IDS)); // check that the basic settings all return their set values assertTrue(testConfig.get(BasicParserSettings.PRESERVE_BNODE_IDS)); assertTrue(testConfig.isPreserveBNodeIDs()); }