/** * <p>Remove the statement that the given string is a label for * this resource. If this statement * is not true of the current model, nothing happens.</p> * @param label A label string to be removed * @param lang A lang tag */ @Override public void removeLabel( String label, String lang ) { removeLabel( getModel().createLiteral( label, lang ) ); }
/** * <p>Answer true if this resource has the given comment.</p> * @param comment The comment to test for * @param lang The optional language tag, or null for don't care. * @return True if this resource has <code>comment</code> as a comment. */ @Override public boolean hasComment( String comment, String lang ) { return hasComment( getModel().createLiteral( comment, lang ) ); }
/** * <p>Add the given label to this resource.</p> * @param label A label string for this resource * @param lang The language attribute for this label (EN, FR, etc) or null if not specified. * @exception ProfileException If the {@link Profile#LABEL()} property is not supported in the current language profile. */ @Override public void addLabel( String label, String lang ) { addLabel( getModel().createLiteral( label, lang ) ); }
/** * <p>Remove the statement that the given string is a comment on * this resource. If this statement * is not true of the current model, nothing happens.</p> * @param comment A comment string to be removed * @param lang A lang tag */ @Override public void removeComment( String comment, String lang ) { removeComment( getModel().createLiteral( comment, lang ) ); }
public void testRDFNodeAsLiteral() { final Model m = ModelHelper.modelWithStatements(this, ""); final Literal l = m.createLiteral("hello, world"); Assert.assertSame(l, ((RDFNode) l).asLiteral()); }
/** * <p>Add the given version information to this resource.</p> * @param info A version information string for this resource * @exception ProfileException If the {@link Profile#VERSION_INFO()} property is not supported in the current language profile. */ @Override public void addVersionInfo( String info ) { checkProfile( getProfile().VERSION_INFO(), "VERSION_INFO" ); addProperty( getProfile().VERSION_INFO(), getModel().createLiteral( info ) ); }
public void testRDFNodeAsLiteral() { final Model m = ModelHelper.modelWithStatements(this, ""); final Literal l = m.createLiteral("hello, world"); Assert.assertSame(l, ((RDFNode) l).asLiteral()); }
public void testLiteralHasModel() { testLiteralHasModel(model, model.createLiteral("hello, world")); testLiteralHasModel(model, model.createLiteral("hello, world", "en-UK")); testLiteralHasModel(model, model.createLiteral("hello, world", true)); testLiteralHasModel(model, model.createTypedLiteral("hello, world")); testLiteralHasModel(model, model.createTypedLiteral(false)); testLiteralHasModel(model, model.createTypedLiteral(17)); testLiteralHasModel(model, model.createTypedLiteral('x')); }
public void testAddLiteralPassesLiteralUnmodified() { final Resource r = model.createResource(); final Literal lit = model.createLiteral("spoo"); r.addLiteral(RDF.value, lit); Assert.assertTrue("model should contain unmodified literal", model.contains(null, RDF.value, lit)); }
public void testAddWithLiteralObject() { final Literal lit = model.createLiteral("spoo"); model.addLiteral(X, P, lit); Assert.assertTrue(model.contains(X, P, lit)); Assert.assertTrue(model.containsLiteral(X, P, lit)); }
public void testInModel() { final Model m1 = createModel(); final Model m2 = createModel(); final Literal l1 = m1.createLiteral("17"); final Literal l2 = l1.inModel(m2); Assert.assertEquals(l1, l2); Assert.assertSame(m2, l2.getModel()); }
public void testInModel() { final Model m1 = createModel(); final Model m2 = createModel(); final Literal l1 = m1.createLiteral("17"); final Literal l2 = l1.inModel(m2); Assert.assertEquals(l1, l2); Assert.assertSame(m2, l2.getModel()); }
@Override public void setUp() { model = createModel(); final Resource S2 = model.createResource(TestReifiedStatements.anchor + "subject2"); S = model.createResource(TestReifiedStatements.anchor + "subject"); P = model.createProperty(TestReifiedStatements.anchor + "predicate"); O = model.createLiteral(TestReifiedStatements.anchor + "object"); SPO = model.createStatement(S, P, O); SPO2 = model.createStatement(S2, P, O); }
protected void testPlainString( final Model model, final String tv ) { final Literal l = model.createLiteral(tv); Assert.assertEquals(tv, l.getString()); Assert.assertEquals(tv, l.getLexicalForm()); Assert.assertEquals("", l.getLanguage()); }
protected void testLanguagedString( final Model model, final String tv, final String lang ) { final Literal l = model.createLiteral(tv, lang); Assert.assertEquals(tv, l.getString()); Assert.assertEquals(tv, l.getLexicalForm()); Assert.assertEquals(lang, l.getLanguage()); }
@Test public void testInitialBindings3() { try(QueryExecution qExec = makeQExec("SELECT * {?s ?p 'x1'}")) { QuerySolutionMap init = new QuerySolutionMap() ; init.add("z", m.createLiteral("zzz")); qExec.setInitialBinding(init) ; ResultSet rs = qExec.execSelect() ; QuerySolution qs = rs.nextSolution() ; assertTrue("Initial setting not set correctly now", qs.getLiteral("z").getLexicalForm().equals("zzz")) ; } }
@Test public void testInitialBindings1() { QueryExecution qExec = makeQExec("SELECT * {?s ?p ?o}") ; QuerySolutionMap init = new QuerySolutionMap() ; init.add("o", m.createLiteral("y1")); qExec.setInitialBinding(init) ; int count = queryAndCount(qExec) ; assertEquals("Initial binding didn't restrict query properly", 1, count) ; }
public void testXMLLiteral() { Literal ll; ll = m.createLiteral("<bad",true); assertTrue("Error checking must be off.",((EnhNode)ll).asNode().getLiteralIsXML()); ll = m.createTypedLiteral("<bad/>",XMLLiteralType.theXMLLiteralType); assertFalse("Error checking must be on.",((EnhNode)ll).asNode().getLiteralIsXML()); ll = m.createTypedLiteral("<good></good>",XMLLiteralType.theXMLLiteralType); assertTrue("Well-formed XMLLiteral.",((EnhNode)ll).asNode().getLiteralIsXML()); }
@Test public void testInitialBindingsConstruct1() { try(QueryExecution qExec = makeQExec("CONSTRUCT {?s ?p ?z} {?s ?p 'x1'}")) { QuerySolutionMap init = new QuerySolutionMap() ; init.add("z", m.createLiteral("zzz")); qExec.setInitialBinding(init) ; Model r = qExec.execConstruct() ; assertTrue("Empty model", r.size() > 0 ) ; Property p1 = m.createProperty(ns+"p1") ; assertTrue("Empty model", r.contains(null,p1, init.get("z"))) ; } }
@Test public void testInitialBindingsConstruct2() { try(QueryExecution qExec = makeQExec("CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o }")) { QuerySolutionMap init = new QuerySolutionMap() ; init.add("o", m.createLiteral("x1")); qExec.setInitialBinding(init) ; Model r = qExec.execConstruct() ; assertTrue("Empty model", r.size() > 0 ) ; Property p1 = m.createProperty(ns+"p1") ; assertTrue("Empty model", r.contains(null, p1, init.get("x1"))) ; } }