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


Java Graph.contains方法代码示例

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


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

示例1: getRelatedSubjects

import com.hp.hpl.jena.graph.Graph; //导入方法依赖的package包/类
@Override
protected HashSet<Node> getRelatedSubjects(Node node, ExecutionContext execCxt) {
	HashSet<Node> results = new HashSet<Node>();

	Graph graph = execCxt.getActiveGraph();

	Node clazz = NodeFactory.createURI(Namespace.IFC2X3_TC1 + "IfcBuildingStorey");
	LinkedList<Storey> storeys = new LinkedList<Storey>();
	if (graph.contains(node, RDF.type.asNode(), clazz)) {
		Storey storey = new Storey(node, elevation(node, graph));
		ExtendedIterator<Triple> triples = graph.find(null, RDF.type.asNode(), clazz);
		while (triples.hasNext()) {
			Node subject = triples.next().getSubject();
			Storey s = new Storey(subject, elevation(subject, graph));
			if (s.elevation > storey.elevation) {
				addStorey(storeys, s, graph);
			}
		}
		if (storeys.size() > 0) {
			results.add(storeys.get(0).storey);
		}
	}
	return results;
}
 
开发者ID:BenzclyZhang,项目名称:BimSPARQL,代码行数:25,代码来源:HasLowerStoreyPF.java

示例2: getRelatedObjects

import com.hp.hpl.jena.graph.Graph; //导入方法依赖的package包/类
@Override
protected HashSet<Node> getRelatedObjects(Node node, ExecutionContext execCxt) {
	HashSet<Node> results = new HashSet<Node>();

	Graph graph = execCxt.getActiveGraph();

	Node clazz = NodeFactory.createURI(Namespace.IFC2X3_TC1 + "IfcBuildingStorey");
	LinkedList<Storey> storeys = new LinkedList<Storey>();
	if (graph.contains(node, RDF.type.asNode(), clazz)) {
		Storey storey = new Storey(node, elevation(node, graph));
		ExtendedIterator<Triple> triples = graph.find(null, RDF.type.asNode(), clazz);
		while (triples.hasNext()) {
			Node subject = triples.next().getSubject();
			Storey s = new Storey(subject, elevation(subject, graph));
			if (s.elevation < storey.elevation) {
				addStorey(storeys, s, graph);
			}
		}
		if (storeys.size() > 0) {
			results.add(storeys.get(storeys.size() - 1).storey);
		}
	}
	return results;

}
 
开发者ID:BenzclyZhang,项目名称:BimSPARQL,代码行数:26,代码来源:HasLowerStoreyPF.java

示例3: getRelatedObjects

import com.hp.hpl.jena.graph.Graph; //导入方法依赖的package包/类
@Override
protected HashSet<Node> getRelatedObjects(Node node, ExecutionContext execCxt) {
	HashSet<Node> results = new HashSet<Node>();

	Graph graph = execCxt.getActiveGraph();

	Node clazz = NodeFactory.createURI(Namespace.IFC2X3_TC1 + "IfcBuildingStorey");
	LinkedList<Storey> storeys = new LinkedList<Storey>();
	if (graph.contains(node, RDF.type.asNode(), clazz)) {
		Storey storey = new Storey(node, elevation(node, graph));
		if (storey.elevation == Double.NaN) {
			return results;
		}
		ExtendedIterator<Triple> triples = graph.find(null, RDF.type.asNode(), clazz);
		while (triples.hasNext()) {
			Node subject = triples.next().getSubject();
			Storey s = new Storey(subject, elevation(subject, graph));
			if (s.elevation != Double.NaN) {
				if (s.elevation > storey.elevation) {
					addStorey(storeys, s, graph);
				}
			}
		}
		if (storeys.size() > 0) {
			results.add(storeys.get(0).storey);
		}
	}
	return results;
}
 
开发者ID:BenzclyZhang,项目名称:BimSPARQL,代码行数:30,代码来源:HasUpperStoreyPF.java

示例4: getRelatedSubjects

import com.hp.hpl.jena.graph.Graph; //导入方法依赖的package包/类
@Override
protected HashSet<Node> getRelatedSubjects(Node node, ExecutionContext execCxt) {
	HashSet<Node> results = new HashSet<Node>();

	Graph graph = execCxt.getActiveGraph();

	Node clazz = NodeFactory.createURI(Namespace.IFC2X3_TC1 + "IfcBuildingStorey");
	LinkedList<Storey> storeys = new LinkedList<Storey>();
	if (graph.contains(node, RDF.type.asNode(), clazz)) {
		Storey storey = new Storey(node, elevation(node, graph));
		if (storey.elevation == Double.NaN) {
			return results;
		}
		ExtendedIterator<Triple> triples = graph.find(null, RDF.type.asNode(), clazz);
		while (triples.hasNext()) {
			Node subject = triples.next().getSubject();
			Storey s = new Storey(subject, elevation(subject, graph));
			if (s.elevation != Double.NaN) {
				if (s.elevation < storey.elevation) {
					addStorey(storeys, s, graph);
				}
			}
		}
		if (storeys.size() > 0) {
			results.add(storeys.get(storeys.size() - 1).storey);
		}
	}
	return results;

}
 
开发者ID:BenzclyZhang,项目名称:BimSPARQL,代码行数:31,代码来源:HasUpperStoreyPF.java

