当前位置: 首页>>代码示例>>Java>>正文


Java NodeFactory.createAnon方法代码示例

本文整理汇总了Java中com.hp.hpl.jena.graph.NodeFactory.createAnon方法的典型用法代码示例。如果您正苦于以下问题:Java NodeFactory.createAnon方法的具体用法?Java NodeFactory.createAnon怎么用?Java NodeFactory.createAnon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.hp.hpl.jena.graph.NodeFactory的用法示例。


在下文中一共展示了NodeFactory.createAnon方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testRule

import com.hp.hpl.jena.graph.NodeFactory; //导入方法依赖的package包/类
@Test
public void testRule() throws Exception {
  Node var = NodeFactory.createAnon();
  
  System.out.println("Node: " + var);
  
  KBCollection varCol = new KBCollectionImpl("http://www.w3.org/2007/rif#var");
  RDFNode varRdf = KBObjectImpl.getBaseContextModel().asRDFNode(var);
  System.out.println("RDF Node: " + varRdf);

  Resource varRes = varRdf.asResource();
  System.out.println("Resource: " + varRes.getLocalName() + ", " + varRes.getNameSpace() + ", " + varRes.getURI());
  // Individual varInd = ((KBCollectionImpl)varCol).getCore().createIndividual();//.createIndividual(varRes.getURI());
  // KBObjectImpl.getBaseContextModel().createIndividual(((KBCollectionImpl)varCol).getCore());
  
  Variable v = new VariableImpl("vijayvar");
  System.out.println("Var Name: " + v.getName());
  FileWriter fw = new FileWriter("/scratch/WORK2/jena/testModels/test4.xml");
  RDFDataMgr.write(fw, KBObjectImpl.getDataset(), RDFFormat.NQUADS);
  
}
 
开发者ID:vijayrajak,项目名称:JenaKBClient,代码行数:22,代码来源:KBIndividualImplTest.java

示例2: checkObjectPart

import com.hp.hpl.jena.graph.NodeFactory; //导入方法依赖的package包/类
/**
 * This method checks
 * - if there is exactly one rdf:object part of the reification statement
 * @throws SQLException 
 */
private void checkObjectPart(Resource reificationResource,
		StmtIterator objPartsIt, SparqlifyDataset dataset)
		throws NotImplementedException, SQLException {

	List<Statement> objParts = objPartsIt.toList();
	
	if (objParts.isEmpty()) {
		// no object part given --> reification statement incomplete
		// --> violation
		
		// build dummy triple representing the missing reification part
		Triple triple = new Triple(reificationResource.asNode(),
				RDF.object.asNode(), NodeFactory.createAnon());
		writeTripleMeasureToSink(missingReificationPartVal, triple, null);
		
	} else if (objParts.size() > 1) {
		// multiple predicate parts given --> violation
		
		// TODO: also check if the types of all statements are correct
		reportStatements(multipleReificationPartsVal, objParts, dataset);
	}
}
 
开发者ID:SmartDataAnalytics,项目名称:R2RLint,代码行数:28,代码来源:CorrectReificationUse.java

示例3: testAssessNodes2

import com.hp.hpl.jena.graph.NodeFactory; //导入方法依赖的package包/类
@Test
public synchronized void testAssessNodes2() throws NotImplementedException, SQLException {
	String metricName = "test02";
	metric.setName(metricName);
	metric.setParentDimension("parent");
	metric.initMeasureDataSink();
	
	// should be ignored
	Node subj = NodeFactory.createAnon();
	// too long
	Node pred = NodeFactory.createURI("http://example.org/too/long/resource/identifier/aa");
	// not too long
	Node obj = NodeFactory.createURI("http://example.org/not/too/long/resource/id/aaaaa");
	
	Triple triple = new Triple(subj, pred, obj);
	metric.assessNodes(triple);
	
	assertFalse(sink.nodeMeasureWritten(metricName, TriplePosition.SUBJECT));
	assertTrue(sink.nodeMeasureWritten(metricName, TriplePosition.PREDICATE));
	assertFalse(sink.nodeMeasureWritten(metricName, TriplePosition.OBJECT));
}
 
开发者ID:SmartDataAnalytics,项目名称:R2RLint,代码行数:22,代码来源:ShortUriTest.java

示例4: checkIfTyped

