org.nsdl.mptstore.query
Class SQLUnionQueryResults

java.lang.Object
  extended by org.nsdl.mptstore.query.SQLUnionQueryResults
All Implemented Interfaces:
java.util.Iterator<java.util.List<Node>>, ClosableIterator<java.util.List<Node>>, QueryResults

public class SQLUnionQueryResults
extends java.lang.Object
implements QueryResults

RDF query results generated from a list of SQL statements. This class executes the given SQL in the order given, and provides an RDF result row for each JDBC ResultSet row.

Author:
cwilper@cs.cornell.edu

Constructor Summary
SQLUnionQueryResults(java.sql.Connection conn, SQLProvider sqlProvider, int fetchSize, boolean autoReleaseConnection)
          Instantiate SQLUnionQueryResults to work with the given SQL on the given connection.
 
Method Summary
 void close()
          Close database resources held by this object.
 void finalize()
          In the event of garbage collection, make sure close() has occurred.
 java.util.List<java.lang.String> getTargets()
          Get the column names for these query result rows.
 boolean hasNext()
          Tell whether there's another row of results.
 java.util.List<Node> next()
          Get the next row of results.
 void remove()
          Throws UnsupportedOperationException.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLUnionQueryResults

public SQLUnionQueryResults(java.sql.Connection conn,
                            SQLProvider sqlProvider,
                            int fetchSize,
                            boolean autoReleaseConnection)
                     throws QueryException
Instantiate SQLUnionQueryResults to work with the given SQL on the given connection.

Parameters:
conn - the database connection to use.
sqlProvider - provides the SQL and column names for the query.
fetchSize - the JDBC fetchSize to use for each SQL query.
autoReleaseConnection - whether to automatically close/release the connection when the results are closed.
Throws:
QueryException - if an unexpected error occurs starting the query.
Method Detail

getTargets

public java.util.List<java.lang.String> getTargets()
Get the column names for these query result rows.

Specified by:
getTargets in interface QueryResults
Returns:
the ordered list of names.

hasNext

public boolean hasNext()
Tell whether there's another row of results.

Specified by:
hasNext in interface java.util.Iterator<java.util.List<Node>>
Specified by:
hasNext in interface QueryResults
Returns:
true if there's another row, false if not.

next

public java.util.List<Node> next()
Get the next row of results.

Specified by:
next in interface java.util.Iterator<java.util.List<Node>>
Specified by:
next in interface QueryResults
Returns:
the next row.

remove

public void remove()
            throws java.lang.UnsupportedOperationException
Throws UnsupportedOperationException. This operation is not supported by QueryResults implementations.

Specified by:
remove in interface java.util.Iterator<java.util.List<Node>>
Specified by:
remove in interface QueryResults
Throws:
java.lang.UnsupportedOperationException - if this method is called.

close

public void close()
Close database resources held by this object. This closes any open ResultSet and Statement objects. In addition, if autoReleaseConnection was specified as true, the database connection will also be closed/released.

Specified by:
close in interface ClosableIterator<java.util.List<Node>>

finalize

public void finalize()
In the event of garbage collection, make sure close() has occurred. Note: This is intended to be called by the VM, not by client code.

Overrides:
finalize in class java.lang.Object