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.
-
answers
-
-
browserAnswers
-
-
browserMsg
-
-
hostname
-
-
instream
-
-
KBName
-
-
kbOpen
-
-
newPredList
-
-
numAnswersMsg
-
-
numTotalAnswersToQuery
-
-
outstream
-
-
parent
-
-
port
-
-
predArity
-
-
predicates
-
-
socket
-
-
statusMsg
-
-
usingMem
- 'usingMem' refers to using memory vs.
-
vars
-
-
varStatus
-
-
ParkaNet(ParkaWin)
- Methods
-
changeParkaHost(String, int)
- Change hostname and port used to connect to PARKA
-
clearNumAnswersToQueryMsg()
-
-
closeKB()
- Close the current knowledge base.
-
connect()
- Make a socket connection to the Parka server.
-
deleteFrame(String)
- Deletes a frame from the KB.
-
deleteFromKB(String)
- Given an assertion (in standard Parka format, including the
enclosing parentheses), removes it from the KB.
-
disconnect()
- Disconnect from the Parka server.
-
displayNumAnswersToQueryMsg()
-
-
getAnswers(int, int)
- Gets start...end answers from the server and puts them in
the 'answers' array.
-
getBrowserAnswers()
- Returns a 2-D array of the answers to the browsing query.
-
getDescendants(String)
- A version of getDescendants that automatically returns instances
as well as categories.
-
getDescendants(String, boolean)
- Given the name of a parent category gets all sub-categories of it.
-
getImmediateDescendants(String)
- Returns all the direct descendant categories of a particular
category.
-
getKbNames()
- Returns a list of KBs that are available to the connection.
-
getKbStats()
- Get the size stats for the currently loaded KB.
-
getNumTotalAnswersToQuery()
- Returns the number of answers (complete sets of variables bindings)
generated by the last query sent to the server.
-
getNumVariables()
-
-
getPredicateArity(String)
- Returns the arity of the predicate with the given name.
-
getPredicateList()
- Retrieves the list of predicates and their arities from the KB
and stores them for later use.
-
getPreds()
- Gets a list of predicates relevant to a particular database.
-
getTimingStats()
- Get the timing statistics for the last query.
-
getVariableList()
-
-
getVariables()
- Retrieves the list of variables in the order that values are
bound to them.
-
insertFrame(String)
- Inserts a new frame into the KB.
-
insertPredicate(String, int)
- Inserts a predicate of the given arity into the KB.
-
insertToKB(String)
-
-
isConnection()
- Returns true if there is a connection to PARKA open.
-
isKBOpen()
- Returns true if a knowledge base is currently open on the connection.
-
openKB(String, boolean)
- Open the KB with the given name.
-
query(String)
- Given a string representing a Parka query, returns a QueryResults
object that contains the answers, or null on error.
-
submitBrowsingQuery(String)
- Submit a "browsing" style query.
-
submitQuery(String)
- Given a Parka query string, sends the query to the server and
determines the status of this query.
KBName
protected String KBName
usingMem
protected boolean usingMem
- 'usingMem' refers to using memory vs. disk in internal
Parka operations, ie, joins.
predicates
protected String predicates[]
predArity
protected int predArity[]
parent
protected ParkaWin parent
socket
protected Socket socket
instream
protected InputStream instream
outstream
protected OutputStream outstream
kbOpen
protected boolean kbOpen
newPredList
protected boolean newPredList
hostname
protected String hostname
port
protected int port
numTotalAnswersToQuery
protected int numTotalAnswersToQuery
varStatus
protected int varStatus
numAnswersMsg
protected String numAnswersMsg
answers
protected String answers[]
vars
protected String vars[]
browserAnswers
protected String browserAnswers[][]
browserMsg
protected String browserMsg
statusMsg
public String statusMsg
ParkaNet
public ParkaNet(ParkaWin parent)
- Methods
clearNumAnswersToQueryMsg
public void clearNumAnswersToQueryMsg()
displayNumAnswersToQueryMsg
public void displayNumAnswersToQueryMsg()
connect
public void connect()
- Make a socket connection to the Parka server.
disconnect
public void disconnect()
- Disconnect from the Parka server. Close the knowledge base if it is
still open.
isConnection
public boolean isConnection()
- Returns true if there is a connection to PARKA open.
changeParkaHost
public void changeParkaHost(String newhost,
int newport)
- Change hostname and port used to connect to PARKA
isKBOpen
public synchronized boolean isKBOpen()
- Returns true if a knowledge base is currently open on the connection.
openKB
public void openKB(String newkbName,
boolean memoryp)
- Open the KB with the given name.
closeKB
public void closeKB()
- Close the current knowledge base.
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...)....
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().
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.
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.
getBrowserAnswers
public String[][] getBrowserAnswers()
- Returns a 2-D array of the answers to the browsing query.
getVariables
public String[] getVariables()
- Retrieves the list of variables in the order that values are
bound to them.
getKbNames
public String[] getKbNames()
- Returns a list of KBs that are available to the connection.
getKbStats
public String[] getKbStats()
- Get the size stats for the currently loaded KB.
getTimingStats
public String[] getTimingStats()
- Get the timing statistics for the last query. Returns the
times as an array of strings.
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.
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
getPredicateArity
public int getPredicateArity(String predname)
- Returns the arity of the predicate with the given name.
getVariableList
public String[] getVariableList()
getNumVariables
public int getNumVariables()
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.
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.
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
getDescendants
public String[][] getDescendants(String parent)
- A version of getDescendants that automatically returns instances
as well as categories.
insertToKB
public void insertToKB(String assertion)
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.
insertFrame
public void insertFrame(String frame)
- Inserts a new frame into the KB.
deleteFrame
public void deleteFrame(String frame)
- Deletes a frame from the KB.
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