jess
Class QueryResult

java.lang.Object
  extended byjess.QueryResult

public class QueryResult
extends java.lang.Object

A ResultSet-like class to report the result of executing a Jess query. One of these is returned by the Rete.runQueryStar(java.lang.String, jess.ValueVector) method or by the run-query* function in Jess. Note that the arguments to the getXXX() methods are the names of variables that appear in the query, not the names of slots in the individual facts returned by the query.

(C) 2005 Sandia National Laboratories

See Also:
Rete.runQueryStar(java.lang.String, jess.ValueVector)

Method Summary
 void close()
          Dispose of this QueryResult.
 Value get(java.lang.String variableName)
          Return the value of the given variable in the current result record, as a jess.Value object
 boolean getBoolean(java.lang.String variableName)
          Return the value of the given variable in the current result record, interpreted as a Jess Boolean value.
 byte getByte(java.lang.String variableName)
          Return the value of the given variable in the current result record, as a byte.
 double getDouble(java.lang.String variableName)
          Return the value of the given variable in the current result record, as a double.
 float getFloat(java.lang.String variableName)
          Return the value of the given variable in the current result record, as a float.
 int getInt(java.lang.String variableName)
          Return the value of the given variable in the current result record, as an int.
 long getLong(java.lang.String variableName)
          Return the value of the given variable in the current result record, as a long.
 java.lang.Object getObject(java.lang.String variableName)
          Return the value of the given variable in the current result record, as a Java object
 short getShort(java.lang.String variableName)
          Return the value of the given variable in the current result record, as a short.
 java.lang.String getString(java.lang.String variableName)
          Return the value of the given variable in the current result record, as a String.
 java.lang.String getSymbol(java.lang.String variableName)
          Return the value of the given variable in the current result record, as a symbol.
 boolean next()
          Advance the cursor to the next result record.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

next

public boolean next()
Advance the cursor to the next result record. When a QueryResult is first created, the cursor is positioned before the first record, so that you must call next() before attempting to access the first record.

Returns:
true if the cursor is now pointing to a valid result record, or false at the end

close

public void close()
Dispose of this QueryResult.


getString

public java.lang.String getString(java.lang.String variableName)
                           throws JessException
Return the value of the given variable in the current result record, as a String.

Parameters:
variableName - the name of a variable mentioned anywhere in the query
Returns:
the value of that variable
Throws:
JessException - if the variable does not hold a String, or the cursor is invalid.

getSymbol

public java.lang.String getSymbol(java.lang.String variableName)
                           throws JessException
Return the value of the given variable in the current result record, as a symbol.

Parameters:
variableName - the name of a variable mentioned anywhere in the query
Returns:
the value of that variable
Throws:
JessException - if the variable does not hold a symbol, or the cursor is invalid.

getBoolean

public boolean getBoolean(java.lang.String variableName)
                   throws JessException
Return the value of the given variable in the current result record, interpreted as a Jess Boolean value. The symbol FALSE signifies false; anything else is true.

Parameters:
variableName - the name of a variable mentioned anywhere in the query
Returns:
the value of that variable
Throws:
JessException - if the variable can't be interpreted as a Boolean, or the cursor is invalid.

getByte

public byte getByte(java.lang.String variableName)
             throws JessException
Return the value of the given variable in the current result record, as a byte.

Parameters:
variableName - the name of a variable mentioned anywhere in the query
Returns:
the value of that variable
Throws:
JessException - if the variable does not hold a number, or the cursor is invalid.

getShort

public short getShort(java.lang.String variableName)
               throws JessException
Return the value of the given variable in the current result record, as a short.

Parameters:
variableName - the name of a variable mentioned anywhere in the query
Returns:
the value of that variable
Throws:
JessException - if the variable does not hold a number, or the cursor is invalid.

getInt

public int getInt(java.lang.String variableName)
           throws JessException
Return the value of the given variable in the current result record, as an int.

Parameters:
variableName - the name of a variable mentioned anywhere in the query
Returns:
the value of that variable
Throws:
JessException - if the variable does not hold a number, or the cursor is invalid.

getLong

public long getLong(java.lang.String variableName)
             throws JessException
Return the value of the given variable in the current result record, as a long.

Parameters:
variableName - the name of a variable mentioned anywhere in the query
Returns:
the value of that variable
Throws:
JessException - if the variable does not hold a number, or the cursor is invalid.

getFloat

public float getFloat(java.lang.String variableName)
               throws JessException
Return the value of the given variable in the current result record, as a float.

Parameters:
variableName - the name of a variable mentioned anywhere in the query
Returns:
the value of that variable
Throws:
JessException - if the variable does not hold a number, or the cursor is invalid.

getDouble

public double getDouble(java.lang.String variableName)
                 throws JessException
Return the value of the given variable in the current result record, as a double.

Parameters:
variableName - the name of a variable mentioned anywhere in the query
Returns:
the value of that variable
Throws:
JessException - if the variable does not hold a number, or the cursor is invalid.

getObject

public java.lang.Object getObject(java.lang.String variableName)
                           throws JessException
Return the value of the given variable in the current result record, as a Java object

Parameters:
variableName - the name of a variable mentioned anywhere in the query
Returns:
the value of that variable
Throws:
JessException - if the variable does not hold a Java object, or the cursor is invalid.

get

public Value get(java.lang.String variableName)
          throws JessException
Return the value of the given variable in the current result record, as a jess.Value object

Parameters:
variableName - the name of a variable mentioned anywhere in the query
Returns:
the value of that variable
Throws:
JessException - if the variable is undefined, or the cursor is invalid.

© 2006 Sandia Corporation