@SuppressWarnings("unused") private SerialisableResource(Resource resource){ super(); this.isURI = resource.isURIResource(); this.isBlank = resource.isAnon(); this.isLiteral = resource.isLiteral(); this._resource = resource.toString(); if (this.isLiteral) literalDataType = resource.asLiteral().getDatatypeURI(); }
public static String toSPARQL(Resource n){ if (n != null && (n.isResource() || n.isLiteral())){ if (n.isURIResource()) return "<" + n.getURI() + ">"; else if (n.isLiteral()) { String sparql = "'''" + sparqlEncode(n.asLiteral().toString()) + "'''"; //does it have a Datatype Literal? if (n.asLiteral().getDatatypeURI() != null){ sparql = sparql + "'''^^<" + n.asLiteral().getDatatypeURI().toString() + ">"; } if (n.asLiteral().getLanguage() != ""){ sparql = sparql + "'''@" + n.asLiteral().getLanguage(); } return sparql; } else return null; } else return null; }
throw new IllegalArgumentException("Resource may not be null"); if (resource.isLiteral()) { throw new IllegalArgumentException("Resource may not be a literal");
} else if (model.getResource(oUri).isLiteral()) {
public void testIsLiteral() { final Model m = ModelHelper.modelWithStatements(this, ""); Assert.assertEquals(false, m.createResource("eh:/foo").isLiteral()); Assert.assertEquals(false, m.createResource().isLiteral()); Assert.assertEquals(true, m.createTypedLiteral(17).isLiteral()); Assert.assertEquals(true, m.createTypedLiteral("hello").isLiteral()); }
public void testIsLiteral() { final Model m = ModelHelper.modelWithStatements(this, ""); Assert.assertEquals(false, m.createResource("eh:/foo").isLiteral()); Assert.assertEquals(false, m.createResource().isLiteral()); Assert.assertEquals(true, m.createTypedLiteral(17).isLiteral()); Assert.assertEquals(true, m.createTypedLiteral("hello").isLiteral()); }