本文整理匯總了Java中org.apache.jena.rdf.model.Resource.addLiteral方法的典型用法代碼示例。如果您正苦於以下問題:Java Resource.addLiteral方法的具體用法?Java Resource.addLiteral怎麽用?Java Resource.addLiteral使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.jena.rdf.model.Resource
的用法示例。
在下文中一共展示了Resource.addLiteral方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createConcept
import org.apache.jena.rdf.model.Resource; //導入方法依賴的package包/類
public Concept createConcept(URI uri, Label prefLabel, URI[] classURIs, UUID uuid) throws ModelException {
Resource conceptURIResource = resourceFromURI(model, uri);
if (resourceInUse(conceptURIResource)) throw new ModelException("Attempting to create concept with URI - '%s'. This URI is already in use.", uri.toString());
if ((classURIs == null) || (classURIs.length == 0)) {
conceptURIResource.addProperty(RDF.type, SKOS.Concept);
} else {
for (URI classURI: classURIs) {
conceptURIResource.addProperty(RDF.type, resourceFromURI(model, classURI));
}
}
conceptURIResource.addLiteral(SEM.guid, (uuid == null ? Utils.generateGuid(uri.toString()) : uuid.toString()));
URI labelURI = getLabelURI(model, conceptURIResource, SKOS.prefLabel, prefLabel);
Resource labelURIResource = resourceFromURI(model, labelURI);
model.add(conceptURIResource, SKOSXL.prefLabel, labelURIResource);
model.add(labelURIResource, SKOSXL.literalForm, getAsLiteral(model, prefLabel));
model.add(labelURIResource, RDF.type, SKOSXL.Label);
return new Concept(model, conceptURIResource);
}
示例2: hydrateAndModifySecondModel
import org.apache.jena.rdf.model.Resource; //導入方法依賴的package包/類
public Model hydrateAndModifySecondModel() {
Model model2 = ModelFactory.createDefaultModel();
model2.add(model);
StmtIterator it = model2.listStatements(newConceptRes, null, (RDFNode) null);
List<Statement> toDelete = Lists.newArrayList();
while (it.hasNext()) {
Statement stmt = it.nextStatement();
toDelete.add(stmt);
}
model2.remove(toDelete);
Resource foobarFooRes = model2.createResource("http://example/com/Playpen2#foobarFoo");
foobarFooRes.addProperty(RDF.type, SKOS.Concept);
foobarFooRes.addLiteral(prop1, false);
foobarFooRes.addLiteral(prop2, 1);
Calendar c = Calendar.getInstance();
c.set(Calendar.YEAR, 2016);
c.set(Calendar.DAY_OF_MONTH, 3);
c.set(Calendar.MONTH, 10);
foobarFooRes.addLiteral(prop3, model.createTypedLiteral(dtfmt.format(c.getTime()), XSDDatatype.XSDdate));
foobarFooRes.addProperty(prop4, "2017-01-01", XSDDatatype.XSDdate);
foobarFooRes.addProperty(prop5, "http://www.google.com", XSDDatatype.XSDanyURI);
model2.addLiteral(foobarFooRes, prop6, model.createLiteral("2017-02-22", "en"));
return model2;
}
開發者ID:Smartlogic-Semaphore-Limited,項目名稱:Java-APIs,代碼行數:30,代碼來源:DiffToSparqlInsertUpdateBuilderTests.java
示例3: createConceptScheme
import org.apache.jena.rdf.model.Resource; //導入方法依賴的package包/類
public ConceptScheme createConceptScheme(URI uri, Label prefLabel, UUID uuid) throws ModelException {
Resource conceptSchemeURIResource = resourceFromURI(model, uri);
if (resourceInUse(conceptSchemeURIResource)) throw new ModelException(String.format("Attempting to create concept scheme with URI - '%s'. This URI is already in use.", uri.toString()));
conceptSchemeURIResource.addProperty(RDF.type, SKOS.ConceptScheme);
conceptSchemeURIResource.addLiteral(SEM.guid, (uuid == null ? Utils.generateGuid(uri.toString()) : uuid.toString()));
conceptSchemeURIResource.addLiteral(RDFS.label, getAsLiteral(model, prefLabel));
return new ConceptScheme(model, conceptSchemeURIResource);
}