/** * Adds a triple to the default graph of this dataset * * @param subject * the subject for the triple * @param predicate * the predicate for the triple * @param object * the object for the triple */ public void addTriple(final String subject, final String predicate, final String object) { addQuad(subject, predicate, object, "@default"); }
/** * Adds a triple to the default graph of this dataset * * @param subject * the subject for the triple * @param predicate * the predicate for the triple * @param object * the object for the triple */ public void addTriple(final String subject, final String predicate, final String object) { addQuad(subject, predicate, object, "@default"); }
/** * Adds a triple to the default graph of this dataset * * @param subject * the subject for the triple * @param predicate * the predicate for the triple * @param object * the object for the triple */ public void addTriple(final String subject, final String predicate, final String object) { addQuad(subject, predicate, object, "@default"); }
/** * Adds a triple to the @default graph of this dataset * * @param subject * the subject for the triple * @param predicate * the predicate for the triple * @param value * the value of the literal object for the triple * @param datatype * the datatype of the literal object for the triple (null values * will default to xsd:string) * @param language * the language of the literal object for the triple (or null) */ public void addTriple(final String subject, final String predicate, final String value, final String datatype, final String language) { addQuad(subject, predicate, value, datatype, language, "@default"); }
/** * Adds a triple to the @default graph of this dataset * * @param subject * the subject for the triple * @param predicate * the predicate for the triple * @param value * the value of the literal object for the triple * @param datatype * the datatype of the literal object for the triple (null values * will default to xsd:string) * @param language * the language of the literal object for the triple (or null) */ public void addTriple(final String subject, final String predicate, final String value, final String datatype, final String language) { addQuad(subject, predicate, value, datatype, language, "@default"); }
/** * Adds a triple to the @default graph of this dataset * * @param subject * the subject for the triple * @param predicate * the predicate for the triple * @param value * the value of the literal object for the triple * @param datatype * the datatype of the literal object for the triple (null values * will default to xsd:string) * @param language * the language of the literal object for the triple (or null) */ public void addTriple(final String subject, final String predicate, final String value, final String datatype, final String language) { addQuad(subject, predicate, value, datatype, language, "@default"); }
private void addStatement(RDFDataset result, URI context, Resource subject, URI predicate, URI object) { if (context == null) { result.addTriple(subject.toString(), predicate.toString(), object.toString()); } else { result.addQuad(subject.toString(), predicate.toString(), object.toString(), context.toString()); } }
private void addStatement(RDFDataset result, URI context, Resource subject, URI predicate, String value) { if (context == null) { result.addTriple(subject.toString(), predicate.toString(), value, null, null); } else { result.addQuad(subject.toString(), predicate.toString(), value, null, null, context.toString()); } }
private void addStatement(RDFDataset result, URI context, Resource subject, URI predicate, String value, URI datatype) { if (context == null) { result.addTriple(subject.toString(), predicate.toString(), value, datatype.toString(), null); } else { result.addQuad(subject.toString(), predicate.toString(), value, datatype.toString(), null, context.toString()); } }
private void addStatement(RDFDataset result, URI context, Resource subject, URI predicate, String value, String language) { if (context == null) { result.addTriple(subject.toString(), predicate.toString(), value, null, language); } else { result.addQuad(subject.toString(), predicate.toString(), value, null, language, context.toString()); } }
void add(final BlankNodeOrIRI graphName, final BlankNodeOrIRI subject, final IRI predicate, final RDFTerm object) { final String g = factory.asJsonLdString(graphName); final String s = factory.asJsonLdString(subject); final String p = factory.asJsonLdString(predicate); if (object instanceof BlankNodeOrIRI) { final String o = factory.asJsonLdString((BlankNodeOrIRI) object); rdfDataSet.addQuad(s, p, o, g); } else if (object instanceof Literal) { final Literal literal = (Literal) object; final String language = literal.getLanguageTag().orElse(null); final String datatype = literal.getDatatype().getIRIString(); rdfDataSet.addQuad(s, p, literal.getLexicalForm(), datatype, language, g); } }
@Test public void literalsInDataset() throws Exception { final RDFDataset dataset = new RDFDataset(); dataset.addQuad("http://example.com/p", "http://example.com/p", "Same", null, null, "http://example.com/g1"); dataset.addQuad("http://example.com/p", "http://example.com/p", "Different", null, null, "http://example.com/g1"); final List<Quad> quads = dataset.getQuads("http://example.com/g1"); final Quad q1 = quads.get(0); final Quad q2 = quads.get(1); assertNotEquals(q1, q2); assertNotEquals(0, q1.compareTo(q2)); assertNotEquals(0, q1.getObject().compareTo(q2.getObject())); }
public void handleStatement(RDFDataset result, Statement nextStatement) { // TODO: from a basic look at the code it seems some of these could be // null // null values for IRIs will probably break things further down the line // and i'm not sure yet if this should be something handled later on, or // something that should be checked here final String subject = getResourceValue(nextStatement.getSubject()); final String predicate = getResourceValue(nextStatement.getPredicate()); final Value object = nextStatement.getObject(); final String graphName = getResourceValue(nextStatement.getContext()); if (object instanceof Literal) { final Literal literal = (Literal) object; final String value = literal.getLabel(); final String language = literal.getLanguage(); String datatype = getResourceValue(literal.getDatatype()); // In RDF-1.1, Language Literals internally have the datatype // rdf:langString if (language != null && datatype == null) { datatype = RDF.LANGSTRING.stringValue(); } // In RDF-1.1, RDF-1.0 Plain Literals are now Typed Literals with // type xsd:String if (language == null && datatype == null) { datatype = XMLSchema.STRING.stringValue(); } result.addQuad(subject, predicate, value, datatype, language, graphName); } else { result.addQuad(subject, predicate, getResourceValue((Resource) object), graphName); } }
testData.addQuad(potentialSubjects.get(prng.nextInt(potentialSubjects.size())), potentialPredicates.get(prng.nextInt(potentialPredicates.size())), nextObject, JsonLdConsts.XSD_STRING, testData.addQuad(potentialSubjects.get(prng.nextInt(potentialSubjects.size())), potentialPredicates.get(prng.nextInt(potentialPredicates.size())), nextObject,