import com.hp.hpl.jena.graph.NodeFactory; //导入方法依赖的package包/类
private void checkIfTyped(Resource subject, SparqlifyDataset dataset)
		throws NotImplementedException, SQLException {
	
	// get all type statements for the considered resource ('subject')
	StmtIterator typeStmntsIt =
			dataset.listStatements(subject, RDF.type, (RDFNode) null);
	
	// init list that should hold all assigned types to later check if
	// it is empty or contains different entries (contradictory types)
	Set<Statement> assignmentStatements = new HashSet<Statement>();
	
	// get assigned types...
	while (typeStmntsIt.hasNext()) {
		Statement typeStmnt = typeStmntsIt.next();
		RDFNode object = typeStmnt.getObject();
		
		// ... of course we're just interested in container types
		if (object.isResource()) {
			if (object.asResource().equals(RDF.Bag)
					|| object.asResource().equals(RDF.Seq)
					|| object.asResource().equals(RDF.Alt))
				assignmentStatements.add(typeStmnt);
		}
	}
	
	if (assignmentStatements.isEmpty()) {
		// no type assigned --> violation
		
		// dummy triple representing the missing type statement
		Triple triple =  new Triple(subject.asNode(),
				RDF.type.asNode(), NodeFactory.createAnon());
		writeTripleMeasureToSink(noTypeAssignedVal, triple, null);
		
	} else if (assignmentStatements.size() > 1) {
		// multiple container types assigned --> violation
		ArrayList<Statement> statementsList =
				new ArrayList<Statement>(assignmentStatements);
		reportStatements(multipleTypesAssignedVal, statementsList, dataset);
	}
}
 
开发者ID:SmartDataAnalytics,项目名称:R2RLint,代码行数:41,代码来源:CorrectContainerUse.java

示例5: checkSubjectPart

import com.hp.hpl.jena.graph.NodeFactory; //导入方法依赖的package包/类
/**
 * This method checks
 * - if there is exactly one rdf:subject part of the reification statement
 * - for all rdf:subject parts of the reification statement if the value
 *   is a resource
 * @throws SQLException 
 */
private void checkSubjectPart(Resource reificationResource,
		StmtIterator subjPartsIt, SparqlifyDataset dataset)
		throws NotImplementedException, SQLException {
	
	List<Statement> subjParts = subjPartsIt.toList();
	
	if (subjParts.isEmpty()) {
		// no subject part given --> reification statement incomplete
		// --> violation
		
		// build dummy triple representing the missing reification part
		Triple triple = new Triple(reificationResource.asNode(),
				RDF.subject.asNode(), NodeFactory.createAnon());
		writeTripleMeasureToSink(missingReificationPartVal, triple, null);
		
	} else if (subjParts.size() == 1) {
		// expected case --> no violation; look if the value type is correct
		Statement subjPart = subjParts.get(0);
		RDFNode subjPartVal = subjPart.getObject();
		if (!subjPartVal.isResource()) {
			Set<ViewQuad<ViewDefinition>> viewQuads = pinpointer
					.getViewCandidates(subjPart.asTriple());
			writeTripleMeasureToSink(wrongValueTypeVal, subjPart.asTriple(),
					viewQuads);
		}
		
	} else {
		// multiple subject parts given --> violation
		
		// TODO: also check if the types of all statements are correct
		reportStatements(multipleReificationPartsVal, subjParts, dataset);
	}
	
}
 
开发者ID:SmartDataAnalytics,项目名称:R2RLint,代码行数:42,代码来源:CorrectReificationUse.java

示例6: checkPredicatePart

import com.hp.hpl.jena.graph.NodeFactory; //导入方法依赖的package包/类
/**
 * This method checks
 * - if there is exactly one rdf:predicate part of the reification statement
 * - for all rdf:predicate parts of the reification statement if the value
 *   is a URI resource
 * @throws SQLException 
 */
private void checkPredicatePart(Resource reificationResource,
		StmtIterator predPartsIt, SparqlifyDataset dataset)
		throws NotImplementedException, SQLException {
	
	List<Statement> predParts = predPartsIt.toList();
	
	if (predParts.isEmpty()) {
		// no predicate part given --> reification statement incomplete
		// --> violation
		
		// build dummy triple representing the missing reification part
		Triple triple = new Triple(reificationResource.asNode(),
				RDF.predicate.asNode(), NodeFactory.createAnon());
		writeTripleMeasureToSink(missingReificationPartVal, triple, null);
		
	} else if (predParts.size() == 1) {
		// expected case --> no violation; look if the value type is correct
		Statement predPart = predParts.get(0);
		RDFNode predPartVal = predPart.getObject();
		if (!predPartVal.isURIResource()) {
			Set<ViewQuad<ViewDefinition>> viewQuads = pinpointer
					.getViewCandidates(predPart.asTriple());
			writeTripleMeasureToSink(wrongValueTypeVal, predPart.asTriple(),
					viewQuads);
		}
		
	} else {
		// multiple predicate parts given --> violation
		
		// TODO: also check if the types of all statements are correct
		reportStatements(multipleReificationPartsVal, predParts, dataset);
	}
}
 
开发者ID:SmartDataAnalytics,项目名称:R2RLint,代码行数:41,代码来源:CorrectReificationUse.java

示例7: checkConsecutiveNumberingAndUri

