⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rdfexplorerutil.java

📁 这是外国一个开源推理机
💻 JAVA
字号:
/*  Sesame - Storage and Querying architecture for RDF and RDF Schema *  Copyright (C) 2001-2005 Aduna * *  Contact: *  	Aduna *  	Prinses Julianaplein 14 b *  	3817 CS Amersfoort *  	The Netherlands *  	tel. +33 (0)33 465 99 87 *  	fax. +33 (0)33 465 99 87 * *  	http://aduna.biz/ *  	http://www.openrdf.org/ * *  This library is free software; you can redistribute it and/or *  modify it under the terms of the GNU Lesser General Public *  License as published by the Free Software Foundation; either *  version 2.1 of the License, or (at your option) any later version. * *  This library is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *  Lesser General Public License for more details. * *  You should have received a copy of the GNU Lesser General Public *  License along with this library; if not, write to the Free Software *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */package org.openrdf.sesame.server.http;import java.util.HashMap;import java.util.Map;import org.openrdf.util.StringUtil;import org.openrdf.util.http.HttpClientUtil;import org.openrdf.model.BNode;import org.openrdf.model.Literal;import org.openrdf.model.Resource;import org.openrdf.model.URI;import org.openrdf.model.Value;import org.openrdf.model.impl.URIImpl;import org.openrdf.rio.ntriples.NTriplesUtil;import org.openrdf.sesame.sail.RdfSource;import org.openrdf.sesame.sail.StatementIterator;public class RdfExplorerUtil {	private static Map _rdfLabelMap;	static {		_rdfLabelMap = new HashMap(64);		_rdfLabelMap.put(URIImpl.RDF_TYPE, "type");		_rdfLabelMap.put(URIImpl.RDF_PROPERTY, "Property");		_rdfLabelMap.put(URIImpl.RDF_STATEMENT, "Statement");		_rdfLabelMap.put(URIImpl.RDF_XMLLITERAL, "XMLLiteral");		_rdfLabelMap.put(URIImpl.RDF_SUBJECT, "subject");		_rdfLabelMap.put(URIImpl.RDF_PREDICATE, "predicate");		_rdfLabelMap.put(URIImpl.RDF_SUBJECT, "object");		_rdfLabelMap.put(URIImpl.RDF_FIRST, "first");		_rdfLabelMap.put(URIImpl.RDF_REST, "rest");		_rdfLabelMap.put(URIImpl.RDF_ALT, "Alt");		_rdfLabelMap.put(URIImpl.RDF_BAG, "Bag");		_rdfLabelMap.put(URIImpl.RDF_SEQ, "Seq");		_rdfLabelMap.put(URIImpl.RDF_LIST, "List");		_rdfLabelMap.put(URIImpl.RDF_NIL, "nil");		_rdfLabelMap.put(URIImpl.RDFS_CLASS, "Class");		_rdfLabelMap.put(URIImpl.RDFS_RESOURCE, "Resource");		_rdfLabelMap.put(URIImpl.RDFS_LITERAL, "Literal");		_rdfLabelMap.put(URIImpl.RDFS_SUBCLASSOF, "subClassOf");		_rdfLabelMap.put(URIImpl.RDFS_SUBPROPERTYOF, "subPropertyOf");		_rdfLabelMap.put(URIImpl.RDFS_DOMAIN, "domain");		_rdfLabelMap.put(URIImpl.RDFS_RANGE, "range");		_rdfLabelMap.put(URIImpl.RDFS_COMMENT, "comment");		_rdfLabelMap.put(URIImpl.RDFS_LABEL, "label");		_rdfLabelMap.put(URIImpl.RDFS_ISDEFINEDBY, "isDefinedBy");		_rdfLabelMap.put(URIImpl.RDFS_SEEALSO, "seeAlso");		_rdfLabelMap.put(URIImpl.RDFS_MEMBER, "member");		_rdfLabelMap.put(URIImpl.RDFS_DATATYPE, "Datatype");		_rdfLabelMap.put(URIImpl.RDFS_CONTAINER, "Container");		_rdfLabelMap.put(URIImpl.RDFS_CONTAINERMEMBERSHIPPROPERTY, "ContainerMemberShipProperty");	}	public static String getDisplayString(Value value) {		if (value instanceof URI) {			return ((URI)value).getURI();		}		else if (value instanceof BNode) {			return "_:" + ((BNode)value).getID();		}		else if (value instanceof Literal) {			Literal lit = (Literal)value;			StringBuffer buf = new StringBuffer(32);			buf.append("\"");			buf.append(lit.getLabel());			buf.append("\"");			if (lit.getLanguage() != null) {				buf.append("@").append(lit.getLanguage());			}			else if (lit.getDatatype() != null) {				buf.append("^^").append(lit.getDatatype().getURI());			}			return buf.toString();		}		return "";	}	public static String getLabelForResource(Resource resource, RdfSource rdfSource) {		// Check RDF/RDFS standard labels		String label = (String)_rdfLabelMap.get(resource);		if (label == null) {			// Get label from repository			StatementIterator labelIter = rdfSource.getStatements(resource, URIImpl.RDFS_LABEL, null);			while (labelIter.hasNext()) {				Value labelObj = labelIter.next().getObject();				if (labelObj instanceof Literal) {					label = ((Literal)labelObj).getLabel();					break;				}			}			labelIter.close();		}		return label;	}	public static String getQueryString(String repository, Value value, boolean useLabels) {		Map params = new HashMap(4);		params.put("repository", repository);		params.put("value", NTriplesUtil.toNTriplesString(value));		if (useLabels) {			params.put("useLabels", "yes");		}		return HttpClientUtil.buildQueryString(params);	}	public static String javaScriptEscape(String text) {		String result = StringUtil.gsub("\\", "\\\\", text);		result = StringUtil.gsub("\"", "\\\"", result);		result = StringUtil.gsub("'", "\\'", result);		return result;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -