All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class ParkaClient.ParkaNet

java.lang.Object
   |
   +----ParkaClient.ParkaNet

public class ParkaNet
extends Object
A client interface for communicating with a Parka server. Provides methods to connect to a server, open a knowledge base, issue queries, and make updates.


Variable Index

 o answers
 o browserAnswers
 o browserMsg
 o hostname
 o instream
 o KBName
 o kbOpen
 o newPredList
 o numAnswersMsg
 o numTotalAnswersToQuery
 o outstream
 o parent
 o port
 o predArity
 o predicates
 o socket
 o statusMsg
 o usingMem
'usingMem' refers to using memory vs.
 o vars
 o varStatus

Constructor Index

 o ParkaNet(ParkaWin)
Methods

Method Index

 o changeParkaHost(String, int)
Change hostname and port used to connect to PARKA
 o clearNumAnswersToQueryMsg()
 o closeKB()
Close the current knowledge base.
 o connect()
Make a socket connection to the Parka server.
 o deleteFrame(String)
Deletes a frame from the KB.
 o deleteFromKB(String)
Given an assertion (in standard Parka format, including the enclosing parentheses), removes it from the KB.
 o disconnect()
Disconnect from the Parka server.
 o displayNumAnswersToQueryMsg()
 o getAnswers(int, int)
Gets start...end answers from the server and puts them in the 'answers' array.
 o getBrowserAnswers()
Returns a 2-D array of the answers to the browsing query.
 o getDescendants(String)
A version of getDescendants that automatically returns instances as well as categories.
 o getDescendants(String, boolean)
Given the name of a parent category gets all sub-categories of it.
 o getImmediateDescendants(String)
Returns all the direct descendant categories of a particular category.
 o getKbNames()
Returns a list of KBs that are available to the connection.
 o getKbStats()
Get the size stats for the currently loaded KB.
 o getNumTotalAnswersToQuery()
Returns the number of answers (complete sets of variables bindings) generated by the last query sent to the server.
 o getNumVariables()
 o getPredicateArity(String)
Returns the arity of the predicate with the given name.
 o getPredicateList()
Retrieves the list of predicates and their arities from the KB and stores them for later use.
 o getPreds()
Gets a list of predicates relevant to a particular database.
 o getTimingStats()
Get the timing statistics for the last query.
 o getVariableList()
 o getVariables()
Retrieves the list of variables in the order that values are bound to them.
 o insertFrame(String)
Inserts a new frame into the KB.
 o insertPredicate(String, int)
Inserts a predicate of the given arity into the KB.
 o insertToKB(String)
 o isConnection()
Returns true if there is a connection to PARKA open.
 o isKBOpen()
Returns true if a knowledge base is currently open on the connection.
 o openKB(String, boolean)
Open the KB with the given name.
 o query(String)
Given a string representing a Parka query, returns a QueryResults object that contains the answers, or null on error.
 o submitBrowsingQuery(String)
Submit a "browsing" style query.
 o submitQuery(String)
Given a Parka query string, sends the query to the server and determines the status of this query.

Variables

 o KBName
 protected String KBName
 o usingMem
 protected boolean usingMem
'usingMem' refers to using memory vs. disk in internal Parka operations, ie, joins.

 o predicates
 protected String predicates[]
 o predArity
 protected int predArity[]
 o parent
 protected ParkaWin parent
 o socket
 protected Socket socket
 o instream
 protected InputStream instream
 o outstream
 protected OutputStream outstream
 o kbOpen
 protected boolean kbOpen
 o newPredList
 protected boolean newPredList
 o hostname
 protected String hostname
 o port
 protected int port
 o numTotalAnswersToQuery
 protected int numTotalAnswersToQuery
 o varStatus
 protected int varStatus
 o numAnswersMsg
 protected String numAnswersMsg
 o answers
 protected String answers[]
 o vars
 protected String vars[]
 o browserAnswers
 protected String browserAnswers[][]
 o browserMsg
 protected String browserMsg
 o statusMsg
 public String statusMsg

Constructors

 o ParkaNet
 public ParkaNet(ParkaWin parent)
Methods

Methods

 o clearNumAnswersToQueryMsg
 public void clearNumAnswersToQueryMsg()
 o displayNumAnswersToQueryMsg
 public void displayNumAnswersToQueryMsg()
 o connect
 public void connect()
Make a socket connection to the Parka server.

 o disconnect
 public void disconnect()