import com.hp.hpl.jena.graph.NodeFactory; //导入方法依赖的package包/类
private void checkConsecutiveNumberingAndUri(Statement statement, int num,
		StmtIterator succIt, SparqlifyDataset dataset)
		throws NotImplementedException, SQLException {

	Resource subject = statement.getSubject();
	Property predicate = statement.getPredicate();
	RDFNode object = statement.getObject();
	
	// check if object is resource
	if (!object.isResource()) {
		Set<ViewQuad<ViewDefinition>> viewQuads =
				pinpointer.getViewCandidates(statement.asTriple());
		writeTripleMeasureToSink(memberIsLiteralVal, statement.asTriple(), viewQuads);
	}
	
	// check if same member number exists more than once
	StmtIterator sameMemNumberStmntsIt =
			dataset.listStatements(subject, predicate, (RDFNode) null);
	List<Statement> sameMemNumberStmnts = sameMemNumberStmntsIt.toList();
	if (sameMemNumberStmnts.size() > 1) {
		// there is more than one statement with same subject and same
		// membership property
		reportStatements(duplicateContMembPropsVal, sameMemNumberStmnts, dataset);
	}
	
	// check consecutive numbering
	StmtIterator succSuccIt = dataset.listStatements(subject, RDF.li(num+2), (RDFNode) null);
	if (!succIt.hasNext()) {
		// there is a gap or we're done
		if (succSuccIt.hasNext()) {
			// there is a gap --> violation
			
			// create dummy triple representing the missing statement
			Triple dummy = new Triple(subject.asNode(),
					RDF.li(num + 1).asNode(), NodeFactory.createAnon());
			writeTripleMeasureToSink(noConsecutiveNumberingVal, dummy, null);
			
			// go on with successor of successor
			StmtIterator succSuccSuccIt =
					dataset.listStatements(subject, RDF.li(num+3), (RDFNode) null);
			checkConsecutiveNumberingAndUri(succSuccIt.next(), num+2, succSuccSuccIt, dataset);
		}
		
	} else // there is no gap and we can continue with the next member
		checkConsecutiveNumberingAndUri(succIt.next(), num+1, succSuccIt, dataset);
}
 
开发者ID:SmartDataAnalytics,项目名称:R2RLint,代码行数:47,代码来源:CorrectContainerUse.java

示例8: buildNodeFromTermMap

import com.hp.hpl.jena.graph.NodeFactory; //导入方法依赖的package包/类
/**
 * Returns a node used in the SML view definition's quad pattern. Such a
 * node can be either a variable, a URI, a blank node or a literal node:
 * - variable --> if rr:constant is used in the term map
 * - URI --> if rr:constant is not used and term type is URI
 * - blank node --> if rr:constant is not used and term type is rr:BlankNode
 * - literal --> if rr:constant is not used and term
 */
protected static Node buildNodeFromTermMap(TermMap termMap, String varName) {
    Node node = null;

    // var
    if (!termMap.isConstantTermMap()) {
        node = new Node_Variable(varName);

    } else {
    // URI
        if (termMap.getTermType().equals(RR.IRI)) {
            RDFNode term = termMap.getTerm();
            if (term.isURIResource()) {
                node = NodeFactory.createURI(term.asResource().getURI());

            } else if (term.isLiteral()) {
                node = NodeFactory.createURI(term.asLiteral().getLexicalForm());
            }

    // blank node
        } else if (termMap.getTermType().equals(RR.BlankNode)) {
            String bNodeId = termMap.getTerm().asLiteral().getLexicalForm();
            node = NodeFactory.createAnon(new AnonId(bNodeId));

    // literal
        } else if (termMap.getTermType().equals(RR.Literal)) {
            String termValue = termMap.getConstantTerm().asLiteral().getLexicalForm();

            // typed with datatype
            if (termMap.hasDatatype()) {
                RDFDatatype datatype = XSDUtils.getDatatype(termMap.getDatatype());
                node = NodeFactory.createLiteral(termValue, datatype);

            // plain with language tag
            } else if (termMap.hasLanguage()) {
                String lang = termMap.getLanguage().getLexicalForm();
                node = NodeFactory.createLiteral(termValue, lang, false);

            // plain without language tag
            } else {
                node = NodeFactory.createLiteral(termValue);
            }
        }
    }
    return node;
}
 
开发者ID:AKSW,项目名称:sml-converters,代码行数:54,代码来源:R2RML2SMLConverter.java

示例9: internalAsBlankNode

import com.hp.hpl.jena.graph.NodeFactory; //导入方法依赖的package包/类
/**
 * Parses the given input as a blank node.
 * 
 * @param blankNodeAsString the blank node string value.
 * @return the {@link Node} Blank node representation of the given value.
 */
private static Node internalAsBlankNode(final String blankNodeAsString) {
	return NodeFactory.createAnon(AnonId.create(blankNodeAsString.substring(2)));	
}
 
开发者ID:spaziocodice,项目名称:jena-nosql,代码行数:10,代码来源:NTriples.java

示例10: buildBNode

import com.hp.hpl.jena.graph.NodeFactory; //导入方法依赖的package包/类
/**
 * Builds a blank node with the given id.
 * 
 * @param id the node id.
 * @return a blank node with the given id.
 */
public static Node buildBNode(final String id) {
	return NodeFactory.createAnon(AnonId.create(id));
}
 
开发者ID:spaziocodice,项目名称:jena-nosql,代码行数:10,代码来源:TestUtility.java


注:本文中的com.hp.hpl.jena.graph.NodeFactory.createAnon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。