/** * Gets a copy of the underlying {@link ParameterizedSparqlString} used to * implement this prepared statement * * @return Copy of the underlying string */ public ParameterizedSparqlString getParameterizedString() { return this.sparqlStr.copy(); } }
/** * Makes a full copy of this parameterized string * * @return Copy of the string */ public ParameterizedSparqlString copy() { return this.copy(true, true, true); }
/** * Makes a copy of the command text, base URI and prefix mapping and * optionally copies parameter values * * @param copyParams * Whether to copy parameters * @return Copy of the string */ public ParameterizedSparqlString copy(boolean copyParams) { return this.copy(copyParams, true, true); }
/** * Gets a copy of the underlying {@link ParameterizedSparqlString} used to * implement this prepared statement * * @return Copy of the underlying string */ public ParameterizedSparqlString getParameterizedString() { return this.sparqlStr.copy(); } }
@Test public void test_param_string_copy_6() { // Test selective copying - copying without copying prefixes ParameterizedSparqlString query = new ParameterizedSparqlString(); query.setNsPrefix("ex", "http://example.org"); ParameterizedSparqlString copy = query.copy(true, true, false); Assert.assertFalse("http://example.org".equals(copy.getNsPrefixURI("ex"))); }
@Test public void test_param_string_copy_1() { // Test copying - copying always copies command text String cmdText = "SELECT * WHERE { ?s ?p ?o }"; ParameterizedSparqlString query = new ParameterizedSparqlString(cmdText); ParameterizedSparqlString copy = query.copy(); Assert.assertEquals(cmdText, copy.getCommandText()); }
@Test public void test_param_string_copy_4() { // Test copying - copying should copy base URI ParameterizedSparqlString query = new ParameterizedSparqlString(); query.setBaseUri("http://example.org"); ParameterizedSparqlString copy = query.copy(); Assert.assertEquals("http://example.org", copy.getBaseUri()); }
@Test public void test_param_string_copy_3() { // Test copying - copying should copy prefixes ParameterizedSparqlString query = new ParameterizedSparqlString(); query.setNsPrefix("ex", "http://example.org"); ParameterizedSparqlString copy = query.copy(); Assert.assertEquals("http://example.org", copy.getNsPrefixURI("ex")); }
ParameterizedSparqlString template = SPARQLUtils.CBD_TEMPLATE_DEPTH3.copy(); template.setIri("uri", r); try(QueryExecution qe = qef.createQueryExecution(template.toString())) {
ParameterizedSparqlString template = SPARQLUtils.CBD_TEMPLATE_DEPTH3.copy(); template.setIri("uri", r); try(QueryExecution qe = qef.createQueryExecution(template.toString())) {
@Test public void test_param_string_copy_5() { // Test selective copying - copying without copying parameters ParameterizedSparqlString query = new ParameterizedSparqlString(); query.setIri("x", "http://example.org/original"); ParameterizedSparqlString copy = query.copy(false); Assert.assertEquals("http://example.org/original", query.getParam("x").toString()); Assert.assertEquals(null, copy.getParam("x")); }
@Test public void test_param_string_copy_8() { // Test selective copying - copying without copying parameters ParameterizedSparqlString query = new ParameterizedSparqlString(); query.setIri(0, "http://example.org/original"); ParameterizedSparqlString copy = query.copy(false); Assert.assertEquals("http://example.org/original", query.getParam(0).toString()); Assert.assertEquals(null, copy.getParam(0)); }
@Test public void test_param_string_copy_2() { // Test copying - copying and changing a parameter changes only one // instance ParameterizedSparqlString query = new ParameterizedSparqlString(); query.setIri("x", "http://example.org/original"); ParameterizedSparqlString copy = query.copy(); copy.setIri("x", "http://example.org/copy"); Assert.assertEquals("http://example.org/original", query.getParam("x").toString()); Assert.assertFalse("http://example.org/copy".equals(query.getParam("x").toString())); Assert.assertEquals("http://example.org/copy", copy.getParam("x").toString()); Assert.assertFalse("http://example.org/original".equals(copy.getParam("x").toString())); }
@Test public void test_param_string_copy_7() { // Test copying - copying and changing a parameter changes only one // instance ParameterizedSparqlString query = new ParameterizedSparqlString(); query.setIri(0, "http://example.org/original"); ParameterizedSparqlString copy = query.copy(); copy.setIri(0, "http://example.org/copy"); Assert.assertEquals("http://example.org/original", query.getParam(0).toString()); Assert.assertFalse("http://example.org/copy".equals(query.getParam(0).toString())); Assert.assertEquals("http://example.org/copy", copy.getParam(0).toString()); Assert.assertFalse("http://example.org/original".equals(copy.getParam(0).toString())); }