本文整理匯總了Java中com.hp.hpl.jena.rdf.model.ResourceFactory.createResource方法的典型用法代碼示例。如果您正苦於以下問題:Java ResourceFactory.createResource方法的具體用法?Java ResourceFactory.createResource怎麽用?Java ResourceFactory.createResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.hp.hpl.jena.rdf.model.ResourceFactory
的用法示例。
在下文中一共展示了ResourceFactory.createResource方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testDownloadMap
import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
@Test
public void testDownloadMap() {
sql.executeSQL("CREATE TABLE \"People\" (\"ID\" INT PRIMARY KEY, \"pic\" VARCHAR(50))");
DownloadMap dl = new DownloadMap(ResourceFactory.createResource());
dl.setDatabase(database);
dl.setURIPattern("http://example.org/downloads/@@[email protected]@");
dl.setMediaType("image/png");
dl.setContentDownloadColumn("People.pic");
mapping.addDownloadMap(dl);
CompiledD2RQMapping compiled = mapping.compile();
assertEquals(1, compiled.getDownloadRelations().size());
DownloadRelation d = compiled.getDownloadRelations().iterator().next();
assertNotNull(d);
assertEquals(Node.createLiteral("image/png"),
d.nodeMaker(DownloadRelation.MEDIA_TYPE).makeNode(
new ResultRow(null) {public String get(ColumnName column) {return null;}}));
assertEquals(Microsyntax.parseColumn("People.pic"), d.getContentDownloadColumn());
assertEquals("URI(http://example.org/downloads/{\"People\".\"ID\"})",
d.nodeMaker(DownloadRelation.RESOURCE).toString());
assertFalse(d.getBaseTabular().getUniqueKeys().isEmpty());
assertEquals(ColumnList.create(
Microsyntax.parseColumn("People.ID"),
Microsyntax.parseColumn("People.pic")),
d.getBaseTabular().getColumns());
}
示例2: testGenerateDownloadMap
import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
public void testGenerateDownloadMap() {
Mapping m = MappingHelper.readFromTestFile("parser/download-map.ttl");
MappingHelper.connectToDummyDBs(m);
Resource name = ResourceFactory.createResource("http://example.org/dm");
assertTrue(m.downloadMapResources().contains(name));
DownloadMap d = m.downloadMap(name);
assertNotNull(d);
assertEquals("image/png",
d.getMediaTypeValueMaker().makeValue(
new ResultRow() {public String get(ProjectionSpec column) {return null;}}));
assertEquals("People.pic", d.getContentDownloadColumn().qualifiedName());
assertEquals("URI(Pattern(http://example.org/downloads/@@[email protected]@))",
d.nodeMaker().toString());
assertEquals(
new HashSet<ProjectionSpec>() {{
add(SQL.parseAttribute("People.ID"));
add(SQL.parseAttribute("People.pic"));
}},
d.getRelation().projections());
assertTrue(d.getRelation().isUnique());
assertTrue(d.getRelation().condition().isTrue());
assertTrue(d.getRelation().joinConditions().isEmpty());
}
示例3: setUp
import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
@BeforeMethod
public void setUp() {
source = ResourceFactory.createResource();
target = ResourceFactory.createResource();
mid = ResourceFactory.createResource();
final Resource y = ResourceFactory.createResource();
final Property p = ResourceFactory.createProperty("urn:example:p");
final Model model = ModelFactory.createDefaultModel();
// a path of length 3
model.add(source, p, mid);
model.add(mid, p, y);
model.add(y, p, target);
// a shorter path of length 2
model.add(source, p, mid);
model.add(mid, p, target);
finder = new ShortestPathFinder(model, p);
}
示例4: main
import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
/**
*
* @param args
*/
public static void main(String args[])
{
// Create an empty model
Model model = ModelFactory.createDefaultModel();
String fullName = "John Smith";
String johnURI = ns+"JohnSmith";
// ** TASK 2.1: Create the resource John Smith
Resource johnSmith = ResourceFactory.createResource("John Smith");
// Add to johnSmith the datatype property full name (from the VCARD vocabulary)
johnSmith.addProperty(VCARD.FN, fullName);
// ** TASK 2.2: Create a new resource for Jane Smith, specifying her full name and email **
Resource janeSmith = ResourceFactory.createResource("Jane Smith");
janeSmith.addProperty(VCARD.FN, "Jane Smith");
janeSmith.addProperty(VCARD.EMAIL, "[email protected]");
// ** TASK 2.3: Add Jane as a person who John knows through an object property from the FOAF vocabulary**
johnSmith.addProperty(FOAF.knows, janeSmith);
model.write(System.out, "RDF/XML-ABBREV");
}
示例5: getNormalizedTermMapStatements
import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
private List<Statement> getNormalizedTermMapStatements(Model triplesMap,
Statement statement) {
List<Statement> normalizedStatements = new ArrayList<Statement>();
Resource subject = statement.getSubject();
Property shortCutPredicate = statement.getPredicate();
Property generalProperty = short2general.get(shortCutPredicate);
RDFNode object = statement.getObject();
Resource termMapBNode = ResourceFactory.createResource();
normalizedStatements.add(ResourceFactory.createStatement(
subject, generalProperty, termMapBNode));
normalizedStatements.add(ResourceFactory.createStatement(
termMapBNode, RR.constant, object));
return normalizedStatements;
}
示例6: TermConstructorConverter
import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
public TermConstructorConverter(TermConstructorType type, List<Expr> exprs) {
this.type = type;
if (type.equals(TermConstructorType.typedLiteral)) {
Node dtype = ((NodeValueNode) exprs.get(2)).getNode();
this.dtype = ResourceFactory.createResource(((Node_URI) dtype).getURI());
} else {
this.dtype = null;
}
String langStr = ((NodeValueString) exprs.get(1)).asString();
if (type.equals(TermConstructorType.plainLiteral) && !langStr.isEmpty()) {
this.langStr = langStr;
} else {
this.langStr = null;
}
this.expr = exprs.get(0);
}
示例7: test_getTriplesMaps_1
import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
@Test
public void test_getTriplesMaps_1() {
Model r2rml = readR2RML(r2rml1);
Resource expectedTMResource = ResourceFactory
.createResource(prefix + "TriplesMap1");
int expectedNumTMResources = 1;
R2RMLSpec spec = new R2RMLSpec(r2rml);
Set<TriplesMap> triplesMaps = spec.getTriplesMaps();
Set<Resource> tmResources = new HashSet<Resource>();
for (TriplesMap tm : triplesMaps) {
tmResources.add(tm.getResource());
}
assertEquals(expectedNumTMResources, triplesMaps.size());
assertEquals(expectedNumTMResources, tmResources.size());
assertTrue(tmResources.contains(expectedTMResource));
}
示例8: test_buildTblToTM_1
import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
@Test
public void test_buildTblToTM_1() {
Model r2rml = readR2RML(r2rml1);
R2RMLSpec spec = new R2RMLSpec(r2rml);
Resource expectedTMSubject = ResourceFactory.createResource(prefix + "TriplesMap1");
NodeIterator tmpRes = r2rml.listObjectsOfProperty(expectedTMSubject, RR.logicalTable);
Resource expectedTblSubject = tmpRes.next().asResource();
LogicalTable logTbl = new LogicalTable(r2rml, expectedTblSubject);
Pair<LogicalTable, TriplesMap> expectedLtTm =
new Pair<LogicalTable, TriplesMap>(
logTbl, new TriplesMap(r2rml, expectedTMSubject));
int expectedNumLtTmEntries = 1;
Map<LogicalTable, Collection<TriplesMap>> tableToTMs =
R2RML2SMLConverter.buildTblToTM(spec);
assertEquals(expectedNumLtTmEntries, tableToTMs.size());
assertEquals(expectedNumLtTmEntries, tableToTMs.keySet().size());
Set<LogicalTable> tbls = tableToTMs.keySet();
assertTrue(tbls.contains(expectedLtTm.first));
Collection<TriplesMap> triplesMaps = tableToTMs.get(logTbl);
assertTrue(triplesMaps.contains(expectedLtTm.second));
}
示例9: create
import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
/**
* Convenience method for creating class maps.
*
* @param id Identifier for the class map; may be <code>null</code>
* @param uriPattern URI pattern
* @param mapping Mapping the class map belongs to; if it has exactly one database, that will be used too
*/
public static ClassMap create(Resource id, String uriPattern, Mapping mapping) {
ClassMap result = new ClassMap(id == null ? ResourceFactory.createResource() : id);
result.setURIPattern(uriPattern);
if (mapping.databases().size() == 1) {
result.setDatabase(mapping.databases().iterator().next());
}
mapping.addClassMap(result);
return result;
}
示例10: setUp
import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
@Before
public void setUp() {
sql = new HSQLDatabase("test");
database = new Database(ResourceFactory.createResource());
database.setJdbcURL(sql.getJdbcURL());
database.setUsername(sql.getUser());
mapping = new Mapping();
mapping.addDatabase(database);
class1 = ResourceFactory.createResource("http://test/Class1");
pattern1 = "http://test/@@[email protected]@";
t_id = Microsyntax.parseColumn("T.ID");
t_col1 = Microsyntax.parseColumn("T.COL1");
t_ref_a_id = Microsyntax.parseJoin("T.REF = A.ID");
}
示例11: testGenerateDownloadMap
import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
@Test
public void testGenerateDownloadMap() {
Mapping m = D2RQTestUtil.loadMapping("d2rq-reader/download-map.ttl");
Resource name = ResourceFactory.createResource("http://example.org/dm");
assertTrue(m.downloadMapResources().contains(name));
DownloadMap dl = m.downloadMap(name);
assertEquals("http://example.org/database", dl.getDatabase().resource().getURI());
assertEquals("downloads/@@[email protected]@", dl.getURIPattern());
assertEquals(Microsyntax.parseColumn("People.pic"), dl.getContentDownloadColumn());
assertEquals("image/png", dl.getMediaType());
}
示例12: testOsloHasMainLanguageNorwegian
import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
@Test
public void testOsloHasMainLanguageNorwegian() {
Individual oslo = exercise31.getIndividual("Oslo");
Property mainLanguage = ResourceFactory.createProperty(Exercise3.NS, "hasMainLanguage");
RDFNode norwegian = ResourceFactory.createResource(Exercise3.NS + "Norwegian");
Assert.assertTrue(oslo.hasProperty(mainLanguage, norwegian));
}
示例13: SchemaProcessor
import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
public SchemaProcessor(Model model, String packetURI, ObjectNode schema)
throws JsonLdError {
this.model = model;
this.context = ContextUtil.getDefaultContext();
processSchema(schema, repeatedStructureMap);
Resource packetResource = ResourceFactory.createResource(packetURI);
processedJSON = processObjectNode(schema, packetResource);
processedJSON.put("@context", ContextUtil.defaultContextURI);
}
示例14: fillPropertiesHandleIfcObject
import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
private int fillPropertiesHandleIfcObject(Resource r, EntityVO evo, int attributePointer, Object o,IFCVO ivo) throws IOException, IfcDataFormatException {
if ((evo != null) && (evo.getDerivedAttributeList() != null) && (evo.getDerivedAttributeList().size() > attributePointer)) {
final AttributeVO avo=evo.getDerivedAttributeList().get(attributePointer);
if (avo.isSet()){
throw IfcDataFormatException.valueOutOfRange("#"+ivo.getLineNum(),"#"+((IFCVO)o).getLineNum(),"SET");
}
final String propURI = getOntNS() + evo.getDerivedAttributeList().get(attributePointer).getLowerCaseName();
EntityVO evorange = ent.get(ExpressReader.formatClassName(((IFCVO) o).getName()));
OntProperty p = ontModel.getOntProperty(propURI);
OntClass range=p.getRange().asClass();
OntClass rclass = ontModel.getOntClass(getOntNS() + evorange.getName());
if (!rclass.hasSuperClass(range)){
throw IfcDataFormatException.valueOutOfRange("#"+ivo.getLineNum(),"#"+((IFCVO)o).getLineNum(),range.getLocalName());
}
else{
Resource r1=ResourceFactory.createResource(getBaseURI() + createLocalName(evorange.getName() + "_" + ((IFCVO) o).getLineNum()));
getRdfWriter().triple(new Triple(r.asNode(), p.asNode(), r1.asNode()));
// if (logToFile)
// bw.write("*OK 1*: added property: " + r.getLocalName() + " - " + p.getLocalName() + " - " + r1.getLocalName() + "\r\n");
}
} else {
throw IfcDataFormatException.attributeOutOfBounds("#"+ivo.getLineNum()+"="+ivo.getFullLineAfterNum());
}
attributePointer++;
return attributePointer;
}
示例15: createLiteralProperty
import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
private void createLiteralProperty(Resource r, OntResource p, OntResource range, String literalString,IFCVO ivo) throws IOException, IfcDataFormatException {
String xsdType = getXSDTypeFromRange(range);
if (xsdType == null) {
xsdType = getXSDTypeFromRangeExpensiveMethod(range);
}
if (xsdType != null) {
String xsdTypeCAP = Character.toUpperCase(xsdType.charAt(0)) + xsdType.substring(1);
OntProperty valueProp = expressModel.getOntProperty(getExpressns() + "has" + xsdTypeCAP);
String key = valueProp.toString() + ":" + xsdType + ":" + literalString;
// Resource r1 = propertyResourceMap.get(key);
// if (r1 == null) {
Resource r1 = ResourceFactory.createResource(getBaseURI() + createLocalName(range.getLocalName() + "_" + IDcounter));
// Resource r1 = ResourceFactory.createResource(getBaseURI() + range.getLocalName() + "_" + IDcounter);
getRdfWriter().triple(new Triple(r1.asNode(), RDF.type.asNode(), range.asNode()));
// if (logToFile)
// bw.write("*OK 17*: created resource: " + r1.getLocalName() + "\r\n");
IDcounter++;
propertyResourceMap.put(key, r1);
addLiteralToResource(r1, valueProp, xsdType, literalString,ivo);
// }
getRdfWriter().triple(new Triple(r.asNode(), p.asNode(), r1.asNode()));
// if (logToFile)
// bw.write("*OK 3*: added property: " + r.getLocalName() + " - " + p.getLocalName() + " - " + r1.getLocalName() + "\r\n");
} else {
LOGGER.log(Level.WARNING ,"XSD type not found for: " + p + " - " + range.getURI() + " - " + literalString + "\r\n");
}
}