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

📄 racerclient.java

📁 Semantic Web Ontology Editor
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
package org.mindswap.swoop.racer;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Enumeration;
import java.util.Vector;

/** This class provides a full RACER client, providing Java methods to access RACER primitives;
	and performing simple parsing of the results obtained from RACER. */

public class RacerClient extends RacerSocketClient {

	/** This object is used to perform syntax checking for concepts and role terms. If it is set
	to null by the createTermParser method, no syntax checking is performed. */

	protected RacerTermParser termParser;

/** The constructor builds a RACER client for a given RACER server ip address, and a given RACER server
	port number.
 * @param ip java.lang.String The ip address.
 * @param port int The port number.
 */

public RacerClient(String ip, int port) {
	super(ip, port);
	termParser=createTermParser();
}
/** This method refers to the RACER abox-consistent? macro for the current tbox.
 * @return boolean true if the abox is consistent, and false otherwise.
 * @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
 * @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
 */

public boolean aboxConsistentP() throws java.io.IOException, RacerException {
	String res=send("(abox-consistent?)",true);
	return parseBoolean(res);
}
/** This method refers to the RACER abox-consistent? macro.
 * @return boolean true if the abox is consistent, and false otherwise.
 * @param abox java.lang.String The abox name.
 * @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
 * @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
 */

public boolean aboxConsistentP(String abox) throws java.io.IOException, RacerException {
	String res=send("(abox-consistent? "+abox+")",true);
	return parseBoolean(res);
}
/** This method refers to the RACER abox-realized-p function for the current tbox.
 * @return boolean true if the abox has already been realized, and false otherwise.
 * @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
 * @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
 */

public boolean aboxRealizedP() throws java.io.IOException, RacerException {
	String res=send("(abox-realized-p)",true);
	return parseBoolean(res);
}
/** This method refers to the RACER abox-realized-p function.
 * @return boolean true if the abox has already been realized, and false otherwise.
 * @param abox java.lang.String The abox name.
 * @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
 * @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
 */

public boolean aboxRealizedP(String abox) throws java.io.IOException, RacerException {
	String res=send("(abox-realized-p "+abox+")",true);
	return parseBoolean(res);
}
/** This method refers to the RACER add-concept-assertion function.
 * @param abox java.lang.String The abox name corresponding to the abox in which the assertion is added.
 * @param in java.lang.String The individual name.
 * @param c java.lang.String The concept term.
 * @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
 * @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
 */

public void addConceptAssertion(String abox, String in, String c) throws java.io.IOException, RacerException {
	if (termParser!=null) termParser.parseConcept(c);
	send("(add-concept-assertion "+abox+" "+in+" "+c+")",false);
}
/** This method refers to the add-concept-axiom RACER function.
 * @param tbox java.lang.String The name of the TBox where the axiom is to be included.
 * @param c1 java.lang.String One concept term.
 * @param c2 java.lang.String The other concept term.
 * @param inc boolean Specifies whether the axiom is an inclusion axiom (true) or
   an equality axiom (false).
 * @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
 * @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
 */

public void addConceptAxiom(String tbox,String c1, String c2,boolean inc) throws java.io.IOException, RacerException {
	if (termParser!=null) termParser.parseConcept(c1);
	if (termParser!=null) termParser.parseConcept(c2);
	send("(add-concept-axiom "+tbox+" "+c1+" "+c2+" :inclusion-p "+(inc ? "t)" : "nil)"),false);
}
/** This method refers to the RACER add-role-assertion function.
 * @param abox java.lang.String The name of the abox in which the role assertion is to be added.
 * @param in1 java.lang.String The individual name of the predecessor.
 * @param in2 java.lang.String The individual name of the successor.
 * @param r java.lang.String The role term.
 * @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
 * @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
 */

public void addRoleAssertion(String abox, String in1, String in2, String r) throws java.io.IOException, RacerException {
	if (termParser!=null) termParser.parseRole(r);
	send("(add-role-assertion "+abox+" "+in1+" "+in2+" "+r+")",false);
}
/** This method refers to the RACER alc-concept-coherent function
 * @return boolean true if the concept is coherent and false otherwise.
 * @param c java.lang.String The concept term.
 * @param logic int The logic to be used. It can be RacerConstants.K_LOGIC, RacerConstants.K4_LOGIC, or
   RacerConstants.S4_LOGIC
 * @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
 * @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
 */

public boolean alcConceptCoherent(String c, int logic) throws java.io.IOException, RacerException {
	if (termParser!=null) termParser.parseConcept(c);
	String res=send("(alc-concept-coherent '"+c+" :logic "+
				(logic==RacerConstants.K_LOGIC ? ":K)" : "")+
				(logic==RacerConstants.K4_LOGIC ? ":K4)" : "")+
				(logic==RacerConstants.S4_LOGIC ? ":S4)" : ""),true);
	return parseBoolean(res);
}
/** This method refers to the RACER all-aboxes function.
 * @return java.lang.String[] An array of strings with the names of the aboxes.
 * @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
 * @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
 */

public String[] allABoxes() throws java.io.IOException, RacerException {
	String res=send("(all-aboxes)",true);
	return parseList(res);
}
/** This method refers to the RACER all-atomic-concepts function for the current tbox.
 * @return java.lang.String[] An array of strings with the names of the atomic concepts in the tbox.
 * @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
 * @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
 */

public String[] allAtomicConcepts() throws java.io.IOException, RacerException {
	String res=send("(all-atomic-concepts)",true);
	return parseConceptSetList(res);
}
/** This method refers to the RACER all-atomic-concepts method.
 * @return java.lang.String[] An array of strings with the names of the atomic concepts in the tbox.
 * @param tbox java.lang.String The name of the tbox.
 * @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
 * @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
 */

public String[] allAtomicConcepts(String tbox) throws java.io.IOException, RacerException {
	String res=send("(all-atomic-concepts "+tbox+")",true);
	return parseConceptSetList(res);
}
/**  This method refers to the all-concept-assertions RACER macro for the current ABox.
 * @return ConceptAssertion[] The set of concept assertions in the ABox.
 * @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
 * @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
 */

public ConceptAssertion[] allConceptAssertions() throws IOException, RacerException {
	String res=send("(all-concept-assertions)",true);
	return parseConceptAssertionList(res);
}
/**  This method refers to the all-concept-assertions RACER macro.
 * @return ConceptAssertion[] An array with the concept assertions in the ABox.
 * @param abox java.lang.String The abox name.
 * @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
 * @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
 */

public ConceptAssertion[] allConceptAssertions(String abox) throws IOException, RacerException {
	String res=send("(all-concept-assertions "+abox+")",true);
	return parseConceptAssertionList(res);
}
/** This method refers to the all-concept-assertions-for-individual RACER macro for the current ABox.
 * @return ConceptAssertion[] An array of concept assertions.
 * @param in java.lang.String The individual name.
 * @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
 * @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
 */

public ConceptAssertion[] allConceptAssertionsForIndividual(String in) throws IOException, RacerException {
	String res=send("(all-concept-assertions-for-individual "+in+")",true);
	return parseConceptAssertionList(res);
}
/** This method refers to the all-concept-assertions-for-individual RACER macro.
 * @return ConceptAssertion[] An array of concept assertions.
 * @param abox java.lang.String The name of the abox.
 * @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
 * @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
 */

public ConceptAssertion[] allConceptAssertionsForIndividual(String in, String abox) throws IOException, RacerException {
	String res=send("(all-concept-assertions-for-individual "+in+" "+abox+")",true);
	return parseConceptAssertionList(res);
}
/** This method refers to the RACER all-features function for the current tbox.
 * @return java.lang.String[] An array of strings with the features in the tbox.
 * @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
 * @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
 */

public String[] allFeatures() throws java.io.IOException, RacerException {
	String res=send("(all-features)",true);
	return parseList(res);
}
/** This method refers to the RACER all-features function.
 * @return java.lang.String[] An array of strings with the features in the tbox.
 * @param tbox java.lang.String The name of the tbox.
 * @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
 * @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
 */

public String[] allFeatures(String tbox) throws java.io.IOException, RacerException {
	String res=send("(all-features "+tbox+")",true);
	return parseList(res);
}
/** This method refers to the RACER all-individuals function for the current tbox.
 * @return java.lang.String[] An array of strings with the names of the individuals in the abox.
 * @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
 * @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
 */

public String[] allIndividuals() throws java.io.IOException, RacerException {
	String res=send("(all-individuals)",true);
	return parseList(res);
}
/** This method refers to the RACER all-individuals function.
 * @return java.lang.String[] An array of strings with the names of the individuals in the tbox.
 * @param tbox java.lang.String The name of the tbox.
 * @exception java.io.IOException Thrown when there is a communication problem with the RACER server.
 * @exception dl.racer.RacerException Thrown when the RACER server produces an ":error" message.
 */

public String[] allIndividuals(String tbox) throws java.io.IOException, RacerException {
	String res=send("(all-individuals "+tbox+")",true);
	return parseList(res);
}
/** This method refers to the all-role-assertions RACER macro fo the current ABox.
 * @return RoleAssertion[] An array of role assertions.

⌨️ 快捷键说明

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