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

📄 soapservices.java

📁 这是外国一个开源推理机
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
			String[] theStatementAsStringArray = new String[3];			theStatementAsStringArray[0] = _valueToString(st.getSubject());			theStatementAsStringArray[1] = _valueToString(st.getPredicate());			theStatementAsStringArray[2] = _valueToString(st.getObject());			result.add(theStatementAsStringArray);		}		return result;	}	protected String _valueToString(Value value) {		if (value instanceof Literal) {			return ((Literal)value).toString();		}		else if (value instanceof URI) {			return ((URI)value).getURI();		}		else if (value instanceof BNode) {			return ((BNode)value).getID();		}		else {			throw new IllegalArgumentException("value should be a Literal, URI or BNode");		}	}	public boolean hasStatement(String subj, String pred, String obj, boolean objIsLiteral)	{		boolean result = false;		SessionContext sc = getContext();		try {			LocalService service = SesameServer.getLocalService();			service.login(sc.user, sc.pass);			LocalRepository rep = (LocalRepository)service.getRepository(sc.repository);			Sail sail = rep.getSail();			if (sail instanceof RdfSchemaSource) {				RdfSchemaSource rdfSchema = (RdfSchemaSource)sail;				Resource subjR = null;				if (subj != null) {					subjR = new URIImpl(subj);				}				URI predR = null;				if (pred != null) {					predR = new URIImpl(pred);				}				Value objV = null;				if (obj != null) {					if (objIsLiteral) {						objV = new LiteralImpl(obj);					}					else {						objV = new URIImpl(obj);					}				}				result = rdfSchema.hasStatement(subjR, predR, objV);			}		}		catch (Exception ex) {			throw new RuntimeException(ex.getMessage());		}		return result;	} // hasStatement()	public boolean hasExplicitStatement(String subj, String pred, String obj, boolean objIsLiteral)	{		boolean result = false;		SessionContext sc = getContext();		try {			LocalService service = SesameServer.getLocalService();			service.login(sc.user, sc.pass);			LocalRepository rep = (LocalRepository)service.getRepository(sc.repository);			Sail sail = rep.getSail();			if (sail instanceof RdfSchemaSource) {				RdfSchemaSource rdfSchema = (RdfSchemaSource)sail;				Resource subjR = null;				if (subj != null) {					subjR = new URIImpl(subj);				}				URI predR = null;				if (pred != null) {					predR = new URIImpl(pred);				}				Value objV = null;				if (obj != null) {					if (objIsLiteral) {						objV = new LiteralImpl(obj);					}					else {						objV = new URIImpl(obj);					}				}				result = rdfSchema.hasExplicitStatement(subjR, predR, objV);			}		}		catch (Exception ex) {			throw new RuntimeException(ex.getMessage());		}		return result;	} // hasExplicitStatement()	public Vector getClasses()	{		Vector result = null;		SessionContext sc = getContext();		try {			LocalService service = SesameServer.getLocalService();			service.login(sc.user, sc.pass);			LocalRepository rep = (LocalRepository)service.getRepository(sc.repository);			Sail sail = rep.getSail();			if (sail instanceof RdfSchemaSource) {				RdfSchemaSource rdfSchema = (RdfSchemaSource)sail;				StatementIterator iter = rdfSchema.getClasses();				result = _statementIteratorToVector(iter);				iter.close();			}		}		catch (Exception ex) {			throw new RuntimeException(ex.getMessage());		}		return result;	} // getClasses()	public boolean isClass(String resource)	{		boolean result = false;		SessionContext sc = getContext();		try {			LocalService service = SesameServer.getLocalService();			service.login(sc.user, sc.pass);			LocalRepository rep = (LocalRepository)service.getRepository(sc.repository);			Sail sail = rep.getSail();			if (sail instanceof RdfSchemaSource) {				RdfSchemaSource rdfSchema = (RdfSchemaSource)sail;				result = rdfSchema.isClass(new URIImpl(resource));			}		}		catch (Exception ex) {			throw new RuntimeException(ex.getMessage());		}		return result;	} // isClass()	public Vector getProperties()	{		Vector result = null;		SessionContext sc = getContext();		try {			LocalService service = SesameServer.getLocalService();			service.login(sc.user, sc.pass);			LocalRepository rep = (LocalRepository)service.getRepository(sc.repository);			Sail sail = rep.getSail();			if (sail instanceof RdfSchemaSource) {				RdfSchemaSource rdfSchema = (RdfSchemaSource)sail;				StatementIterator iter = rdfSchema.getProperties();				result = _statementIteratorToVector(iter);				iter.close();			}		}		catch (Exception ex) {			throw new RuntimeException(ex.getMessage());		}		return result;	} // getProperties()	public boolean isProperty(String resource)	{		boolean result = false;		SessionContext sc = getContext();		try {			LocalService service = SesameServer.getLocalService();			service.login(sc.user, sc.pass);			LocalRepository rep = (LocalRepository)service.getRepository(sc.repository);			Sail sail = rep.getSail();			if (sail instanceof RdfSchemaSource) {				RdfSchemaSource rdfSchema = (RdfSchemaSource)sail;				result = rdfSchema.isProperty(new URIImpl(resource));			}		}		catch (Exception ex) {			throw new RuntimeException(ex.getMessage());		}		return result;	} // isProperty()	public Vector getSubClassOf(String subClass, String superClass)	{		Vector result = null;		SessionContext sc = getContext();		try {			LocalService service = SesameServer.getLocalService();			service.login(sc.user, sc.pass);			LocalRepository rep = (LocalRepository)service.getRepository(sc.repository);			Sail sail = rep.getSail();			if (sail instanceof RdfSchemaSource) {				RdfSchemaSource rdfSchema = (RdfSchemaSource)sail;				URI rSubClass = null, rSuperClass = null;				if (subClass != null) {					rSubClass = new URIImpl(subClass);				}				if (superClass != null) {					rSuperClass = new URIImpl(superClass);				}				StatementIterator iter = rdfSchema.getSubClassOf(rSubClass, rSuperClass);				result = _statementIteratorToVector(iter);				iter.close();			}		}		catch (Exception ex) {			throw new RuntimeException(ex.getMessage());		}		return result;	} // getSubClassesOf()	public Vector getDirectSubClassOf(String subClass, String superClass)	{		Vector result = null;		SessionContext sc = getContext();		try {			LocalService service = SesameServer.getLocalService();			service.login(sc.user, sc.pass);			LocalRepository rep = (LocalRepository)service.getRepository(sc.repository);			Sail sail = rep.getSail();			if (sail instanceof RdfSchemaSource) {				RdfSchemaSource rdfSchema = (RdfSchemaSource)sail;				URI rSubClass = null, rSuperClass = null;				if (subClass != null) {					rSubClass = new URIImpl(subClass);				}				if (superClass != null) {					rSuperClass = new URIImpl(superClass);				}				StatementIterator iter = rdfSchema.getDirectSubClassOf(rSubClass, rSuperClass);				result = _statementIteratorToVector(iter);				iter.close();			}		}		catch (Exception ex) {			throw new RuntimeException(ex.getMessage());		}		return result;	} // getDirectSubClassesOf()	public boolean isSubClassOf(String subClass, String superClass)	{		boolean result = false;		SessionContext sc = getContext();		try {			LocalService service = SesameServer.getLocalService();			service.login(sc.user, sc.pass);			LocalRepository rep = (LocalRepository)service.getRepository(sc.repository);			Sail sail = rep.getSail();			if (sail instanceof RdfSchemaSource) {				RdfSchemaSource rdfSchema = (RdfSchemaSource)sail;				result = rdfSchema.isSubClassOf(new URIImpl(subClass), new URIImpl(superClass));			}		}		catch (Exception ex) {			throw new RuntimeException(ex.getMessage());		}		return result;	} // isSubClassOf()	public boolean isDirectSubClassOf(String subClass, String superClass)	{		boolean result = false;		SessionContext sc = getContext();		try {			LocalService service = SesameServer.getLocalService();			service.login(sc.user, sc.pass);			LocalRepository rep = (LocalRepository)service.getRepository(sc.repository);			Sail sail = rep.getSail();			if (sail instanceof RdfSchemaSource) {				RdfSchemaSource rdfSchema = (RdfSchemaSource)sail;				result = rdfSchema.isDirectSubClassOf(new URIImpl(subClass), new URIImpl(superClass));			}		}		catch (Exception ex) {			throw new RuntimeException(ex.getMessage());		}		return result;	} // isDirectSubClassOf()	public Vector getSubPropertyOf(String subProperty, String superProperty)	{		Vector result = null;		SessionContext sc = getContext();		try {			LocalService service = SesameServer.getLocalService();			service.login(sc.user, sc.pass);			LocalRepository rep = (LocalRepository)service.getRepository(sc.repository);			Sail sail = rep.getSail();			if (sail instanceof RdfSchemaSource) {				RdfSchemaSource rdfSchema = (RdfSchemaSource)sail;				URI rSubProperty = null, rSuperProperty = null;				if (subProperty != null) {					rSubProperty = new URIImpl(subProperty);				}				if (superProperty != null) {					rSuperProperty = new URIImpl(superProperty);				}				StatementIterator iter = rdfSchema.getSubPropertyOf(rSubProperty, rSuperProperty);				result = _statementIteratorToVector(iter);				iter.close();			}		}		catch (Exception ex) {			throw new RuntimeException(ex.getMessage());		}		return result;	} // getSubPropertyesOf()	public Vector getDirectSubPropertyOf(String subProperty, String superProperty)	{		Vector result = null;		SessionContext sc = getContext();		try {			LocalService service = SesameServer.getLocalService();			service.login(sc.user, sc.pass);			LocalRepository rep = (LocalRepository)service.getRepository(sc.repository);			Sail sail = rep.getSail();			if (sail instanceof RdfSchemaSource) {				RdfSchemaSource rdfSchema = (RdfSchemaSource)sail;				URI rSubProperty = null, rSuperProperty = null;				if (subProperty != null) {					rSubProperty = new URIImpl(subProperty);				}				if (superProperty != null) {					rSuperProperty = new URIImpl(superProperty);				}				StatementIterator iter = rdfSchema.getDirectSubPropertyOf(rSubProperty, rSuperProperty);				result = _statementIteratorToVector(iter);				iter.close();			}		}		catch (Exception ex) {			throw new RuntimeException(ex.getMessage());		}		return result;	} // getDirectSubPropertyesOf()	public boolean isSubPropertyOf(String subProperty, String superProperty)	{		boolean result = false;		SessionContext sc = getContext();		try {			LocalService service = SesameServer.getLocalService();			service.login(sc.user, sc.pass);			LocalRepository rep = (LocalRepository)service.getRepository(sc.repository);			Sail sail = rep.getSail();			if (sail instanceof RdfSchemaSource) {				RdfSchemaSource rdfSchema = (RdfSchemaSource)sail;				result = rdfSchema.isSubPropertyOf(new URIImpl(subProperty), new URIImpl(superProperty));			}		}		catch (Exception ex) {			throw new RuntimeException(ex.getMessage());		}		return result;	} // isSubPropertyOf()	public boolean isDirectSubPropertyOf(String subProperty, String superProperty)	{		boolean result = false;		SessionContext sc = getContext();		try {			LocalService service = SesameServer.getLocalService();			service.login(sc.user, sc.pass);

⌨️ 快捷键说明

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