[Mulgara-svn] r775 - in trunk/src/jar: client-jrdf/java/org/mulgara/client/jrdf/test demo-mp3/java/org/mulgara/demo/mp3/swing util/java/org/mulgara/util
pag at mulgara.org
pag at mulgara.org
Fri Apr 11 19:40:05 UTC 2008
Author: pag
Date: 2008-04-11 12:40:04 -0700 (Fri, 11 Apr 2008)
New Revision: 775
Modified:
trunk/src/jar/client-jrdf/java/org/mulgara/client/jrdf/test/ClientGraphUnitTest.java
trunk/src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/Mp3Application.java
trunk/src/jar/util/java/org/mulgara/util/AbstractMulgaraResultSet.java
trunk/src/jar/util/java/org/mulgara/util/MulgaraResultSet.java
trunk/src/jar/util/java/org/mulgara/util/RowList.java
trunk/src/jar/util/java/org/mulgara/util/TestResultSet.java
trunk/src/jar/util/java/org/mulgara/util/TestResultSetTest.java
trunk/src/jar/util/java/org/mulgara/util/UIDGeneratorUnitTest.java
Log:
Cleaned up deprecated references, formatting, and warnings
Modified: trunk/src/jar/client-jrdf/java/org/mulgara/client/jrdf/test/ClientGraphUnitTest.java
===================================================================
--- trunk/src/jar/client-jrdf/java/org/mulgara/client/jrdf/test/ClientGraphUnitTest.java 2008-04-11 14:40:58 UTC (rev 774)
+++ trunk/src/jar/client-jrdf/java/org/mulgara/client/jrdf/test/ClientGraphUnitTest.java 2008-04-11 19:40:04 UTC (rev 775)
@@ -182,6 +182,7 @@
*
* @throws Exception
*/
+ @SuppressWarnings("deprecation") // avoiding the use of a connection
public void testCreate() throws Exception {
// log that we're executing the test
@@ -192,7 +193,7 @@
log.debug("Testing Answer implementation");
//get all statments from the graph
- Answer answer = this.getEntireGraph(graphURI);
+ Answer answer = getEntireGraph(graphURI);
//create a Client Graph from it.
ClientGraph client = AbstractGraphFactory.createGraph(answer, answerBean.getSession(serverURI));
@@ -225,7 +226,7 @@
//Answer
log.debug("Testing Answer implementation");
- this.testAnswerFind();
+ testAnswerFind();
log.debug("Testing Answer implementation successful");
} catch (Exception exception) {
exception.printStackTrace();
@@ -238,10 +239,11 @@
*
* @throws Exception
*/
+ @SuppressWarnings("deprecation") // avoiding the use of a connection
public void testAnswerFind() throws Exception {
//create a Client Graph from it.
- Answer answer = this.getEntireGraph(graphURI);
+ Answer answer = getEntireGraph(graphURI);
ClientGraph client = AbstractGraphFactory.createGraph(answer, answerBean.getSession(serverURI));
GraphElementFactory factory = client.getElementFactory();
@@ -252,19 +254,19 @@
ClosableIterator iter = client.find(triple);
//compare with answer
- this.compareAnswerToIterator(answer, iter, factory);
+ compareAnswerToIterator(answer, iter, factory);
//close iterator
iter.close();
//-- FIND SUBJECT (S) --
- this.testAnswerFindSubjects(client, factory);
+ testAnswerFindSubjects(client, factory);
//-- FIND PREDICATE (S) --
- this.testAnswerFindPredicates(client, factory);
+ testAnswerFindPredicates(client, factory);
//-- FIND OBJECT (S) --
- this.testAnswerFindObjects(client, factory);
+ testAnswerFindObjects(client, factory);
//close graph
client.close();
@@ -285,7 +287,7 @@
subject)),
null, null);
ClosableIterator iter = client.find(triple);
- this.compareAnswerToIterator(this.getSubject("<" + subject + ">"), iter,
+ compareAnswerToIterator(getSubject("<" + subject + ">"), iter,
factory);
iter.close();
@@ -294,7 +296,7 @@
triple = factory.createTriple(factory.createResource(URI.create(subject)),
null, null);
iter = client.find(triple);
- this.compareAnswerToIterator(this.getSubject("<" + subject + ">"), iter,
+ compareAnswerToIterator(getSubject("<" + subject + ">"), iter,
factory);
iter.close();
@@ -303,7 +305,7 @@
triple = factory.createTriple(factory.createResource(URI.create(subject)),
null, null);
iter = client.find(triple);
- this.compareAnswerToIterator(this.getSubject("<" + subject + ">"), iter,
+ compareAnswerToIterator(getSubject("<" + subject + ">"), iter,
factory);
iter.close();
}
@@ -324,7 +326,7 @@
predicate)),
null);
ClosableIterator iter = client.find(triple);
- this.compareAnswerToIterator(this.getPredicate("<" + predicate + ">"), iter,
+ compareAnswerToIterator(getPredicate("<" + predicate + ">"), iter,
factory);
iter.close();
@@ -334,7 +336,7 @@
factory.createResource(URI.create(predicate)),
null);
iter = client.find(triple);
- this.compareAnswerToIterator(this.getPredicate("<" + predicate + ">"), iter,
+ compareAnswerToIterator(getPredicate("<" + predicate + ">"), iter,
factory);
iter.close();
@@ -344,7 +346,7 @@
factory.createResource(URI.create(predicate)),
null);
iter = client.find(triple);
- this.compareAnswerToIterator(this.getPredicate("<" + predicate + ">"), iter,
+ compareAnswerToIterator(getPredicate("<" + predicate + ">"), iter,
factory);
iter.close();
}
@@ -364,7 +366,7 @@
factory.createResource(URI.
create(object)));
ClosableIterator iter = client.find(triple);
- this.compareAnswerToIterator(this.getObject("<" + object + ">"), iter,
+ compareAnswerToIterator(getObject("<" + object + ">"), iter,
factory);
iter.close();
@@ -373,7 +375,7 @@
triple = factory.createTriple(null, null,
factory.createResource(URI.create(object)));
iter = client.find(triple);
- this.compareAnswerToIterator(this.getObject("<" + object + ">"), iter,
+ compareAnswerToIterator(getObject("<" + object + ">"), iter,
factory);
iter.close();
@@ -382,7 +384,7 @@
triple = factory.createTriple(null, null,
factory.createResource(URI.create(object)));
iter = client.find(triple);
- this.compareAnswerToIterator(this.getObject("<" + object + ">"), iter,
+ compareAnswerToIterator(getObject("<" + object + ">"), iter,
factory);
iter.close();
@@ -390,7 +392,7 @@
object = "Test1";
triple = factory.createTriple(null, null, factory.createLiteral(object));
iter = client.find(triple);
- this.compareAnswerToIterator(this.getObject("'" + object + "'"), iter,
+ compareAnswerToIterator(getObject("'" + object + "'"), iter,
factory);
iter.close();
@@ -398,7 +400,7 @@
object = "Test2";
triple = factory.createTriple(null, null, factory.createLiteral(object));
iter = client.find(triple);
- this.compareAnswerToIterator(this.getObject("'" + object + "'"), iter,
+ compareAnswerToIterator(getObject("'" + object + "'"), iter,
factory);
iter.close();
@@ -406,7 +408,7 @@
object = "Test3";
triple = factory.createTriple(null, null, factory.createLiteral(object));
iter = client.find(triple);
- this.compareAnswerToIterator(this.getObject("'" + object + "'"), iter,
+ compareAnswerToIterator(getObject("'" + object + "'"), iter,
factory);
iter.close();
}
@@ -469,7 +471,7 @@
//needed for comparision
"order by $s $p $o ;";
- return this.answerBean.executeQuery(query);
+ return answerBean.executeQuery(query);
}
/**
@@ -481,13 +483,13 @@
//select ALL query
String query = "select $s $p $o " +
- "from <" + this.graphURI + "> " +
+ "from <" + graphURI + "> " +
"where " + variable + "<http://mulgara.org/mulgara#is> " + uri + " " +
"and $s $p $o " +
//needed for comparision
"order by $s $p $o ;";
- return this.interpreterBean.executeQuery(query);
+ return interpreterBean.executeQuery(query);
}
/**
@@ -497,7 +499,7 @@
*/
private Answer getSubject(String subject) throws Exception {
- return this.getColumn(subject, "$s");
+ return getColumn(subject, "$s");
}
/**
@@ -507,7 +509,7 @@
*/
private Answer getPredicate(String predicate) throws Exception {
- return this.getColumn(predicate, "$p");
+ return getColumn(predicate, "$p");
}
/**
@@ -517,7 +519,7 @@
*/
private Answer getObject(String object) throws Exception {
- return this.getColumn(object, "$o");
+ return getColumn(object, "$o");
}
/**
@@ -526,31 +528,32 @@
*
* @throws Exception
*/
+ @SuppressWarnings("deprecation") // avoiding the use of a Connection
public void testAnswerOutputRDF() throws Exception {
//create a Client Graph containing all statments
- ClientGraph client1 = AbstractGraphFactory.createGraph(this.getEntireGraph(graphURI), answerBean.getSession(serverURI));
+ ClientGraph client1 = AbstractGraphFactory.createGraph(getEntireGraph(graphURI), answerBean.getSession(serverURI));
File rdfOutput1 = new File(CLIENT_TEST_FILE1);
- this.outputRDF(rdfOutput1, client1);
+ outputRDF(rdfOutput1, client1);
//reload file into new model
- URI graph2 = new URI("" + this.graphURI + "2");
- this.createModel(graph2);
- this.interpreterBean.load(rdfOutput1, graph2);
+ URI graph2 = new URI("" + graphURI + "2");
+ createModel(graph2);
+ interpreterBean.load(rdfOutput1, graph2);
//output new model
- ClientGraph client2 = AbstractGraphFactory.createGraph(this.getEntireGraph(graph2), answerBean.getSession(serverURI));
+ ClientGraph client2 = AbstractGraphFactory.createGraph(getEntireGraph(graph2), answerBean.getSession(serverURI));
File rdfOutput2 = new File(CLIENT_TEST_FILE2);
- this.outputRDF(rdfOutput2, client2);
+ outputRDF(rdfOutput2, client2);
//compare files
assertTrue("RDF output file is not equal to file that was loaded.",
- this.compareFiles(rdfOutput1, rdfOutput2));
+ compareFiles(rdfOutput1, rdfOutput2));
//tidy up
client1.close();
client2.close();
- this.dropModel(graph2);
+ dropModel(graph2);
}
/**
@@ -566,8 +569,8 @@
//value to be returned
boolean compare = false;
- byte[] digest1 = this.digest(file1);
- byte[] digest2 = this.digest(file2);
+ byte[] digest1 = digest(file1);
+ byte[] digest2 = digest(file2);
//compare the bytes
if (digest1.length == digest2.length) {
@@ -608,8 +611,7 @@
do {
read = digestIn.read(buffer);
- }
- while (read != -1);
+ } while (read != -1);
//digest
return digestIn.getMessageDigest().digest();
@@ -644,7 +646,7 @@
//select ALL query
String query = "create <" + modelURI + "> ;";
- return this.interpreterBean.executeQuery(query);
+ return interpreterBean.executeQuery(query);
}
/**
@@ -657,7 +659,7 @@
//select ALL query
String query = "drop <" + modelURI + "> ;";
- return this.interpreterBean.executeQuery(query);
+ return interpreterBean.executeQuery(query);
}
/**
@@ -668,10 +670,9 @@
private Answer populateModel() throws Exception {
//select ALL query
- String query = "insert " + this.testStatements +
- "into <" + this.graphURI + "> ;";
+ String query = "insert " + testStatements + "into <" + graphURI + "> ;";
- return this.interpreterBean.executeQuery(query);
+ return interpreterBean.executeQuery(query);
}
//set up and tear down
@@ -691,27 +692,20 @@
graphURI = new URI("rmi", hostname, "/" + SERVER_NAME, "clientJenaTest");
//create an iTQLInterpreterBean for executing queries with
- this.interpreterBean = new ItqlInterpreterBean();
- this.answerBean = new ItqlInterpreterBean();
+ interpreterBean = new ItqlInterpreterBean();
+ answerBean = new ItqlInterpreterBean();
- //initialize with server
- this.interpreterBean.setServerURI(this.serverURI.toString());
-
//initialize model
- this.createModel(this.graphURI);
- this.populateModel();
- }
- catch (Exception exception) {
-
+ createModel(graphURI);
+ populateModel();
+ } catch (Exception exception) {
//try to tear down first
try {
-
tearDown();
+ } catch (Throwable t) {
+ // going to throw the original
}
- finally {
-
- throw exception;
- }
+ throw exception;
}
}
@@ -722,9 +716,9 @@
*/
public void tearDown() throws Exception {
- this.dropModel(this.graphURI);
+ dropModel(graphURI);
- this.interpreterBean.close();
- this.answerBean.close();
+ interpreterBean.close();
+ answerBean.close();
}
}
Modified: trunk/src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/Mp3Application.java
===================================================================
--- trunk/src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/Mp3Application.java 2008-04-11 14:40:58 UTC (rev 774)
+++ trunk/src/jar/demo-mp3/java/org/mulgara/demo/mp3/swing/Mp3Application.java 2008-04-11 19:40:04 UTC (rev 775)
@@ -33,7 +33,6 @@
import java.util.List;
import java.io.*;
import java.net.*;
-import java.util.*;
// Logging
import org.apache.log4j.*;
@@ -69,13 +68,12 @@
*
* @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
*/
+ at SuppressWarnings("serial")
public class Mp3Application extends JFrame {
- /**
- * Logger. This is named after the class.
- */
- private final static Logger log = Logger.getLogger(Mp3Application.class.
- getName());
+ /** Logger. This is named after the class. */
+ @SuppressWarnings("unused")
+ private final static Logger log = Logger.getLogger(Mp3Application.class.getName());
/** Name of the Application */
private static final String DEFAULT_APPLICATION_NAME = "Mulgara Mp3 Player";
@@ -240,6 +238,7 @@
* Initializes the Models and data
* @throws Exception
*/
+ @SuppressWarnings("unchecked") // cannot add types to generated code
private void init() throws Exception {
//getConfig from the file
config = (config != null) ? config :
@@ -248,16 +247,13 @@
//Create the Models (may not exist yet)
getController().createModels();
//load schemas
- List schemas = config.getSchemaFiles();
+ List<URIReference> schemas = (List<URIReference>)config.getSchemaFiles();
SchemaModel schemaModel = getController().getSchemaModel();
if (schemas == null) {
throw new IllegalStateException("Mp3ConfigFile returned a null " +
"Schema File List.");
}
- Iterator iter = schemas.iterator();
- while (iter.hasNext()) {
- schemaModel.loadSchema((URIReference) iter.next());
- }
+ for (URIReference schema: schemas) schemaModel.loadSchema(schema);
}
/**
@@ -495,6 +491,7 @@
* Run the application.
* @param args String[]
*/
+ @SuppressWarnings("deprecation")
public static void main(String[] args) {
try {
// Just use the basic Log configurator
Modified: trunk/src/jar/util/java/org/mulgara/util/AbstractMulgaraResultSet.java
===================================================================
--- trunk/src/jar/util/java/org/mulgara/util/AbstractMulgaraResultSet.java 2008-04-11 14:40:58 UTC (rev 774)
+++ trunk/src/jar/util/java/org/mulgara/util/AbstractMulgaraResultSet.java 2008-04-11 19:40:04 UTC (rev 775)
@@ -69,6 +69,7 @@
/**
* Logger. This is named after the class.
*/
+ @SuppressWarnings("unused")
private final static Logger logger =
Logger.getLogger(AbstractMulgaraResultSet.class.getName());
@@ -224,11 +225,13 @@
}
/**
- * @param columnIndex PARAMETER TO DO
- * @param scale PARAMETER TO DO
+ * @param columnIndex The column number to retrieve
+ * @param scale The number of digits to the right of the decimal point
* @return The BigDecimal value
* @throws SQLException on failure
+ * @deprecated Deprecated in {@link java.sql.ResultSet}
*/
+ @SuppressWarnings("deprecation")
public BigDecimal getBigDecimal(int columnIndex, int scale)
throws SQLException {
@@ -288,10 +291,12 @@
}
/**
- * @param columnIndex PARAMETER TO DO
+ * @param columnIndex The column number to get data from
* @return The UnicodeStream value
* @throws SQLException on failure
+ * @deprecated Deprecated in the original {@link java.sql.ResultSet}
*/
+ @SuppressWarnings("deprecation")
public java.io.InputStream getUnicodeStream(int columnIndex)
throws SQLException {
@@ -436,11 +441,13 @@
}
/**
- * @param columnName PARAMETER TO DO
- * @param scale PARAMETER TO DO
+ * @param columnName The column containing a number
+ * @param scale Number of digits after the decimal point
* @return The BigDecimal value
* @throws SQLException on failure
+ * @deprecated Deprecated in the original {@link java.sql.ResultSet}
*/
+ @SuppressWarnings("deprecation")
public BigDecimal getBigDecimal(String columnName, int scale)
throws SQLException {
@@ -500,10 +507,12 @@
}
/**
- * @param columnName PARAMETER TO DO
+ * @param columnName The name of the column with the data to retrieve
* @return The UnicodeStream value
* @throws SQLException on failure
+ * @deprecated This has been deprecated in the original {@link ResultSet#getUnicodeStream(String)}
*/
+ @SuppressWarnings("deprecation")
public java.io.InputStream getUnicodeStream(String columnName)
throws SQLException {
@@ -701,6 +710,7 @@
* @return The Object value
* @throws SQLException on failure
*/
+ @SuppressWarnings("unchecked")
public Object getObject(int i, java.util.Map map) throws SQLException {
throw new SQLException(NOT_IMPLEMENTED);
@@ -752,6 +762,7 @@
* @return The Object value
* @throws SQLException on failure
*/
+ @SuppressWarnings("unchecked")
public Object getObject(String colName, java.util.Map map)
throws SQLException {
Modified: trunk/src/jar/util/java/org/mulgara/util/MulgaraResultSet.java
===================================================================
--- trunk/src/jar/util/java/org/mulgara/util/MulgaraResultSet.java 2008-04-11 14:40:58 UTC (rev 774)
+++ trunk/src/jar/util/java/org/mulgara/util/MulgaraResultSet.java 2008-04-11 19:40:04 UTC (rev 775)
@@ -69,7 +69,7 @@
* @return the entire rows underlying the result set.
* @throws SQLException EXCEPTION TO DO
*/
- public List getAllRows() throws SQLException;
+ public List<ResultSetRow> getAllRows() throws SQLException;
/**
* Overwrites the existing set of rows available.
@@ -77,7 +77,7 @@
* @param newRows the new rows to set.
* @throws SQLException EXCEPTION TO DO
*/
- public void setAllRows(List newRows) throws SQLException;
+ public void setAllRows(List<ResultSetRow> newRows) throws SQLException;
/**
* Returns the total size of the number of rows.
Modified: trunk/src/jar/util/java/org/mulgara/util/RowList.java
===================================================================
--- trunk/src/jar/util/java/org/mulgara/util/RowList.java 2008-04-11 14:40:58 UTC (rev 774)
+++ trunk/src/jar/util/java/org/mulgara/util/RowList.java 2008-04-11 19:40:04 UTC (rev 775)
@@ -51,7 +51,7 @@
*
* @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
*/
-public class RowList extends ArrayList {
+public class RowList<T> extends ArrayList<T> {
/**
* Allow newer compiled version of the stub to operate when changes
Modified: trunk/src/jar/util/java/org/mulgara/util/TestResultSet.java
===================================================================
--- trunk/src/jar/util/java/org/mulgara/util/TestResultSet.java 2008-04-11 14:40:58 UTC (rev 774)
+++ trunk/src/jar/util/java/org/mulgara/util/TestResultSet.java 2008-04-11 19:40:04 UTC (rev 775)
@@ -85,7 +85,7 @@
/**
* The rows of the result set.
*/
- private List rows = new RowList();
+ private List<ResultSetRow> rows = new RowList<ResultSetRow>();
/**
* The current row index.
@@ -142,7 +142,6 @@
// Validate "resultSet" parameter
if (resultSet == null) {
-
throw new IllegalArgumentException("Null \"resultSet\" parameter");
}
@@ -151,10 +150,8 @@
// Copy rows
if (resultSet.getClass() == TestResultSet.class) {
-
rows.addAll( ( (TestResultSet) resultSet).rows);
- }
- else {
+ } else {
// Don't assume that it hasn't already been read.
resultSet.beforeFirst();
@@ -165,7 +162,6 @@
ResultSetRow row = new ResultSetRow(resultSet);
for (int i = 0; i < columnNames.length; i++) {
-
row.setObject(columnNames[i], resultSet.getObject(columnNames[i]));
}
@@ -180,8 +176,7 @@
* @param newRows the new rows to set.
* @throws SQLException EXCEPTION TO DO
*/
- public void setAllRows(List newRows) throws SQLException {
-
+ public void setAllRows(List<ResultSetRow> newRows) throws SQLException {
rows = newRows;
}
@@ -195,13 +190,9 @@
* @throws SQLException on failure
*/
public Object getObject(int columnIndex) throws SQLException {
-
// throw an error if the current row is invalid
- if (this.currentRow == null) {
+ if (this.currentRow == null) throw new SQLException("Not on a row.");
- throw new SQLException("Not on a row.");
- }
-
// get the value out of the current row
return this.currentRow.getObject(columnIndex);
}
@@ -218,11 +209,8 @@
public String getString(int columnIndex) throws SQLException {
// throw an error if the current row is invalid
- if (this.currentRow == null) {
+ if (this.currentRow == null) throw new SQLException("Not on a row.");
- throw new SQLException("Not on a row.");
- }
-
// get the value out of the current row
Object object = this.currentRow.getObject(columnIndex);
@@ -238,7 +226,6 @@
* @throws SQLException on failure
*/
public ResultSetMetaData getMetaData() throws SQLException {
-
return metaData;
}
@@ -250,7 +237,6 @@
* @throws SQLException on failure
*/
public boolean isBeforeFirst() throws SQLException {
-
return this.currentRowIndex == 0;
}
@@ -262,7 +248,6 @@
* @throws SQLException on failure
*/
public boolean isAfterLast() throws SQLException {
-
return this.currentRowIndex > this.rows.size();
}
@@ -273,7 +258,6 @@
* @throws SQLException on failure
*/
public boolean isFirst() throws SQLException {
-
return this.currentRowIndex == 1;
}
@@ -284,7 +268,6 @@
* @throws SQLException on failure
*/
public boolean isLast() throws SQLException {
-
return this.currentRowIndex == this.rows.size();
}
@@ -294,8 +277,7 @@
* @return the entire rows underlying the result set.
* @throws SQLException EXCEPTION TO DO
*/
- public List getAllRows() throws SQLException {
-
+ public List<ResultSetRow> getAllRows() throws SQLException {
return rows;
}
@@ -306,7 +288,6 @@
* @throws SQLException on failure
*/
public int getRow() throws SQLException {
-
return this.currentRowIndex;
}
@@ -316,7 +297,6 @@
* @return the total size of the number of rows available.
*/
public int getTotalRowSize() {
-
return rows.size();
}
@@ -326,7 +306,6 @@
* @return The CurrentRow value
*/
public ResultSetRow getCurrentRow() {
-
return currentRow;
}
@@ -342,7 +321,6 @@
* @throws SQLException on failure
*/
public boolean next() throws SQLException {
-
boolean returnState = false;
// advance the cursor if we can
@@ -351,8 +329,7 @@
this.currentRowIndex++;
this.currentRow = (ResultSetRow)this.rows.get(this.currentRowIndex - 1);
returnState = true;
- }
- else {
+ } else {
this.currentRow = null;
returnState = false;
@@ -369,7 +346,6 @@
* @throws SQLException on failure
*/
public void beforeFirst() throws SQLException {
-
// return members to their default state
this.currentRowIndex = 0;
this.currentRow = null;
@@ -381,7 +357,6 @@
* @throws SQLException on failure
*/
public void afterLast() throws SQLException {
-
this.currentRowIndex = this.rows.size() + 1;
this.currentRow = null;
}
@@ -389,7 +364,7 @@
/**
* Moves the cursor to the first row in this ResultSet object.
*
- * @return true if the cursor is on a valid row; false if there are no rows in
+ * @return true if the cursor is on a valid row; false if there are no rows in
* the result set
* @throws SQLException always
*/
@@ -398,7 +373,6 @@
boolean returnState = false;
if (this.rows.size() > 0) {
-
this.beforeFirst();
this.next();
returnState = true;
@@ -418,7 +392,6 @@
boolean returnState = false;
if ( (this.rows != null) && (this.rows.size() > 0)) {
-
this.currentRowIndex = this.rows.size();
this.currentRow = (ResultSetRow)this.rows.get(this.currentRowIndex - 1);
returnState = true;
@@ -433,7 +406,6 @@
* @param row new row to add to the end of the queue.
*/
public void addRow(ResultSetRow row) {
-
rows.add(row);
}
@@ -445,7 +417,7 @@
*
* @param row the number of the row to which the cursor should move. A
* positive number indicates the row number counting from the beginning
- * of the result set; a negative number indicates the row number counting
+ * of the result set; a negative number indicates the row number counting
* from the end of the result set
* @return RETURNED VALUE TO DO
* @throws SQLException on failure
@@ -458,34 +430,21 @@
if (row >= 0) {
if (row == 0) {
-
beforeFirst();
- }
- else if (row <= this.rows.size()) {
-
+ } else if (row <= this.rows.size()) {
this.currentRowIndex = row;
- this.currentRow =
- (ResultSetRow)this.rows.get(this.currentRowIndex - 1);
+ this.currentRow = this.rows.get(this.currentRowIndex - 1);
returnState = true;
- }
- else {
-
+ } else {
afterLast();
}
- }
-
- // Work back from the end
- else {
-
+ } else {
+ // Work back from the end
if ( (this.rows.size() + row) >= 0) {
-
this.currentRowIndex = (this.rows.size() + 1) + row;
- this.currentRow =
- (ResultSetRow)this.rows.get(this.currentRowIndex - 1);
+ this.currentRow = this.rows.get(this.currentRowIndex - 1);
returnState = true;
- }
- else {
-
+ } else {
beforeFirst();
}
}
@@ -518,26 +477,19 @@
this.currentRow =
(ResultSetRow)this.rows.get(this.currentRowIndex - 1);
returnState = true;
- }
- else {
-
+ } else {
afterLast();
}
- }
+ } else {
+ // Work back from the end
- // Work back from the end
- else {
-
if ( (this.currentRowIndex + numRows) > 0) {
// Add 1 to size to go to end of list then add the negative row number
this.currentRowIndex += numRows;
- this.currentRow =
- (ResultSetRow)this.rows.get(this.currentRowIndex - 1);
+ this.currentRow = this.rows.get(this.currentRowIndex - 1);
returnState = true;
- }
- else {
-
+ } else {
beforeFirst();
}
}
@@ -550,391 +502,6 @@
//
/**
- * Perform a <dfn>natural join</dfn> between this result set and another. The
- * join will be performed based on matching column names. See Elmasri &
- * Navathe, <cite>Fundamentals of Database Systems</cite> , p. 158.
- *
- * @param resultSet the other result set to join with
- * @return the result of the join operation
- * @throws SQLException if the join fails
- */
- /*
- public MulgaraResultSet join(MulgaraResultSet resultSet) throws SQLException {
-
- // Determine the join variables
- List columnNamesList = new ArrayList(Arrays.asList(columnNames));
-
- String[] mdataColumnNames = resultSet.getColumnNames();
-
- columnNamesList.remove("score");
-
- // FIXME: hack for Lucene queries
- columnNamesList.retainAll(Arrays.asList(mdataColumnNames));
-
- // Delegate execution to the fully parameterized join method
- String[] columnNamesArray =
- (String[]) columnNamesList.toArray(new String[columnNamesList.size()]);
-
- return join(resultSet, columnNamesArray, columnNamesArray);
- }
- */
-
- /**
- * Perform a natural join between this result set and another, specifying the
- * column names upon which to join.
- *
- * @param resultSet the other result set to join with
- * @param columnNames the list of column names in <code>this</code> on which
- * to join; all the named columns must occur in <code>this</code>, and
- * the length of the array must match <var>resultSetColumnNames</var>
- * @param resultSetColumnNames the list of column names in <var>resultSet
- * </var> on which to join; all the named columns must occur in <var>
- * resultSet</var> , and the length of the array must match <var>
- * columnNames</var>
- * @return the result of the join operation
- * @throws IllegalArgumentException if the <var>columnName</var> and <var>
- * resultSetColumnNames</var> arguments are incompatible, or if any of
- * the arguments are <code>null</code>
- * @throws SQLException if the join fails
- */
- /*
- public MulgaraResultSet join(MulgaraResultSet resultSet, String[] columnNames,
- String[] resultSetColumnNames) throws SQLException {
-
- // Validate parameters
- if (columnNames.length != resultSetColumnNames.length) {
-
- throw new IllegalArgumentException(
- "columnNames different length than resultSetColumnNames");
- }
-
- MulgaraResultSet testResultSet = new TestResultSet(resultSet);
-
- // Calculate unjoined columns of this and resultSet
- List unjoinedColumnNamesList =
- new ArrayList(Arrays.asList(this.columnNames));
- unjoinedColumnNamesList.removeAll(Arrays.asList(columnNames));
-
- String[] mdColumnNames = testResultSet.getColumnNames();
- List unjoinedResultSetColumnNamesList =
- new ArrayList(Arrays.asList(mdColumnNames));
- unjoinedResultSetColumnNamesList.removeAll(Arrays.asList(columnNames));
-
- List resultColumnNamesList = new ArrayList(Arrays.asList(columnNames));
- resultColumnNamesList.addAll(unjoinedColumnNamesList);
- resultColumnNamesList.addAll(unjoinedResultSetColumnNamesList);
-
- String[] resultColumnNames =
- (String[]) resultColumnNamesList.toArray(new String[
- resultColumnNamesList.size()]);
-
- TestResultSet result = new TestResultSet(resultColumnNames);
-
- // Pre-calculate column numbers for the columnNames array
- int[] columnIndices = new int[columnNames.length];
-
- for (int i = 0; i < columnNames.length; i++) {
-
- columnIndices[i] = columnForName(columnNames[i]);
- }
-
- int[] resultSetColumnIndices = new int[columnNames.length];
-
- for (int i = 0; i < columnNames.length; i++) {
-
- resultSetColumnIndices[i] =
- ( (TestResultSet) resultSet).columnForName(columnNames[i]);
- }
-
- // Short-circuit execution if the join is going to be empty
- if ( (getTotalRowSize() == 0) || (testResultSet.getTotalRowSize() == 0)) {
-
- return result;
- }
-
- if ( (columnNames.length == 0) &&
- logger.isEnabledFor(org.apache.log4j.Priority.WARN) &&
- (getTotalRowSize() > 1) &&
- (testResultSet.getTotalRowSize() > 1)) {
-
- logger.warn("Performing cartesian product (" + rows.size() + "x" +
- testResultSet.getTotalRowSize() + ")");
- }
-
- // Iterate through the joined columns
- while (next()) {
-
- ResultSetRow lhsRow = (ResultSetRow) getCurrentRow();
-
- rhs:
- for (testResultSet.beforeFirst(); testResultSet.next(); ) {
-
- ResultSetRow rhsRow = (ResultSetRow) testResultSet.getCurrentRow();
-
- // Don't create the new row unless the equijoin test succeeds
- for (int i = 0; i < columnNames.length; i++) {
-
- Object lhsObject = lhsRow.getObject(columnIndices[i]);
- Object rhsObject = rhsRow.getObject(resultSetColumnNames[i]);
-
- // Nulls are always equal; other values must be tested
- if ( (lhsObject != null) &&
- (rhsObject != null) &&
- !lhsObject.equals(rhsObject)) {
-
- continue rhs;
- }
- }
-
- // equijoin succeeded
- // Creating a new row
- ResultSetRow resultRow = new ResultSetRow(result);
-
- // Set all the join columns
- for (int i = 0; i < columnNames.length; i++) {
-
- Object lhsValue = lhsRow.getObject(columnIndices[i]);
- Object rhsValue = rhsRow.getObject(resultSetColumnIndices[i]);
- resultRow.setObject(columnNames[i],
- (lhsValue == null) ? rhsValue : lhsValue);
- }
-
- // Set all unjoined LHS columns
- for (Iterator i = unjoinedColumnNamesList.iterator(); i.hasNext(); ) {
-
- String ucn = (String) i.next();
- resultRow.setObject(ucn, lhsRow.getObject(ucn));
- }
-
- // Set all unjoined RHS columns
- for (Iterator i = unjoinedResultSetColumnNamesList.iterator();
- i.hasNext(); ) {
-
- String ucn = (String) i.next();
- resultRow.setObject(ucn, rhsRow.getObject(ucn));
- }
-
- result.addRow(resultRow);
- }
- }
-
- // Not sure what to do here yet
- return result;
- }
- */
-
- /**
- * Perform a relational algebra <dfn>self join</dfn> operation. This operation
- * filters duplicate rows out of result sets. In this implementation, order is
- * not preserved.
- *
- */
- /*
- public void removeDuplicateRows() {
-
- // Sort the result sets
- List sortedRows = new RowList(rows.size());
- sortedRows.addAll(rows);
- Collections.sort(sortedRows, this.new ColumnComparator(columnNames));
-
- // Remove duplicates
- ResultSetRow previousRow = null;
- row:
- for (Iterator i = sortedRows.iterator(); i.hasNext(); ) {
-
- ResultSetRow row = (ResultSetRow) i.next();
-
- if (previousRow == null) {
-
- previousRow = row;
- }
- else {
-
- for (int j = 0; j < columnNames.length; j++) {
-
- Object previousField = previousRow.getObject(columnNames[j]);
- Object field = row.getObject(columnNames[j]);
-
- if ( (previousField != null) && !previousField.equals(field)) {
-
- previousRow = row;
-
- continue row;
- }
- }
-
- // The current element is a duplicate of the previous one; remove it
- i.remove();
- }
- }
-
- // New rows are the ones without duplicates
- rows = sortedRows;
- }
- */
-
- /**
- * Perform a relational algebra <dfn>project</dfn> operation. This operation
- * filters columns out of result sets. The columns to be retained are
- * specified by name.
- *
- * @param columnNames the column names to retain, which may or may not exist
- * in this result set
- * @return a result set containing only columns named in <code>columnNames</code>
- * @throws SQLException if the projection fails
- */
- /*
- public MulgaraResultSet project2(String[] columnNames) throws SQLException {
-
- // Intersect the projection variables
- List columnNamesList = new ArrayList(Arrays.asList(columnNames));
- columnNamesList.retainAll(Arrays.asList(this.columnNames));
-
- String[] projectedColumnNames = new String[columnNamesList.size()];
- projectedColumnNames =
- (String[]) columnNamesList.toArray(projectedColumnNames);
-
- TestResultSet result = new TestResultSet(projectedColumnNames);
-
- // Start at the start
- beforeFirst();
-
- while (next()) {
-
- ResultSetRow row = getCurrentRow();
-
- // Create the new row
- ResultSetRow resultRow = new ResultSetRow(result);
-
- // Populate each column of the new row
- for (int j = 0; j < projectedColumnNames.length; j++) {
-
- resultRow.setObject(projectedColumnNames[j],
- row.getObject(projectedColumnNames[j]));
- }
-
- // Add the new row to the result
- result.addRow(resultRow);
- }
-
- return result;
- }
- */
-
- /**
- * Perform a relational algebra <dfn>project</dfn> operation. This operation
- * filters columns out of result sets. The columns to be retained are
- * specified by name.
- *
- * @param columnNames the column names to retain, all of which must exist in
- * this result set
- * @return a result set containing only columns named in <code>columnNames</code>
- * @throws SQLException if the projection fails
- */
- /*
- public MulgaraResultSet project(String[] columnNames) throws SQLException {
-
- TestResultSet result = new TestResultSet(columnNames);
-
- // Start at the start
- beforeFirst();
-
- while (next()) {
-
- ResultSetRow row = (ResultSetRow) getCurrentRow();
-
- // Create the new row
- ResultSetRow resultRow = new ResultSetRow(result);
-
- // Populate each column of the new row
- for (int j = 0; j < columnNames.length; j++) {
-
- resultRow.setObject(columnNames[j], row.getObject(columnNames[j]));
- }
-
- // Add the new row to the result
- result.addRow(resultRow);
- }
-
- return result;
- }
- */
-
- /**
- * Sort according to a passed comparator.
- *
- * @param comparator a comparator for {@link ResultSetRow}s
- */
- /*
- public void sort(Comparator comparator) {
-
- if (comparator == null) {
-
- throw new IllegalArgumentException("Null \"comparator\" parameter");
- }
-
- Collections.sort(rows, comparator);
- }
- */
-
- //
- // Utility methods to make testing possible
- //
-
- /**
- * Append all rows from another result set to this one. All the column names
- * in this result set must be present in the other. This implementation
- * doesn't require that the types of the columns match.
- *
- * @param resultSet the result set to append
- * @throws SQLException if <var>resultSet</var> can't be read
- */
-
- // FIXME: I modify my argument by moving its cursor all over the place,
- // and I assume that the cursor starts at the beginning
- /*
- public void append(ResultSet resultSet) throws SQLException {
-
- // Short-circuit test
- if (resultSet == null) {
-
- return;
- }
-
- ;
-
- // Quick hack to avoid infinite looping or cursor side effects
- resultSet = new TestResultSet(resultSet);
-
- // Add all rows in resultSet to this
- resultSet.beforeFirst();
-
- while (resultSet.next()) {
-
- // Create the new row
- ResultSetRow row = new ResultSetRow(this);
- this.addRow(row);
-
- // Populate each column of the new row
- for (int i = 0; i < columnNames.length; i++) {
-
- // Hack to skip columns missing from resultSet
- try {
-
- resultSet.findColumn(columnNames[i]);
- }
- catch (SQLException e) {
-
- continue;
- }
-
- row.setObject(columnNames[i], resultSet.getObject(columnNames[i]));
- }
- }
- }
- */
-
- /**
* Result sets are equal if their rows are equal. Both row and column ordering
* is signicant.
*
@@ -943,11 +510,8 @@
*/
public boolean equals(Object object) {
- if (! (object instanceof ResultSet)) {
+ if (! (object instanceof ResultSet)) return false;
- return false;
- }
-
try {
// Convert the other result set into a comparable form
@@ -957,54 +521,12 @@
// Compare the rows
return rows.equals(testResultSet.rows);
- }
- catch (SQLException e) {
-
+ } catch (SQLException e) {
return false;
}
}
/**
- * Test this result set for equality with another, ignoring any differences
- * between row ordering. Column ordering is still significant.
- *
- * @param object the result set to check to see if it is equal.
- * @return true if the result set is equal ignoring row order.
- */
- /*
- public boolean equalsIgnoreOrder(Object object) {
-
- if (! (object instanceof ResultSet)) {
-
- return false;
- }
-
- try {
-
- // Convert the other result set into a comparable form
- TestResultSet testResultSet =
- (object instanceof TestResultSet) ? (TestResultSet) object
- : new TestResultSet( (ResultSet) object);
-
- // Sort the result sets and compare the sorted rows
- List sortedRows = new ArrayList(rows.size());
- sortedRows.addAll(rows);
- Collections.sort(sortedRows);
-
- List sortedTestResultSetRows = new ArrayList(testResultSet.rows.size());
- sortedTestResultSetRows.addAll(testResultSet.rows);
- Collections.sort(sortedTestResultSetRows);
-
- return sortedRows.equals(sortedTestResultSetRows);
- }
- catch (SQLException e) {
-
- return false;
- }
- }
- */
-
- /**
* Produce a string version of the result set. Displaying the available
* columns and rows.
*
@@ -1014,28 +536,22 @@
try {
- StringBuffer buffer =
- new StringBuffer(getColumnNames().length + " columns:");
+ StringBuffer buffer = new StringBuffer(getColumnNames().length + " columns:");
// Save the current state of the result set.
int tmpCurrentRow = getRow();
// Get the names of the columns
for (int i = 0; i < columnNames.length; i++) {
-
buffer.append(" ").append(columnNames[i]);
}
buffer.append(" (").append(rows.size()).append(" rows)");
- // Save the current state
- int currentRowIndex = getRow();
-
// Start at the start
beforeFirst();
while (next()) {
-
buffer.append("\n").append(getCurrentRow());
}
@@ -1043,81 +559,24 @@
absolute(tmpCurrentRow);
return buffer.toString();
- }
- catch (SQLException se) {
-
+ } catch (SQLException se) {
logger.error("Failed to convert object to string", se);
-
return "";
}
}
/**
- * Truncate trailing rows.
- *
- * @param limit the maximum number of rows to retain
- */
- /*
- public void limit(int limit) {
-
- if (rows.size() > limit) {
-
- logger.warn("Removing " + limit + "-" + rows.size());
- ( (RowList) rows).removeRange(limit, rows.size());
-
- // probably should validate currentRowIndex
- }
- }
- */
-
- /**
- * Truncate leading rows.
- *
- * @param offset the number of leading rows to truncate
- */
- /*
- public void offset(int offset) {
-
- if (offset == 0) {
-
- // do nothing
- }
- else if (offset < rows.size()) {
-
- logger.warn("Removing 0-" + offset);
- ( (RowList) rows).removeRange(0, offset);
- currentRowIndex -= offset;
-
- if (currentRowIndex < 0) {
-
- currentRowIndex = 0;
- }
- }
- else if (offset >= rows.size()) {
-
- rows.clear();
- }
- else {
-
- throw new IllegalArgumentException("Illegal offset: " + offset);
- }
- }
- */
-
- /**
* Initialises the column names and metadata from the given metadata object.
*
* @param newMetaData PARAMETER TO DO
* @throws SQLException if there was an error getting the metadata attributes.
*/
- private void initialiseMetaData(ResultSetMetaData newMetaData) throws
- SQLException {
+ private void initialiseMetaData(ResultSetMetaData newMetaData) throws SQLException {
int columnNameCount = newMetaData.getColumnCount();
columnNames = new String[columnNameCount];
for (int i = 0; i < columnNameCount; i++) {
-
columnNames[i] = newMetaData.getColumnName(i + 1);
}
@@ -1126,190 +585,139 @@
}
public int getHoldability() throws SQLException {
- // TODO Auto-generated method stub
- return 0;
+ throw new SQLException(NOT_IMPLEMENTED);
}
public Reader getNCharacterStream(int columnIndex) throws SQLException {
- // TODO Auto-generated method stub
- return null;
+ throw new SQLException(NOT_IMPLEMENTED);
}
public Reader getNCharacterStream(String columnLabel) throws SQLException {
- // TODO Auto-generated method stub
- return null;
+ throw new SQLException(NOT_IMPLEMENTED);
}
public NClob getNClob(int columnIndex) throws SQLException {
- // TODO Auto-generated method stub
- return null;
+ throw new SQLException(NOT_IMPLEMENTED);
}
public NClob getNClob(String columnLabel) throws SQLException {
- // TODO Auto-generated method stub
- return null;
+ throw new SQLException(NOT_IMPLEMENTED);
}
public String getNString(int columnIndex) throws SQLException {
- // TODO Auto-generated method stub
- return null;
+ throw new SQLException(NOT_IMPLEMENTED);
}
public String getNString(String columnLabel) throws SQLException {
- // TODO Auto-generated method stub
- return null;
+ throw new SQLException(NOT_IMPLEMENTED);
}
public RowId getRowId(int columnIndex) throws SQLException {
- // TODO Auto-generated method stub
- return null;
+ throw new SQLException(NOT_IMPLEMENTED);
}
public RowId getRowId(String columnLabel) throws SQLException {
- // TODO Auto-generated method stub
- return null;
+ throw new SQLException(NOT_IMPLEMENTED);
}
public SQLXML getSQLXML(int columnIndex) throws SQLException {
- // TODO Auto-generated method stub
- return null;
+ throw new SQLException(NOT_IMPLEMENTED);
}
public SQLXML getSQLXML(String columnLabel) throws SQLException {
- // TODO Auto-generated method stub
- return null;
+ throw new SQLException(NOT_IMPLEMENTED);
}
public boolean isClosed() throws SQLException {
- // TODO Auto-generated method stub
- return false;
+ throw new SQLException(NOT_IMPLEMENTED);
}
- public void updateAsciiStream(int columnIndex, InputStream x, long length)
- throws SQLException {
- // TODO Auto-generated method stub
-
+ public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException {
+ throw new SQLException(NOT_IMPLEMENTED);
}
- public void updateAsciiStream(String columnLabel, InputStream x, long length)
- throws SQLException {
- // TODO Auto-generated method stub
-
+ public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException {
+ throw new SQLException(NOT_IMPLEMENTED);
}
- public void updateBinaryStream(int columnIndex, InputStream x, long length)
- throws SQLException {
- // TODO Auto-generated method stub
-
+ public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException {
+ throw new SQLException(NOT_IMPLEMENTED);
}
- public void updateBinaryStream(String columnLabel, InputStream x, long length)
- throws SQLException {
- // TODO Auto-generated method stub
-
+ public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException {
+ throw new SQLException(NOT_IMPLEMENTED);
}
- public void updateBlob(int columnIndex, InputStream inputStream, long length)
- throws SQLException {
- // TODO Auto-generated method stub
-
+ public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException {
+ throw new SQLException(NOT_IMPLEMENTED);
}
- public void updateBlob(String columnLabel, InputStream inputStream,
- long length) throws SQLException {
- // TODO Auto-generated method stub
-
+ public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException {
+ throw new SQLException(NOT_IMPLEMENTED);
}
- public void updateCharacterStream(int columnIndex, Reader x, long length)
- throws SQLException {
- // TODO Auto-generated method stub
-
+ public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
+ throw new SQLException(NOT_IMPLEMENTED);
}
- public void updateCharacterStream(String columnLabel, Reader reader,
- long length) throws SQLException {
- // TODO Auto-generated method stub
-
+ public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
+ throw new SQLException(NOT_IMPLEMENTED);
}
- public void updateClob(int columnIndex, Reader reader, long length)
- throws SQLException {
- // TODO Auto-generated method stub
-
+ public void updateClob(int columnIndex, Reader reader, long length) throws SQLException {
+ throw new SQLException(NOT_IMPLEMENTED);
}
- public void updateClob(String columnLabel, Reader reader, long length)
- throws SQLException {
- // TODO Auto-generated method stub
-
+ public void updateClob(String columnLabel, Reader reader, long length) throws SQLException {
+ throw new SQLException(NOT_IMPLEMENTED);
}
- public void updateNCharacterStream(int columnIndex, Reader x, long length)
- throws SQLException {
- // TODO Auto-generated method stub
-
+ public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
+ throw new SQLException(NOT_IMPLEMENTED);
}
- public void updateNCharacterStream(String columnLabel, Reader reader,
- long length) throws SQLException {
- // TODO Auto-generated method stub
-
+ public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
+ throw new SQLException(NOT_IMPLEMENTED);
}
public void updateNClob(int columnIndex, NClob clob) throws SQLException {
- // TODO Auto-generated method stub
-
+ throw new SQLException(NOT_IMPLEMENTED);
}
public void updateNClob(String columnLabel, NClob clob) throws SQLException {
- // TODO Auto-generated method stub
-
+ throw new SQLException(NOT_IMPLEMENTED);
}
- public void updateNClob(int columnIndex, Reader reader, long length)
- throws SQLException {
- // TODO Auto-generated method stub
-
+ public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException {
+ throw new SQLException(NOT_IMPLEMENTED);
}
- public void updateNClob(String columnLabel, Reader reader, long length)
- throws SQLException {
- // TODO Auto-generated method stub
-
+ public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException {
+ throw new SQLException(NOT_IMPLEMENTED);
}
public void updateNString(int columnIndex, String string) throws SQLException {
- // TODO Auto-generated method stub
-
+ throw new SQLException(NOT_IMPLEMENTED);
}
- public void updateNString(String columnLabel, String string)
- throws SQLException {
- // TODO Auto-generated method stub
-
+ public void updateNString(String columnLabel, String string) throws SQLException {
+ throw new SQLException(NOT_IMPLEMENTED);
}
public void updateRowId(int columnIndex, RowId x) throws SQLException {
- // TODO Auto-generated method stub
-
+ throw new SQLException(NOT_IMPLEMENTED);
}
public void updateRowId(String columnLabel, RowId x) throws SQLException {
- // TODO Auto-generated method stub
-
+ throw new SQLException(NOT_IMPLEMENTED);
}
- public void updateSQLXML(int columnIndex, SQLXML xmlObject)
- throws SQLException {
- // TODO Auto-generated method stub
-
+ public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException {
+ throw new SQLException(NOT_IMPLEMENTED);
}
- public void updateSQLXML(String columnLabel, SQLXML xmlObject)
- throws SQLException {
- // TODO Auto-generated method stub
-
+ public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException {
+ throw new SQLException(NOT_IMPLEMENTED);
}
public void updateNCharacterStream(int columnIndex, Reader reader) throws SQLException {
@@ -1369,123 +777,11 @@
}
public boolean isWrapperFor(Class<?> iface) throws SQLException {
- // TODO Auto-generated method stub
- return false;
+ throw new SQLException(NOT_IMPLEMENTED);
}
public <T> T unwrap(Class<T> iface) throws SQLException {
- // TODO Auto-generated method stub
- return null;
+ throw new SQLException(NOT_IMPLEMENTED);
}
- /**
- * Comparator class used by the
- * {@link #join(MulgaraResultSet, String[], String[])} method.
- */
- //class ColumnComparator implements Comparator {
-
- /**
- * The columns to sort by, 0-indexed.
- *
- */
- //private String[] columnNames;
-
- /**
- * @param columnNames the names of the columns to use as a sort order
- */
- /*
- public ColumnComparator(String[] columnNames) {
-
- // Validate columnNames2
- if (columnNames == null) {
-
- throw new IllegalArgumentException("Null columnNames parameter");
- }
-
- // Initialize fields
- this.columnNames = columnNames;
- }
-
- public int compare(Object a, Object b) {
-
- // Validate parameters
- if (! (a instanceof ResultSetRow && b instanceof ResultSetRow)) {
-
- throw new RuntimeException("Can't compare " + a.getClass() + " to " +
- b.getClass());
- }
-
- // Delegate execution to private, type-specific method
- return compare( (ResultSetRow) a, (ResultSetRow) b);
- }
- */
-
- /**
- * Ordering on {@link ResultSetRow}s. The ordering is by the {@link
- * Object#toString} value of the fields, earlier columns having higher
- * precedence and <code>null</code> ordering before all other field values.
- *
- * @param a PARAMETER TO DO
- * @param b PARAMETER TO DO
- * @return RETURNED VALUE TO DO
- * @deprecated Ordering by {@link Object#toString} value is a terrible idea.
- */
- /*
- private int compare(ResultSetRow a, ResultSetRow b) {
-
- // Compare each column in turn, returning an ordering if they're unequal
- for (int i = 0; i < columnNames.length; i++) {
-
- Object a2 = a.getObject(columnNames[i]);
- Object b2 = b.getObject(columnNames[i]);
-
- // Handle null comparisons
- if ( (a2 == null) && (b2 == null)) {
-
- continue;
- }
-
- // A = B
- if (a2 == null) {
-
- return -1;
- }
-
- // A < B
- if (b2 == null) {
-
- return +1;
- }
-
- // A > B
- // Handle non-null comparisons
- int difference;
-
- if (a2 instanceof Comparable) {
-
- difference = ( (Comparable) a2).compareTo(b2);
- }
- else {
-
- if (logger.isDebugEnabled()) {
-
- logger.debug("Falling back to lexical comparison for " +
- a2.getClass());
- }
-
- difference = a2.toString().compareTo(b2.toString());
- }
-
- // Return if an order has been established
- if (difference != 0) {
-
- return difference;
- }
- }
-
- // The rows must be equal (insofar as the named columns go)
- return 0;
- }
- */
- //}
}
Modified: trunk/src/jar/util/java/org/mulgara/util/TestResultSetTest.java
===================================================================
--- trunk/src/jar/util/java/org/mulgara/util/TestResultSetTest.java 2008-04-11 14:40:58 UTC (rev 774)
+++ trunk/src/jar/util/java/org/mulgara/util/TestResultSetTest.java 2008-04-11 19:40:04 UTC (rev 775)
@@ -32,7 +32,7 @@
// Java 2 standard packages
import java.sql.SQLException;
-import java.util.*;
+// import java.util.*;
// JUnit
import org.apache.log4j.Logger;
@@ -54,17 +54,12 @@
*/
public class TestResultSetTest extends TestCase {
- /**
- * Logger. Named after the class.
- *
- */
+ /** Logger. Named after the class. */
+ @SuppressWarnings("unused")
private static final Logger logger = Logger.getLogger(TestResultSetTest.class);
- /**
- * Test object.
- *
- */
- private TestResultSet testResultSet;
+ /** Test object. */
+// private TestResultSet testResultSet;
/**
* CONSTRUCTOR TestResultSetTest TO DO
Modified: trunk/src/jar/util/java/org/mulgara/util/UIDGeneratorUnitTest.java
===================================================================
--- trunk/src/jar/util/java/org/mulgara/util/UIDGeneratorUnitTest.java 2008-04-11 14:40:58 UTC (rev 774)
+++ trunk/src/jar/util/java/org/mulgara/util/UIDGeneratorUnitTest.java 2008-04-11 19:40:04 UTC (rev 775)
@@ -59,7 +59,7 @@
public class UIDGeneratorUnitTest extends TestCase {
/** Set of UIDs that have been generated */
- private Set uids = null;
+ private Set<String> uids = null;
/** Number of UIDs generated */
private static final int NUM_UIDS = 10000;
@@ -143,7 +143,7 @@
public void testConcurrency() throws Exception {
//threads that have to complete before the test finished
- List threadList = new ArrayList();
+ List<Thread> threadList = new ArrayList<Thread>();
Thread currentThread = null;
//start threads that generate UIDs
@@ -167,8 +167,7 @@
uids.add(currentUID);
}
}
- }
- catch (Exception exception) {
+ } catch (Exception exception) {
throw new RuntimeException(
"Error occurred while testing concurrency.",
exception);
@@ -187,7 +186,7 @@
//must wait for all threads to finish
for (int i = 0; i < NUM_THREADS; i++) {
- ((Thread) threadList.get(i)).join();
+ threadList.get(i).join();
}
}
@@ -201,7 +200,7 @@
//load UIDGenerator from multiple classes
URLClassLoader currentLoader = null;
- Class currentUIDGeneratorClass = null;
+ Class<?> currentUIDGeneratorClass = null;
//get an URL to the UIDGenerator class file
URL[] uidClass = new URL[] {
@@ -222,12 +221,12 @@
* @param uidGenerator
* @throws Exception
*/
- private void testUIDGeneratorClass(Class uidGenerator) throws Exception {
+ private void testUIDGeneratorClass(Class<?> uidGenerator) throws Exception {
//get the UIDGenerator's generateUID method
- Method generateUID = uidGenerator.getMethod("generateUID", null);
+ Method generateUID = uidGenerator.getMethod("generateUID", (Class[])null);
String currentUID = "";
for (int i = 0; i < NUM_UIDS; i++) {
- currentUID = (String) generateUID.invoke(null, null);
+ currentUID = (String) generateUID.invoke(null, (Object[])null);
//is it unique??
if (uids.contains(currentUID)) {
fail("UID set already contains UID [" + i + "]: " + currentUID);
@@ -248,11 +247,10 @@
try {
- uids = new HashSet();
+ uids = new HashSet<String>();
super.setUp();
- }
- catch (Exception exception) {
+ } catch (Exception exception) {
//try to tear down first
tearDown();
More information about the Mulgara-svn
mailing list