/**
 * Copyright (C) 2010 Orbeon, Inc.
 *
 * This program is free software; you can redistribute it and/or modify it under the terms of the
 * GNU Lesser General Public License as published by the Free Software Foundation; either version
 * 2.1 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * The full text of the license is available at http://www.gnu.org/copyleft/lesser.html
 */
package org.orbeon.oxf.processor.sql.delegates;

import oracle.jdbc.OraclePreparedStatement;
import oracle.jdbc.OracleResultSet;
import org.jboss.resource.adapter.jdbc.WrappedPreparedStatement;
import org.jboss.resource.adapter.jdbc.WrappedResultSet;
import org.orbeon.oxf.common.OXFException;
import org.orbeon.oxf.processor.sql.DatabaseDelegate;
import org.orbeon.oxf.processor.sql.SQLProcessorOracleDelegateBase;

import java.sql.*;

/**
 * Custom Delegate for Oracle / JBoss.
 */
public class SQLProcessorOracleJBossDelegate  extends SQLProcessorOracleDelegateBase implements DatabaseDelegate {

    protected OraclePreparedStatement getOraclePreparedStatement(PreparedStatement stmt) {
       
        if (stmt instanceof OraclePreparedStatement)
            return (OraclePreparedStatement) stmt;
        else {
			try {
				return (OraclePreparedStatement) ((WrappedPreparedStatement) stmt).getUnderlyingStatement();
			} catch (SQLException e) {
                throw new OXFException(e);
			}
        }
    }

    protected OracleResultSet getOracleResultSet(ResultSet resultSet) {
       
        if (resultSet instanceof OracleResultSet)
            return (OracleResultSet) resultSet;
		else
			try {
				return (OracleResultSet) ((WrappedResultSet) resultSet).getUnderlyingResultSet();
			} catch (SQLException e) {
                throw new OXFException(e);
			}
    }
}

@@ -1169,17 +1169,16 @@
 elegate 
- 
 extends 
@@ -1238,16 +1238,16 @@
 egate %7B%0A
+
 %0A    pro
@@ -1326,32 +1326,25 @@
 ent stmt) %7B%0A
-       
 %0A
+
         if (
@@ -1450,29 +1450,50 @@
  else %7B%0A
-%09%09%09try %7B%0A%09%09%09%09
+            try %7B%0A                
 return (
@@ -1573,27 +1573,36 @@
 tatement();%0A
-%09%09%09
+            
 %7D catch (SQL
@@ -1655,27 +1655,36 @@
 ception(e);%0A
-%09%09%09
+            
 %7D%0A        %7D%0A
@@ -1766,16 +1766,9 @@
 ) %7B%0A
-       
 %0A
+
     
@@ -1865,28 +1865,55 @@
 et;%0A
-%09%09else%0A%09%09%09try %7B%0A%09%09%09%09
+        else%0A            try %7B%0A                
 retu
@@ -1990,19 +1990,28 @@
 tSet();%0A
-%09%09%09
+            
 %7D catch 
@@ -2076,11 +2076,20 @@
 e);%0A
-%09%09%09
+            
 %7D%0A  

Fix whitespace