示例5: addTriplesToDeductionGraph

import com.hp.hpl.jena.graph.Graph; //导入方法依赖的package包/类
/**
 * Transfer the triples inferred by {@link Inferray} into the deduced
 * {@link FGraph}
 * 
 * @param inferredTriples
 */
private void addTriplesToDeductionGraph(
		final CacheTripleStore inferredTriples) {
	final Graph fgraph = fdeductions.getGraph();
	final Iterator<LongPairArrayList> verticalIterator = inferredTriples
			.verticalIterator();
	Node s, o;
	int counter = 0;
	final NodeDictionary dictionary = inferray.getDictionary();
	// Iterate over properties table
	while (verticalIterator.hasNext()) {
		final LongPairArrayList longPairArrayList = verticalIterator.next();
		final Node p = dictionary.getNode(NodeDictionary.SPLIT_INDEX
				- longPairArrayList.getProperty());
		// Iterate over s,o for a given p
		for (int i = 0; i < longPairArrayList.size();) {
			s = dictionary.getNode(longPairArrayList.getQuick(i++));
			o = dictionary.getNode(longPairArrayList.getQuick(i++));
			final Triple triple = new Triple(s, p, o);
			if (fgraph.contains(triple)
					|| fdata.getGraph().contains(triple)) {
				if (LOGGER.isTraceEnabled()) {
					LOGGER.trace("Contains " + triple);
				}
			} else {
				counter++;
				if (LOGGER.isTraceEnabled()) {
					LOGGER.trace("Added " + triple);
				}
				fgraph.add(triple);
			}

		}
	}
	if (LOGGER.isTraceEnabled()) {
		LOGGER.trace("Deducted triples " + fgraph.size());
		LOGGER.trace("Already present " + fdata.getGraph().size());
		LOGGER.trace("Counter value " + counter);
	}

}
 
开发者ID:jsubercaze,项目名称:inferray,代码行数:47,代码来源:InferrayInfGraph.java

示例6: isTPFServer

import com.hp.hpl.jena.graph.Graph; //导入方法依赖的package包/类
/**
 * The function determines whether the remote url is TPF.
 *
 * @param url url adress of SPARQL endpoint or TriplePatternFragments server
 * @see https://lists.w3.org/Archives/Public/public-hydra/2015Aug/0040.html
 */
private boolean isTPFServer(String url) {
    HttpClient client = new DefaultHttpClient();
    HttpGet get = new HttpGet(url);
    try {
        get.setHeader("Accept", "text/turtle");
        HttpResponse response = client.execute(get);
        Model mod = ModelFactory.createDefaultModel();            
        mod.read(response.getEntity().getContent(), null, "TURTLE");
        Graph graph = mod.getGraph();
        
        Triple triple0 = new Triple(Node.ANY, 
                Node.createURI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), 
                Node.createURI("http://www.w3.org/ns/hydra/core#Collection"));
        Triple triple1 = new Triple(Node.ANY, 
                Node.createURI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), 
                Node.createURI("http://rdfs.org/ns/void#Dataset"));
        Triple triple2 = new Triple(Node.ANY, 
                Node.createURI("http://rdfs.org/ns/void#subset"), 
                Node.createURI(url));
        Triple triple3 = new Triple(Node.ANY, 
                Node.createURI("http://www.w3.org/ns/hydra/core#search"), 
                Node.createVariable("_:triplePattern"));
        Triple triple4 = new Triple(Node.createVariable("_:triplePattern"), 
                Node.createURI("http://www.w3.org/ns/hydra/core#mapping"), 
                Node.createVariable("_:subject"));
        Triple triple5 = new Triple(Node.createVariable("_:triplePattern"), 
                Node.createURI("http://www.w3.org/ns/hydra/core#mapping"), 
                Node.createVariable("_:predicate"));
        Triple triple6 = new Triple(Node.createVariable("_:triplePattern"), 
                Node.createURI("http://www.w3.org/ns/hydra/core#mapping"), 
                Node.createVariable("_:object"));
        Triple triple7 = new Triple(Node.createVariable("_:subject"), 
                Node.createURI("http://www.w3.org/ns/hydra/core#property"), 
                Node.createURI("http://www.w3.org/1999/02/22-rdf-syntax-ns#subject"));
        Triple triple8 = new Triple(Node.createVariable("_:predicate"), 
                Node.createURI("http://www.w3.org/ns/hydra/core#property"), 
                Node.createURI("http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate"));
        Triple triple9 = new Triple(Node.createVariable("_:object"), 
                Node.createURI("http://www.w3.org/ns/hydra/core#property"), 
                Node.createURI("http://www.w3.org/1999/02/22-rdf-syntax-ns#object"));
        boolean isTPF = graph.contains(triple0) && graph.contains(triple1) && graph.contains(triple2) &&
                graph.contains(triple3) && graph.contains(triple4) && graph.contains(triple5) &&
                graph.contains(triple6) && graph.contains(triple7) && graph.contains(triple8) && graph.contains(triple9);
        return isTPF;
    } catch (IOException ex) {            
    }
    return false;
}
 
开发者ID:KMax,项目名称:cqels,代码行数:55,代码来源:BDBGraphPatternRouter.java


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