|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmain.DataGatherer
public class DataGatherer
The DataGatherer
class serves as a connection to Sophia. Its
methods allow to send queries to sophia and to retrieve the results. A query
must be set before it is executed and a query must be executed before its
result can be seen.
Nested Class Summary | |
---|---|
(package private) class |
DataGatherer.ReadLine
|
Field Summary | |
---|---|
private java.lang.String |
query
|
private java.lang.String |
result
|
private int |
timeout
|
Constructor Summary | |
---|---|
DataGatherer()
Creates a new, uninitialized DataGatherer with a time-out
value of 10 seconds. |
|
DataGatherer(int timeout)
Creates a new, uninitialized DataGatherer with a specified
time before a query times out. |
Method Summary | |
---|---|
void |
executeQuery()
Executes the query and stores the results. |
void |
executeQuery(int timeout)
Executes the query and stores the results. |
java.lang.String |
getResult()
Returns the results from Sophia from executing the query. |
private java.lang.String |
sendQuery(java.lang.String host,
java.lang.String port,
int timeout)
|
void |
setQuery(java.lang.String query)
Sets the Prolog query that will be sent to Sophia. |
java.lang.String |
toString()
Returns a string representation of the DataGatherer . |
private java.lang.String |
tryHosts(int timeout)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private java.lang.String query
private java.lang.String result
private int timeout
Constructor Detail |
---|
public DataGatherer()
DataGatherer
with a time-out
value of 10 seconds.
public DataGatherer(int timeout)
DataGatherer
with a specified
time before a query times out.
timeout
- the time in seconds a query has before it times outMethod Detail |
---|
public void setQuery(java.lang.String query)
query
- a String
public void executeQuery() throws java.net.UnknownHostException, java.io.IOException
java.net.UnknownHostException
- the host is not accessible
java.io.IOException
- an I/O error occurredpublic void executeQuery(int timeout) throws java.net.UnknownHostException, java.io.IOException
timeout
- the time in seconds the query has before it times out
java.net.UnknownHostException
- if the host is not accessible
java.io.IOException
- if an I/O error occurredpublic java.lang.String getResult()
private java.lang.String tryHosts(int timeout) throws java.net.UnknownHostException, java.io.IOException
java.net.UnknownHostException
java.io.IOException
private java.lang.String sendQuery(java.lang.String host, java.lang.String port, int timeout) throws java.io.IOException, java.net.UnknownHostException
java.io.IOException
java.net.UnknownHostException
public java.lang.String toString()
DataGatherer
.
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |