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


Java Namespace.getPrefix方法代码示例

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


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

示例1: findPrefix

import org.openrdf.model.Namespace; //导入方法依赖的package包/类
private String findPrefix(String ns, Model model) {
	for (Namespace e : model.getNamespaces()) {
		if (ns.equals(e.getName()) && e.getPrefix().length() > 0) {
			return e.getPrefix();
		}
	}
	if (resolvingPrefix) {
		String prefix = NamespacePrefixService.getInstance().prefix(ns);
		if (prefix != null && model.getNamespace(prefix) == null) {
			model.setNamespace(prefix, ns);
			return prefix;
		}
	}
	return "ns" + Integer.toHexString(ns.hashCode());
}
 
开发者ID:anno4j,项目名称:anno4j,代码行数:16,代码来源:OWLCompiler.java

示例2: getExportNamespacesResult

import org.openrdf.model.Namespace; //导入方法依赖的package包/类
/**
 * 
 * @param repository the Repository object
 * @param request the HttpServletRequest object 
 * @param response the HttpServletResponse oject
 * @return QueryResultView object include the namespaces
 * @throws ClientHTTPException throws when errors in the request
 * @throws ServerHTTPException throws when errors in the Repository
 * @throws RepositoryException throws when errors in closing the RepositoryConnection 
 */
private ModelAndView getExportNamespacesResult(final Repository repository, final HttpServletRequest request, final HttpServletResponse response)
		throws ClientHTTPException, ServerHTTPException, RepositoryException {
	final boolean headersOnly = METHOD_HEAD.equals(request.getMethod());

	Map<String, Object> model = new HashMap<String, Object>();
	if (!headersOnly) {
		List<String> columnNames = Arrays.asList("prefix", "namespace");
		List<BindingSet> namespaces = new ArrayList<BindingSet>();

		RepositoryConnection repositoryCon = repository.getConnection();
		synchronized (repositoryCon) {
			try {
				CloseableIteration<? extends Namespace, RepositoryException> iter = repositoryCon.getNamespaces();

				try {
					while (iter.hasNext()) {
						Namespace ns = iter.next();

						Literal prefix = new LiteralImpl(ns.getPrefix());
						Literal namespace = new LiteralImpl(ns.getName());

						BindingSet bindingSet = new ListBindingSet(columnNames, prefix, namespace);
						namespaces.add(bindingSet);
					}
				} finally {
					iter.close();
				}
			} catch (RepositoryException e) {
				throw new ServerHTTPException("Repository error: " + e.getMessage(), e);
			}
		}
		model.put(QueryResultView.QUERY_RESULT_KEY, new TupleQueryResultImpl(columnNames, namespaces));
		repositoryCon.close();
	}

	TupleQueryResultWriterFactory factory = ProtocolUtil.getAcceptableService(request, response,
			TupleQueryResultWriterRegistry.getInstance());

	model.put(QueryResultView.FILENAME_HINT_KEY, "namespaces");
	model.put(QueryResultView.HEADERS_ONLY, headersOnly);
	model.put(QueryResultView.FACTORY_KEY, factory);

	return new ModelAndView(TupleQueryResultView.getInstance(), model);
}
 
开发者ID:cumulusrdf,项目名称:cumulusrdf,代码行数:55,代码来源:NamespacesHandler.java


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