Disconnect from the Parka server. Close the knowledge base if it is still open.

 o isConnection
 public boolean isConnection()
Returns true if there is a connection to PARKA open.

 o changeParkaHost
 public void changeParkaHost(String newhost,
                             int newport)
Change hostname and port used to connect to PARKA

 o isKBOpen
 public synchronized boolean isKBOpen()
Returns true if a knowledge base is currently open on the connection.

 o openKB
 public void openKB(String newkbName,
                    boolean memoryp)
Open the KB with the given name.

 o closeKB
 public void closeKB()
Close the current knowledge base.

 o query
 public QueryResults query(String queryString)
Given a string representing a Parka query, returns a QueryResults object that contains the answers, or null on error. The query string should be the standard Parka format: (pred#arg1#arg2...)(pred#arg1#arg2...)....

 o submitQuery
 public void submitQuery(String query)
Given a Parka query string, sends the query to the server and determines the status of this query. Messages are returned using the displayMessage() interface. Calls getVariables() but, in order to get the answers, the caller must also call getAnswers().

 o submitBrowsingQuery
 public int submitBrowsingQuery(String query)
Submit a "browsing" style query. These queries have a specialized expected structure -- see comments on server side for more info. Note that browse queries can only be issued on binary KBs. Returns contents of an error message, if any.

 o getAnswers
 public String[] getAnswers(int start,
                            int end)
Gets start...end answers from the server and puts them in the 'answers' array. Here, an answer is one complete set of bindings for the variables. This routine should only be called after a query has previously been sent and getVariables() has been called. This routine will return the number of answers requested by the user, even if it requires making multiple calls to the Parka server to do so.

 o getBrowserAnswers
 public String[][] getBrowserAnswers()
Returns a 2-D array of the answers to the browsing query.

 o getVariables
 public String[] getVariables()
Retrieves the list of variables in the order that values are bound to them.

 o getKbNames
 public String[] getKbNames()
Returns a list of KBs that are available to the connection.

 o getKbStats
 public String[] getKbStats()
Get the size stats for the currently loaded KB.

 o getTimingStats
 public String[] getTimingStats()
Get the timing statistics for the last query. Returns the times as an array of strings.

 o getPreds
 public String[] getPreds()
Gets a list of predicates relevant to a particular database. User class is expected to call this routine after the thread loading the requested KB has successfully completed.

 o getPredicateList
 public String[] getPredicateList()
Retrieves the list of predicates and their arities from the KB and stores them for later use. Returns the predicate array

 o getPredicateArity
 public int getPredicateArity(String predname)
Returns the arity of the predicate with the given name.

 o getVariableList
 public String[] getVariableList()
 o getNumVariables
 public int getNumVariables()
 o getNumTotalAnswersToQuery
 public int getNumTotalAnswersToQuery()
Returns the number of answers (complete sets of variables bindings) generated by the last query sent to the server. In relational database terms, this is the number of rows returned.

 o getImmediateDescendants
 public String[] getImmediateDescendants(String parent)
Returns all the direct descendant categories of a particular category. This method has been superceded by the getDescendants() method.

 o getDescendants
 public String[][] getDescendants(String parent,
                                  boolean justCats)
Given the name of a parent category gets all sub-categories of it. If justCats is false, then it also returns the instances. In both cases, this returns an array of triplets of the form (parent, child-type, child) where child type is "s" if it is a sub-category and "i" if it is an instance. This function is particularly useful in a client server environment because issuing a separate query for each category can be much slower

 o getDescendants
 public String[][] getDescendants(String parent)
A version of getDescendants that automatically returns instances as well as categories.

 o insertToKB
 public void insertToKB(String assertion)
 o deleteFromKB
 public void deleteFromKB(String assertion)
Given an assertion (in standard Parka format, including the enclosing parentheses), removes it from the KB. If there are multiple identical assertions, all of them are removed.

 o insertFrame
 public void insertFrame(String frame)
Inserts a new frame into the KB.

 o deleteFrame
 public void deleteFrame(String frame)
Deletes a frame from the KB.

 o insertPredicate
 public void insertPredicate(String predname,
                             int arity)
Inserts a predicate of the given arity into the KB. Currently, insertions of predicates with the same name as an existing predicate are ignored by Parka. Calling this method on a binary KB may result in an error.


All Packages  Class Hierarchy  This Package  Previous  Next  Index