/*
 * ResultSet.java
 *
 * Created on August 1, 2007, 6:02 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package usda.weru.soil.arssql;

import java.io.InputStream;
import java.io.Reader;
import java.sql.*;

import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Map;
import java.net.URL;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;



/**
 * This is a stripped implementation of the ResultSet interface. It is
 * intended to be used the ARS soap web service to obtain soil data.
 * Only calls that are actually used by WEPS are implemented.

 * @author wjr
 */
public class ResultSetARS implements java.sql.ResultSet {
    
    /** Creates a new instance of ResultSet */
    public ResultSetARS() {
    }

//	public ResultSetARS(Document doc) {
//		this.doc = doc;
////        System.out.println("RSA: " + doc);
//	}

    SAXParse saxDoc;
    
    public ResultSetARS(SAXParse saxDoc) {
        this.saxDoc = saxDoc;
        maxRowNum = saxDoc.getLength();
    }
    
	int rowNum = -1;
	int maxRowNum = Integer.MAX_VALUE; // arbitrary large number
	
//          Moves the cursor to the given row number in this ResultSet object.
    public boolean 	absolute(int row) {return false;}

//          Moves the cursor to the end of this ResultSet object, just after the last row.
    public void 	afterLast() {}

//          Moves the cursor to the front of this ResultSet object, just before the first row.
    public void 	beforeFirst() {}

//          Cancels the updates made to the current row in this ResultSet object.
    public void 	cancelRowUpdates() {}

//          Clears all warnings reported on this ResultSet object.
    public void 	clearWarnings() {}

//          Releases this ResultSet object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed.
    public void 	close() {}

//          Deletes the current row from this ResultSet object and from the underlying database.
    public void 	deleteRow() {}

//          Maps the given ResultSet column name to its ResultSet column index.
    public int 	findColumn(String columnName) {return -1;}

//          Moves the cursor to the first row in this ResultSet object.
    public boolean 	first() {return false;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as an Array object in the Java programming language.
    public Array 	getArray(int i) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as an Array object in the Java programming language.
    public Array 	getArray(String colName) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a stream of ASCII characters.
    public InputStream 	getAsciiStream(int columnIndex) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a stream of ASCII characters.
    public InputStream 	getAsciiStream(String columnName) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a java.math.BigDecimal with full precision.
    public BigDecimal 	getBigDecimal(int columnIndex) {return null;}

//          Deprecated.
    public BigDecimal 	getBigDecimal(int columnIndex, int scale) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a java.math.BigDecimal with full precision.
    public BigDecimal 	getBigDecimal(String columnName) {return null;}

//          Deprecated.
    public BigDecimal 	getBigDecimal(String columnName, int scale) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a binary stream of uninterpreted bytes.
    public InputStream 	getBinaryStream(int columnIndex) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a stream of uninterpreted bytes.
    public InputStream 	getBinaryStream(String columnName) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a Blob object in the Java programming language.
    public Blob 	getBlob(int i) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a Blob object in the Java programming language.
    public Blob 	getBlob(String colName) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a boolean in the Java programming language.
    public boolean 	getBoolean(int columnIndex) {return false;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a boolean in the Java programming language.
    public boolean 	getBoolean(String columnName) {return false;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a byte in the Java programming language.
    public byte 	getByte(int columnIndex) {return 0;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a byte in the Java programming language.
    public byte 	getByte(String columnName) {return -1;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a byte array in the Java programming language.
    public byte[] 	getBytes(int columnIndex) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a byte array in the Java programming language.
    public byte[] 	getBytes(String columnName) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a java.io.Reader object.
    public Reader 	getCharacterStream(int columnIndex) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a java.io.Reader object.
    public Reader 	getCharacterStream(String columnName) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a Clob object in the Java programming language.
    public Clob 	getClob(int i) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a Clob object in the Java programming language.
    public Clob 	getClob(String colName) {return null;}

//          Retrieves the concurrency mode of this ResultSet object.
    public int 	getConcurrency() {return -1;}

//          Retrieves the name of the SQL cursor used by this ResultSet object.
    public String 	getCursorName() {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Date object in the Java programming language.
    public Date 	getDate(int columnIndex) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Date object in the Java programming language.
    public Date 	getDate(int columnIndex, Calendar cal) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Date object in the Java programming language.
    public Date 	getDate(String columnName) {
        String value = getString(columnName);
        if(value != null){
            DateFormat format = new SimpleDateFormat("M/d/yyyy h:m:s a");
            try{
                java.util.Date date = format.parse(value);
                return new Date(date.getTime());
            }
            catch(ParseException pe){
                return null;
            }
        }
        else{
            return null;
        }

    }

//          Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Date object in the Java programming language.
    public Date 	getDate(String columnName, Calendar cal) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a double in the Java programming language.
    public double 	getDouble(int columnIndex) {return -1.0;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a double in the Java programming language.
    public double 	getDouble(String columnName) {return -1.0;}

//          Retrieves the fetch direction for this ResultSet object.
    public int 	getFetchDirection() {return -1;}

//          Retrieves the fetch size for this ResultSet object.
    public int 	getFetchSize() {return -1;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a float in the Java programming language.
    public float 	getFloat(int columnIndex) {return -1.0f;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a float in the Java programming language.
    public float 	getFloat(String columnName) {return -1.0f;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as an int in the Java programming language.
    public int 	getInt(int columnIndex) {return -1;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as an int in the Java programming language.
    public int 	getInt(String columnName) {return -1;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a long in the Java programming language.
    public long 	getLong(int columnIndex) {return -1;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a long in the Java programming language.
    public long 	getLong(String columnName) {return -1;}

//          Retrieves the number, types and properties of this ResultSet object's columns.
    public ResultSetMetaData 	getMetaData() {return null;}

//          Gets the value of the designated column in the current row of this ResultSet object as an Object in the Java programming language.
    public Object 	getObject(int columnIndex) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as an Object in the Java programming language.
    public Object 	getObject(int i, Map<String,Class<?>> map) {return null;}

//          Gets the value of the designated column in the current row of this ResultSet object as an Object in the Java programming language.
    public Object 	getObject(String columnName) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as an Object in the Java programming language.
    public Object 	getObject(String colName, Map<String,Class<?>> map) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a Ref object in the Java programming language.
    public Ref 	getRef(int i) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a Ref object in the Java programming language.
    public Ref 	getRef(String colName) {return null;}

//          Retrieves the current row number.
    public int 	getRow() {return -1;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a short in the Java programming language.
    public short 	getShort(int columnIndex) {return -1;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a short in the Java programming language.
    public short 	getShort(String columnName) {return -1;}

//          Retrieves the Statement object that produced this ResultSet object.
    public Statement 	getStatement() {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a String in the Java programming language.
    public String 	getString(int columnIndex) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a String in the Java programming language.
    public String 	getString(String columnName) {
//		org.w3c.dom.NodeList nl = doc.getElementsByTagName(columnName);
//        maxRowNum = nl.getLength();
//        try {
//			if (rowNum == -1) rowNum++; // automatically skip to first row if next has not been initially called
//            return (String) nl.item(rowNum).getTextContent();
//        } catch (java.lang.NullPointerException ne) {
//            return null;
//        }
        List<String> columns = saxDoc.getColumn(columnName);
        try {
        
            return  columns.get(rowNum);
        } catch (java.lang.NullPointerException npe) {
            return "";
        }
	}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Time object in the Java programming language.
    public Time 	getTime(int columnIndex) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Time object in the Java programming language.
    public Time 	getTime(int columnIndex, Calendar cal) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Time object in the Java programming language.
    public Time 	getTime(String columnName) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Time object in the Java programming language.
    public Time 	getTime(String columnName, Calendar cal) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming language.
    public Timestamp 	getTimestamp(int columnIndex) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming language.
    public Timestamp 	getTimestamp(int columnIndex, Calendar cal) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object.
    public Timestamp 	getTimestamp(String columnName) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming language.
    public Timestamp 	getTimestamp(String columnName, Calendar cal) {return null;}

//          Retrieves the type of this ResultSet object.
    public int 	getType() {return -1;}

//          Deprecated. use getCharacterStream in place of getUnicodeStream
    public InputStream 	getUnicodeStream(int columnIndex) {return null;}

//          Deprecated. use getCharacterStream instead
    public InputStream 	getUnicodeStream(String columnName) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a java.net.URL object in the Java programming language.
    public URL 	getURL(int columnIndex) {return null;}

//          Retrieves the value of the designated column in the current row of this ResultSet object as a java.net.URL object in the Java programming language.
    public URL 	getURL(String columnName) {return null;}

//          Retrieves the first warning reported by calls on this ResultSet object.
    public SQLWarning 	getWarnings() {return null;}

//          Inserts the contents of the insert row into this ResultSet object and into the database.
    public void 	insertRow() {}

//          Retrieves whether the cursor is after the last row in this ResultSet object.
    public boolean 	isAfterLast() {return false;}

//          Retrieves whether the cursor is before the first row in this ResultSet object.
    public boolean 	isBeforeFirst() {return false;}

//          Retrieves whether the cursor is on the first row of this ResultSet object.
    public boolean 	isFirst() {return false;}

//          Retrieves whether the cursor is on the last row of this ResultSet object.
    public boolean 	isLast() {return false;}

//          Moves the cursor to the last row in this ResultSet object.
    public boolean 	last() {return false;}

//          Moves the cursor to the remembered cursor position, usually the current row.
    public void 	moveToCurrentRow() {}

//          Moves the cursor to the insert row.
    public void 	moveToInsertRow() {}

//          Moves the cursor down one row from its current position.
    public boolean 	next() {
		rowNum++;
//System.out.println("next " + rowNum + " " + maxRowNum);		
		return rowNum < maxRowNum;
	}

//          Moves the cursor to the previous row in this ResultSet object.
    public boolean 	previous() {return false;}

//          Refreshes the current row with its most recent value in the database.
    public void 	refreshRow() {}

//          Moves the cursor a relative number of rows, either positive or negative.
    public boolean 	relative(int rows) {return false;}

//          Retrieves whether a row has been deleted.
    public boolean 	rowDeleted() {return false;}

//          Retrieves whether the current row has had an insertion.
    public boolean 	rowInserted() {return false;}

//          Retrieves whether the current row has been updated.
    public boolean 	rowUpdated() {return false;}

//          Gives a hint as to the direction in which the rows in this ResultSet object will be processed.
    public void 	setFetchDirection(int direction) {}

//          Gives the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed for this ResultSet object.
    public void 	setFetchSize(int rows) {}

//          Updates the designated column with a java.sql.Array value.
    public void 	updateArray(int columnIndex, Array x) {}

//          Updates the designated column with a java.sql.Array value.
    public void 	updateArray(String columnName, Array x) {}

//          Updates the designated column with an ascii stream value.
    public void 	updateAsciiStream(int columnIndex, InputStream x, int length) {}

//          Updates the designated column with an ascii stream value.
    public void 	updateAsciiStream(String columnName, InputStream x, int length) {}

//          Updates the designated column with a java.math.BigDecimal value.
    public void 	updateBigDecimal(int columnIndex, BigDecimal x) {}

//          Updates the designated column with a java.sql.BigDecimal value.
    public void 	updateBigDecimal(String columnName, BigDecimal x) {}

//          Updates the designated column with a binary stream value.
    public void 	updateBinaryStream(int columnIndex, InputStream x, int length) {}

//          Updates the designated column with a binary stream value.
    public void 	updateBinaryStream(String columnName, InputStream x, int length) {}

//          Updates the designated column with a java.sql.Blob value.
    public void 	updateBlob(int columnIndex, Blob x) {}

//          Updates the designated column with a java.sql.Blob value.
    public void 	updateBlob(String columnName, Blob x) {}

//          Updates the designated column with a boolean value.
    public void 	updateBoolean(int columnIndex, boolean x) {}

//          Updates the designated column with a boolean value.
	public void 	updateBoolean(String columnName, boolean x) {}

//          Updates the designated column with a byte value.
    public void 	updateByte(int columnIndex, byte x) {}

//          Updates the designated column with a byte value.
    public void 	updateByte(String columnName, byte x) {}

//          Updates the designated column with a byte array value.
    public void 	updateBytes(int columnIndex, byte[] x) {}

//          Updates the designated column with a byte array value.
    public void 	updateBytes(String columnName, byte[] x) {}

//          Updates the designated column with a character stream value.
    public void 	updateCharacterStream(int columnIndex, Reader x, int length) {}

//          Updates the designated column with a character stream value.
    public void 	updateCharacterStream(String columnName, Reader reader, int length) {}

//          Updates the designated column with a java.sql.Clob value.
    public void 	updateClob(int columnIndex, Clob x) {}

//          Updates the designated column with a java.sql.Clob value.
    public void 	updateClob(String columnName, Clob x) {}

//          Updates the designated column with a java.sql.Date value.
    public void 	updateDate(int columnIndex, Date x) {}

//          Updates the designated column with a java.sql.Date value.
    public void 	updateDate(String columnName, Date x) {}

//          Updates the designated column with a double value.
    public void 	updateDouble(int columnIndex, double x) {}

//          Updates the designated column with a double value.
    public void 	updateDouble(String columnName, double x) {}

//          Updates the designated column with a float value.
    public void 	updateFloat(int columnIndex, float x) {}

//          Updates the designated column with a float value.
    public void 	updateFloat(String columnName, float x) {}

//          Updates the designated column with an int value.
    public void 	updateInt(int columnIndex, int x) {}

//          Updates the designated column with an int value.
    public void 	updateInt(String columnName, int x) {}

//          Updates the designated column with a long value.
    public void 	updateLong(int columnIndex, long x) {}

//          Updates the designated column with a long value.
    public void 	updateLong(String columnName, long x) {}

//          Gives a nullable column a null value.
    public void 	updateNull(int columnIndex) {}

//          Updates the designated column with a null value.
    public void 	updateNull(String columnName) {}

//          Updates the designated column with an Object value.
    public void 	updateObject(int columnIndex, Object x) {}

//          Updates the designated column with an Object value.
    public void 	updateObject(int columnIndex, Object x, int scale) {}

//          Updates the designated column with an Object value.
    public void 	updateObject(String columnName, Object x) {}

//          Updates the designated column with an Object value.
    public void 	updateObject(String columnName, Object x, int scale) {}

//          Updates the designated column with a java.sql.Ref value.
    public void 	updateRef(int columnIndex, Ref x) {}

//          Updates the designated column with a java.sql.Ref value.
    public void 	updateRef(String columnName, Ref x) {}

//          Updates the underlying database with the new contents of the current row of this ResultSet object.
    public void 	updateRow() {}

//          Updates the designated column with a short value.
    public void 	updateShort(int columnIndex, short x) {}

//          Updates the designated column with a short value.
    public void 	updateShort(String columnName, short x) {}

//          Updates the designated column with a String value.
    public void 	updateString(int columnIndex, String x) {}

//          Updates the designated column with a String value.
    public void 	updateString(String columnName, String x) {}

//          Updates the designated column with a java.sql.Time value.
    public void 	updateTime(int columnIndex, Time x) {}

//          Updates the designated column with a java.sql.Time value.
    public void 	updateTime(String columnName, Time x) {}

//          Updates the designated column with a java.sql.Timestamp value.
    public void 	updateTimestamp(int columnIndex, Timestamp x) {}

//          Updates the designated column with a java.sql.Timestamp value.
    public void 	updateTimestamp(String columnName, Timestamp x) {}

//          Reports whether the last column read had a value of SQL NULL.
    public boolean 	wasNull() {return false;}

    
/* These methods are needed for jdk 1.6 */    
    public  void    updateNClob(int i, String s, Reader r) {}
    public  void    updateNClob(int i, Reader r) {}
    public  void    updateNClob(int i, Reader r, long l) {}
    public  void    updateClob(int i, Reader r) {}
    public  void    updateClob(int i, Reader r, long l) {}
    public  void    updateNClob(String s, Reader r) {}
    public  void    updateNClob(String s, Reader r, long l) {}
    public  void    updateClob(String s, Reader r) {}
    public  void    updateClob(String s, Reader r, long l) {}
    public  void    updateBlob(String s, InputStream is) {}
    public  void    updateBlob(int i, String s, InputStream is) {}
    public  void    updateBlob(int i, InputStream is) {}
    public  void    updateBlob(String s, InputStream is, long l) {}
    public  void    updateBlob(int i, String s, InputStream is, long l) {}
    public  void    updateBlob(int i, InputStream is, long l) {}
    public  void    updateCharacterStream(String s, Reader r) {}
    public  void    updateCharacterStream(int i, Reader r) {}
    public  void    updateCharacterStream(String s, Reader r, long l) {}
    public  void    updateCharacterStream(int i, Reader r, long l) {}
    public  void    updateNCharacterStream(String s, Reader r) {}
    public  void    updateNCharacterStream(int i, Reader r) {}
    public  void    updateBinaryStream(String s, InputStream is) {}
    public  void    updateBinaryStream(int i, InputStream is) {}
    public  void    updateAsciiStream(String s, InputStream is) {}
    public  void    updateAsciiStream(int i, InputStream is) {}
    public  void    updateNCharacterStream(String s, Reader r, long l) {}
    public  void    updateNCharacterStream(int i, Reader r, long l) {}
    public  void    updateBinaryStream(String s, InputStream is, long l) {}
    public  void    updateBinaryStream(int i, InputStream is, long l) {}
    public  void    updateAsciiStream(String s, InputStream is, long l) {}
    public  void    updateAsciiStream(int i, InputStream is, long l) {}
    public  Reader  getNCharacterStream(String s) {return null;}
    public  Reader  getNCharacterStream(int i) {return null;}
    public  String  getNString(String s) {return null;}
    public  String  getNString(int i) {return null;}
    public  void    updateSQLXML(String s, SQLXML sx) {}
    public  void    updateSQLXML(int i, SQLXML sx) {}
    public  SQLXML  getSQLXML(String s) {return null;}
    public  SQLXML  getSQLXML(int i) {return null;}
    public  NClob   getNClob(String s) {return null;}
    public  NClob   getNClob(int i) {return null;}
    public  void    updateNClob(String s, NClob n) {}
    public  void    updateNClob(int i, NClob n) {}
    public  void    updateNString(String s1, String s2) {}
    public  void    updateNString(int i, String s2) {}
    public  boolean isClosed() {return false;}
    public  int     getHoldability() {return -1;}
    public  void    updateRowId(String s, RowId ri) {}
    public  void    updateRowId(int i, RowId ri) {}
    public  RowId   getRowId(String s) {return null;}
    public  RowId   getRowId(int i) {return null;}
    public  boolean isWrapperFor(Class<?> c) {return false;}
    public <T> T unwrap(Class<T> t) {return null;}

}
