本文整理汇总了Java中org.eclipse.rdf4j.model.BNode类的典型用法代码示例。如果您正苦于以下问题:Java BNode类的具体用法?Java BNode怎么用?Java BNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BNode类属于org.eclipse.rdf4j.model包,在下文中一共展示了BNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: expandStatements
import org.eclipse.rdf4j.model.BNode; //导入依赖的package包/类
private void expandStatements(Model model, Statement statement) {
IRI p = statement.getPredicate();
// add statements that are NOT shortcut properties
// as-is to the result model
if (!shortcutPredicates.contains(p)) {
model.add(statement);
return;
}
// 'p' is a shortcut predicate
Resource context = statement.getContext();
BNode bNode = f.createBNode();
// TODO verify that 'context' works properly, even if it is null
model.add(statement.getSubject(), getExpandedPredicate(p), bNode, context);
model.add(bNode, constant, statement.getObject(), context);
}
示例2: expandAndTestShorthandStatement
import org.eclipse.rdf4j.model.BNode; //导入依赖的package包/类
private Model expandAndTestShorthandStatement(Statement toExpand, IRI expandedPredicate) {
model.add(toExpand);
Model expanded = SHORTHAND_EXPANDER.apply(model);
assertThat(expanded.size(), is(2));
Statement firstStatement =
Iterators.getOnlyElement(
expanded
.filter(null, expandedPredicate, null)
.iterator()
);
assertThat(firstStatement.getSubject(), is(toExpand.getSubject()));
assertThat(firstStatement.getObject(), instanceOf(BNode.class));
Statement otherSt =
Iterators.getOnlyElement(
expanded
.filter((Resource)firstStatement.getObject(), null, null)
.iterator()
);
assertThat(otherSt.getPredicate(), is(Rr.constant));
assertThat(otherSt.getObject(), is(toExpand.getObject()));
return expanded;
}
示例3: create_createTermParameterDefinition_ForStringShape
import org.eclipse.rdf4j.model.BNode; //导入依赖的package包/类
@Test
public void create_createTermParameterDefinition_ForStringShape() {
// Arrange
ModelBuilder builder = new ModelBuilder();
BNode blankNode = VALUE_FACTORY.createBNode();
builder.subject(DBEERPEDIA.NAME_PARAMETER_ID).add(RDF.TYPE, ELMO.TERM_FILTER).add(
ELMO.NAME_PROP, DBEERPEDIA.NAME_PARAMETER_VALUE).add(ELMO.SHAPE_PROP, blankNode).subject(
blankNode).add(SHACL.DATATYPE, XMLSchema.STRING);
Model model = builder.build();
// Act
ParameterDefinition result =
parameterDefinitionFactory.create(model, DBEERPEDIA.NAME_PARAMETER_ID);
// Assert
assertThat(result, instanceOf(TermParameterDefinition.class));
assertThat(result.getIdentifier(), is(DBEERPEDIA.NAME_PARAMETER_ID));
assertThat(result.getName(), is(DBEERPEDIA.NAME_PARAMETER_VALUE.stringValue()));
}
示例4: create_createTermParameterDefinition_ForIntegerShape
import org.eclipse.rdf4j.model.BNode; //导入依赖的package包/类
@Test
public void create_createTermParameterDefinition_ForIntegerShape() {
// Arrange
ModelBuilder builder = new ModelBuilder();
BNode blankNode = VALUE_FACTORY.createBNode();
builder.subject(DBEERPEDIA.NAME_PARAMETER_ID).add(RDF.TYPE, ELMO.TERM_FILTER).add(
ELMO.NAME_PROP, DBEERPEDIA.NAME_PARAMETER_VALUE).add(ELMO.SHAPE_PROP, blankNode).subject(
blankNode).add(SHACL.DATATYPE, XMLSchema.INTEGER);
Model model = builder.build();
// Act
ParameterDefinition result =
parameterDefinitionFactory.create(model, DBEERPEDIA.NAME_PARAMETER_ID);
// Assert
assertThat(result, instanceOf(TermParameterDefinition.class));
assertThat(result.getIdentifier(), is(DBEERPEDIA.NAME_PARAMETER_ID));
assertThat(result.getName(), is(DBEERPEDIA.NAME_PARAMETER_VALUE.stringValue()));
}
示例5: create_createTermParameterDefinition_ForBooleanShape
import org.eclipse.rdf4j.model.BNode; //导入依赖的package包/类
@Test
public void create_createTermParameterDefinition_ForBooleanShape() {
// Arrange
ModelBuilder builder = new ModelBuilder();
BNode blankNode = VALUE_FACTORY.createBNode();
builder.subject(DBEERPEDIA.NAME_PARAMETER_ID).add(RDF.TYPE, ELMO.TERM_FILTER).add(
ELMO.NAME_PROP, DBEERPEDIA.NAME_PARAMETER_VALUE).add(ELMO.SHAPE_PROP, blankNode).subject(
blankNode).add(SHACL.DATATYPE, XMLSchema.BOOLEAN);
Model model = builder.build();
// Act
ParameterDefinition result =
parameterDefinitionFactory.create(model, DBEERPEDIA.NAME_PARAMETER_ID);
// Assert
assertThat(result, instanceOf(TermParameterDefinition.class));
assertThat(result.getIdentifier(), is(DBEERPEDIA.NAME_PARAMETER_ID));
assertThat(result.getName(), is(DBEERPEDIA.NAME_PARAMETER_VALUE.stringValue()));
}
示例6: create_createTermParameterDefinition_ForIriShape
import org.eclipse.rdf4j.model.BNode; //导入依赖的package包/类
@Test
public void create_createTermParameterDefinition_ForIriShape() {
// Arrange
ModelBuilder builder = new ModelBuilder();
BNode blankNode = VALUE_FACTORY.createBNode();
builder.subject(DBEERPEDIA.NAME_PARAMETER_ID).add(RDF.TYPE, ELMO.TERM_FILTER).add(
ELMO.NAME_PROP, DBEERPEDIA.NAME_PARAMETER_VALUE).add(ELMO.SHAPE_PROP, blankNode).subject(
blankNode).add(SHACL.DATATYPE, XMLSchema.ANYURI);
Model model = builder.build();
// Act
ParameterDefinition result =
parameterDefinitionFactory.create(model, DBEERPEDIA.NAME_PARAMETER_ID);
// Assert
assertThat(result, instanceOf(TermParameterDefinition.class));
assertThat(result.getIdentifier(), is(DBEERPEDIA.NAME_PARAMETER_ID));
assertThat(result.getName(), is(DBEERPEDIA.NAME_PARAMETER_VALUE.stringValue()));
}
示例7: testBlankNodes
import org.eclipse.rdf4j.model.BNode; //导入依赖的package包/类
@Test
public void testBlankNodes() throws Throwable {
IRI uriA = sail.getValueFactory().createIRI("http://example.org/test/S_POG#a");
IRI uriB = sail.getValueFactory().createIRI("http://example.org/test/S_POG#b");
try (SailConnection sc = getConnection()) {
ValueFactory factory = sail.getValueFactory();
BNode bNode = factory.createBNode();
try {
sc.addStatement(uriA, uriA, bNode);
} catch (SailException se) {
// FIXME: not supporting blank nodes ATM
assertTrue(se.getCause() instanceof UnsupportedOperationException);
}
commit(sc);
}
}
示例8: rMapResource2Rdf4jResource
import org.eclipse.rdf4j.model.BNode; //导入依赖的package包/类
/**
* Converts a RMapResource to an org.eclipse.rdf4j.model.Resource. Null returns null
*
* @param rmapResource the RMapResource
* @return the equivalent RDF4J Resource
* @throws IllegalArgumentException if an unrecognized RMapResource type provided
*/
public static Resource rMapResource2Rdf4jResource(RMapResource rmapResource) {
if (rmapResource==null) {
return null;
}
Resource resource = null;
if (rmapResource instanceof RMapBlankNode){
RMapBlankNode rb = (RMapBlankNode)rmapResource;
BNode blank = rMapBlankNode2Rdf4jBNode(rb);
resource = blank;
}
else if (rmapResource instanceof RMapIri){
RMapIri rIri = (RMapIri)rmapResource;
IRI iri = rMapIri2Rdf4jIri(rIri);
resource = iri;
}
else {
throw new IllegalArgumentException("Unrecognized RMapResource type");
}
return resource;
}
示例9: rdf4jResource2RMapResource
import org.eclipse.rdf4j.model.BNode; //导入依赖的package包/类
/**
* Converts and RDF4J Resource to a non-literal RMapResource. Null returns null.
*
* @param resource a non-literal RDF4J Resource
* @return the equivalent RMapResource
* @throws IllegalArgumentException if Resource is not compatible for conversion to RMapResource
*/
public static RMapResource rdf4jResource2RMapResource(Resource resource) {
if (resource==null){
return null;
}
RMapResource nlResource = null;
if (resource instanceof BNode){
RMapBlankNode bnode = rdf4jBNode2RMapBlankNode((BNode) resource);
nlResource = bnode;
}
else if (resource instanceof IRI){
RMapIri uri = rdf4jIri2RMapIri((IRI)resource);
nlResource = uri;
}
else {
throw new IllegalArgumentException("Unrecognized Resource type");
}
return nlResource;
}
示例10: rdf4jValue2RMapValue
import org.eclipse.rdf4j.model.BNode; //导入依赖的package包/类
/**
* Converts an RDF4J Value to the equivalent RMapValue. Null returns null
*
* @param value an RDF4J Value
* @return the equivalent RMapValue
* @throws IllegalArgumentException RDF4J Value is not compatible for conversion to RMapValue
*/
public static RMapValue rdf4jValue2RMapValue(Value value) {
RMapValue resource = null;
if (value==null){
return null;
}
if (value instanceof Literal){
RMapLiteral rLiteral = rdf4jLiteral2RMapLiteral((Literal)value);
resource = rLiteral;
}
else if (value instanceof BNode){
RMapBlankNode bnode = rdf4jBNode2RMapBlankNode((BNode) value);
resource = bnode;
}
else if (value instanceof IRI){
RMapIri iri = rdf4jIri2RMapIri((IRI)value);
resource = iri;
}
else {
throw new IllegalArgumentException("Unrecognized Resource type");
}
return resource;
}
示例11: rRMapBlankNodeConverts2Rdf4jBNode
import org.eclipse.rdf4j.model.BNode; //导入依赖的package包/类
@Test
public void rRMapBlankNodeConverts2Rdf4jBNode() {
try {
String bnId = rmapIdService.createId().toASCIIString();
RMapBlankNode bn = new RMapBlankNode(bnId);
BNode bnode = ORAdapter.rMapBlankNode2Rdf4jBNode(bn);
assertNotNull (bnode);
assertEquals(bnId, bnode.getID());
//null returns null
bnode = ORAdapter.rMapBlankNode2Rdf4jBNode(null);
assertTrue(bnode==null);
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
示例12: rMapResourceConverts2Rdf4jResource
import org.eclipse.rdf4j.model.BNode; //导入依赖的package包/类
@Test
public void rMapResourceConverts2Rdf4jResource() {
try {
//BNODE
String bnId = rmapIdService.createId().toASCIIString();
RMapBlankNode bn = new RMapBlankNode(bnId);
Resource resource = ORAdapter.rMapResource2Rdf4jResource(bn);
assertEquals(bnId, resource.stringValue());
assertTrue (resource instanceof BNode);
//IRI
RMapIri rmIri = new RMapIri(testUri);
resource = ORAdapter.rMapResource2Rdf4jResource(rmIri);
assertTrue (resource instanceof IRI);
assertEquals(URI_STRING, resource.stringValue());
//null
resource = ORAdapter.rMapResource2Rdf4jResource(null);
assertTrue(resource==null);
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
示例13: rdf4jBNodeConverts2RMapBlankNode
import org.eclipse.rdf4j.model.BNode; //导入依赖的package包/类
@Test
public void rdf4jBNodeConverts2RMapBlankNode() {
try {
String bnId = rmapIdService.createId().toASCIIString();
BNode bnode = vf.createBNode(bnId);
RMapBlankNode rb = ORAdapter.rdf4jBNode2RMapBlankNode(bnode);
assertEquals(bnode.getID(), rb.getId());
//Null returns null
rb = ORAdapter.rdf4jBNode2RMapBlankNode(null);
assertTrue(rb==null);
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
示例14: rdf4jResourceConverts2RMapResource
import org.eclipse.rdf4j.model.BNode; //导入依赖的package包/类
@Test
public void rdf4jResourceConverts2RMapResource() {
try {
//BNode
String bnId = rmapIdService.createId().toASCIIString();
BNode bnode = vf.createBNode(bnId);
RMapResource rmapresource = ORAdapter.rdf4jResource2RMapResource(bnode);
assertTrue(rmapresource instanceof RMapBlankNode);
assertEquals(bnode.getID(), rmapresource.getStringValue());
//IRI
IRI rIri =vf.createIRI(URI_STRING);
rmapresource = ORAdapter.rdf4jResource2RMapResource(rIri);
assertTrue (rmapresource instanceof RMapIri);
assertEquals(rmapresource.getStringValue(), rIri.stringValue());
//Null returns null
rmapresource = ORAdapter.rdf4jBNode2RMapBlankNode(null);
assertTrue(rmapresource==null);
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
示例15: buildNoMapNode
import org.eclipse.rdf4j.model.BNode; //导入依赖的package包/类
private <ONTORES> void buildNoMapNode(OntoContainer<ONTORES> onto,
NoMappingPossible<ONTORES> noMap, int number, Model model, ValueFactory factory,
Resource alignmentRoot) {
// ordre d'insertion des proprietes necessaires pour avoir une "belle"
// ecriture dans le fichier RDF/XML
// on créé le noeud correspondant a la Cell
BNode cellNode = factory.createBNode();
// on relie l'objet "Alignement" a ce noeud par la propriete "nomap"
model.add(alignmentRoot,NOMAP_PROPERTY,cellNode);
// on donne le type de l'objet "Cell"
model.add(cellNode, RDF.TYPE, CELL_TYPE);
IRI res1 = factory.createIRI(onto.getURI(noMap.getConcept())
.toString());
if (number == 1)
model.add(cellNode,ENTITY1_PROPERTY,res1);
else
model.add(cellNode,ENTITY2_PROPERTY,res1);
}