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


Java Graph.getRootContextNode方法代码示例

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


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

示例1: geAllCollections

import xdi2.core.Graph; //导入方法依赖的package包/类
public ArrayList<PCAttributeCollection> geAllCollections() {

		Graph g = this.getWholeGraph();
		ContextNode root = g.getRootContextNode();
		ReadOnlyIterator<Literal> allLiterals = root.getAllLiterals();
		while (allLiterals.hasNext()) {
			Literal lit = allLiterals.next();
			String value = lit.getLiteralData().toString();
			String name = lit.getContextNode().toString();
		}
		return null;

	}
 
开发者ID:peacekeeper,项目名称:clouds-client-basic,代码行数:14,代码来源:PersonalCloud.java

示例2: main

import xdi2.core.Graph; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

		// create a simple graph with context nodes, a relation, and a literal

		Graph graph = MemoryGraphFactory.getInstance().openGraph();

		ContextNode root = graph.getRootContextNode();
		ContextNode markus = root.setContextNode(XDIArc.create("=markus"));
		ContextNode animesh = root.setContextNode(XDIArc.create("=animesh"));
		ContextNode name = markus.setContextNode(XDIArc.create("<#name>"));
		Relation relation = markus.setRelation(XDIAddress.create("#friend"), animesh);
		LiteralNode literalNode = name.setLiteralNode("Markus Sabadello");

		// write some statements from our graph

		System.out.println("Statement associated with a context node: " + markus.getStatement());
		System.out.println("Statement associated with a relation: " + relation.getStatement());
		System.out.println("Statement associated with a literal: " + literalNode.getStatement());
		System.out.println();

		// we can also add a whole new statement to the graph

		graph.setStatement(XDIStatement.create("=alice/#friend/=bob"));

		// write the whole graph in different serialization formats

		System.out.println("Serialization in XDI/JSON: \n");
		XDIWriterRegistry.forFormat("XDI/JSON", null).write(graph, System.out);
		System.out.println();
		System.out.println();

		System.out.println("Serialization in XDI statements:\n");
		XDIWriterRegistry.forFormat("XDI DISPLAY", null).write(graph, System.out);

		// close the graph

		graph.close();
	}
 
开发者ID:projectdanube,项目名称:xdi2-example-core,代码行数:39,代码来源:GraphModel.java

示例3: linkContractExists

import xdi2.core.Graph; //导入方法依赖的package包/类
public boolean linkContractExists(String connectRequest) {
	System.out.println("\nChecking if a link contract exists\n");
	boolean result = false;
	MemoryJSONGraphFactory graphFactory = new MemoryJSONGraphFactory();
	String templateOwnerInumber = null;
	try {
		Graph g = graphFactory.parseGraph(connectRequest);
		// get remote cloud number

		XDIWriterRegistry.forFormat("XDI DISPLAY", null).write(g,
				System.out);
		ContextNode c = g.getRootContextNode();
		ReadOnlyIterator<ContextNode> allCNodes = c.getAllContextNodes();
		for (ContextNode ci : allCNodes) {
			if (ci.containsContextNode(XDI3SubSegment.create("[$msg]"))) {
				templateOwnerInumber = ci.toString();
				System.out.println(templateOwnerInumber);
				break;
			}
		}
		if (templateOwnerInumber == null) {
			System.out
					.println("No cloudnumber for requestor/template owner");
			return result;
		}
		// get the address of the link contract template
		// $set{$do}

		String lcTemplateAddress = null;

		ReadOnlyIterator<Relation> allRelations = c.getAllRelations(); // g.getDeepRelations(XDI3Segment.create(templateOwnerInumber),XDI3Segment.create("$get"));
		for (Relation r : allRelations) {
			if (r.getArcXri().toString().equals("$set{$do}")) {
				lcTemplateAddress = r.getTargetContextNodeXri().toString();
				System.out.println(r.getTargetContextNodeXri());
			}

		}
		if (lcTemplateAddress == null) {
			System.out.println("No LC template address provided");
			return result;
		}
	} catch (Exception io) {
		io.printStackTrace();
		return result;
	}

	String isPlusstmt = new String();
	isPlusstmt += this.cloudNumber;
	isPlusstmt += "$to";
	isPlusstmt += templateOwnerInumber;
	isPlusstmt += "$from";
	isPlusstmt += templateOwnerInumber;
	isPlusstmt += "+registration$do";

	ArrayList<XDI3Segment> querySegments = new ArrayList<XDI3Segment>();

	querySegments.add(XDI3Segment.create(isPlusstmt));

	MessageResult responseFromRemoteCloud = this.sendQueries(querySegments,
			null, false);

	Graph responseGraph = responseFromRemoteCloud.getGraph();
	ContextNode responseRootContext = responseGraph.getRootContextNode();
	System.out.println("\n\nLink Contract exists check\n\n"
			+ responseGraph.toString());
	if (responseRootContext.getContextNodeCount() > 1) {
		result = true;
	}

	return result;
}
 
开发者ID:peacekeeper,项目名称:clouds-client-basic,代码行数:73,代码来源:PersonalCloud.java


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