cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: xml-cocoon2/src/org/apache/cocoon/transformation SQLTransformer.java
Date Thu, 25 Oct 2001 20:25:11 GMT
bloritsch    01/10/25 13:25:11

  Modified:    src/org/apache/cocoon/transformation Tag: cocoon_20_branch
                        SQLTransformer.java
  Log:
  Optimize critical path  And fix indentation
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.5.2.14  +486 -484  xml-cocoon2/src/org/apache/cocoon/transformation/SQLTransformer.java
  
  Index: SQLTransformer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/transformation/SQLTransformer.java,v
  retrieving revision 1.5.2.13
  retrieving revision 1.5.2.14
  diff -u -r1.5.2.13 -r1.5.2.14
  --- SQLTransformer.java	2001/10/11 08:56:15	1.5.2.13
  +++ SQLTransformer.java	2001/10/25 20:25:11	1.5.2.14
  @@ -35,7 +35,7 @@
    * @author <a href="mailto:giacomo.pati@pwr.ch">Giacomo Pati</a>
    *         (PWR Organisation & Entwicklung)
    * @author <a href="mailto:sven.beauprez@the-ecorp.com">Sven Beauprez</a>
  - * @version CVS $Revision: 1.5.2.13 $ $Date: 2001/10/11 08:56:15 $ $Author: cziegeler $
  + * @version CVS $Revision: 1.5.2.14 $ $Date: 2001/10/25 20:25:11 $ $Author: bloritsch $
    */
   
   public class SQLTransformer extends AbstractTransformer implements Composable, Recyclable, Disposable, Configurable {
  @@ -112,12 +112,12 @@
       protected Parameters parameters;
       protected Map objectModel;
   
  -    public void compose(ComponentManager manager) {
  +    public void compose( ComponentManager manager ) {
           try {
               this.manager = manager;
  -            this.dbSelector = (ComponentSelector) manager.lookup(DataSourceComponent.ROLE + "Selector");
  -        } catch (ComponentException cme) {
  -            getLogger().warn("Could not get the DataSource Selector", cme);
  +            this.dbSelector = (ComponentSelector) manager.lookup( DataSourceComponent.ROLE + "Selector" );
  +        } catch ( ComponentException cme ) {
  +            getLogger().warn( "Could not get the DataSource Selector", cme );
           }
       }
   
  @@ -136,25 +136,25 @@
        * dispose
        */
       public void dispose() {
  -        if(this.dbSelector != null) this.manager.release((Component) this.dbSelector);
  +        if ( this.dbSelector != null ) this.manager.release( (Component) this.dbSelector );
       }
   
       /**
        * configure
        */
  -    public void configure(Configuration conf)throws ConfigurationException {
  -        if (conf != null) {
  -            Configuration child = conf.getChild("old-driver");
  -            this.oldDriver = child.getValueAsBoolean(false);
  -            getLogger().debug("old-driver is " + this.oldDriver + " for " + this);
  +    public void configure( Configuration conf ) throws ConfigurationException {
  +        if ( conf != null ) {
  +            Configuration child = conf.getChild( "old-driver" );
  +            this.oldDriver = child.getValueAsBoolean( false );
  +            getLogger().debug( "old-driver is " + this.oldDriver + " for " + this );
           }
       }
   
       /** BEGIN SitemapComponent methods **/
   
  -    public void setup(SourceResolver resolver, Map objectModel,
  -                      String source, Parameters parameters)
  -    throws ProcessingException, SAXException, IOException {
  +    public void setup( SourceResolver resolver, Map objectModel,
  +                       String source, Parameters parameters )
  +            throws ProcessingException, SAXException, IOException {
           // setup instance variables
           this.queries = new Vector();
           this.current_value = new StringBuffer();
  @@ -169,42 +169,42 @@
           current_state = SQLTransformer.STATE_OUTSIDE;
   
           // Check for connection
  -        String parameter = parameters.getParameter(SQLTransformer.MAGIC_CONNECTION, null);
  -        if (parameter != null) {
  -            getLogger().debug("CONNECTION: "+parameter);
  -            default_properties.setProperty(SQLTransformer.MAGIC_CONNECTION, parameter);
  +        String parameter = parameters.getParameter( SQLTransformer.MAGIC_CONNECTION, null );
  +        if ( parameter != null ) {
  +            getLogger().debug( "CONNECTION: " + parameter );
  +            default_properties.setProperty( SQLTransformer.MAGIC_CONNECTION, parameter );
           } else {
               // Check the dburl
  -            parameter = parameters.getParameter(SQLTransformer.MAGIC_DBURL,null);
  -            if (parameter != null) {
  -                getLogger().debug("DBURL: "+parameter);
  -                default_properties.setProperty(SQLTransformer.MAGIC_DBURL,parameter);
  +            parameter = parameters.getParameter( SQLTransformer.MAGIC_DBURL, null );
  +            if ( parameter != null ) {
  +                getLogger().debug( "DBURL: " + parameter );
  +                default_properties.setProperty( SQLTransformer.MAGIC_DBURL, parameter );
               }
               // Check the username
  -            parameter = parameters.getParameter(SQLTransformer.MAGIC_USERNAME,null);
  -            if (parameter != null) {
  -                getLogger().debug("USERNAME: "+parameter);
  -                default_properties.setProperty(SQLTransformer.MAGIC_USERNAME,parameter);
  +            parameter = parameters.getParameter( SQLTransformer.MAGIC_USERNAME, null );
  +            if ( parameter != null ) {
  +                getLogger().debug( "USERNAME: " + parameter );
  +                default_properties.setProperty( SQLTransformer.MAGIC_USERNAME, parameter );
               }
   
               // Check the password
  -            parameter = parameters.getParameter(SQLTransformer.MAGIC_PASSWORD,null);
  -            if (parameter != null) {
  -                default_properties.setProperty(SQLTransformer.MAGIC_PASSWORD,parameter);
  +            parameter = parameters.getParameter( SQLTransformer.MAGIC_PASSWORD, null );
  +            if ( parameter != null ) {
  +                default_properties.setProperty( SQLTransformer.MAGIC_PASSWORD, parameter );
               }
           }
  -        showNrOfRows = parameters.getParameter(SQLTransformer.MAGIC_NR_OF_ROWS,null);
  +        showNrOfRows = parameters.getParameter( SQLTransformer.MAGIC_NR_OF_ROWS, null );
   
           // Check for row-element and doc-element
  -        parameter = parameters.getParameter(SQLTransformer.MAGIC_DOC_ELEMENT, null);
  -        if (parameter != null) {
  -            getLogger().debug("DOC-ELEMENT: " + parameter);
  -            default_properties.setProperty(SQLTransformer.MAGIC_DOC_ELEMENT, parameter);
  -        }
  -        parameter = parameters.getParameter(SQLTransformer.MAGIC_ROW_ELEMENT, null);
  -        if (parameter != null) {
  -            getLogger().debug("ROW-ELEMENT: " + parameter);
  -            default_properties.setProperty(SQLTransformer.MAGIC_ROW_ELEMENT, parameter);
  +        parameter = parameters.getParameter( SQLTransformer.MAGIC_DOC_ELEMENT, null );
  +        if ( parameter != null ) {
  +            getLogger().debug( "DOC-ELEMENT: " + parameter );
  +            default_properties.setProperty( SQLTransformer.MAGIC_DOC_ELEMENT, parameter );
  +        }
  +        parameter = parameters.getParameter( SQLTransformer.MAGIC_ROW_ELEMENT, null );
  +        if ( parameter != null ) {
  +            getLogger().debug( "ROW-ELEMENT: " + parameter );
  +            default_properties.setProperty( SQLTransformer.MAGIC_ROW_ELEMENT, parameter );
           }
       }
   
  @@ -215,145 +215,145 @@
       /**
        * This will be the meat of SQLTransformer, where the query is run.
        */
  -    protected void executeQuery(int index) throws SAXException {
  +    protected void executeQuery( int index ) throws SAXException {
   //        this.contentHandler.startPrefixMapping("",my_uri);
  -        getLogger().debug("SQLTransformer executing query nr " + index);
  +        getLogger().debug( "SQLTransformer executing query nr " + index );
           AttributesImpl attr = new AttributesImpl();
  -        Query query = (Query) queries.elementAt(index);
  +        Query query = (Query) queries.elementAt( index );
           try {
               query.execute();
   
  -            if (showNrOfRows!=null && showNrOfRows.equalsIgnoreCase("true"))  {
  -              attr.addAttribute(my_uri,query.nr_of_rows,query.nr_of_rows,"CDATA",
  -                                String.valueOf(query.getNrOfRows()));
  +            if ( showNrOfRows != null && showNrOfRows.equalsIgnoreCase( "true" ) ) {
  +                attr.addAttribute( my_uri, query.nr_of_rows, query.nr_of_rows, "CDATA",
  +                                   String.valueOf( query.getNrOfRows() ) );
               }
               String name = query.getName();
  -            if (name !=null)  {
  -              attr.addAttribute(my_uri,query.name_attribute,query.name_attribute,"CDATA",
  -                                name);
  -            }
  -            this.start(query.rowset_name, attr);
  -            attr=new AttributesImpl();
  -            if (!query.isStoredProcedure())  {
  -              while (query.next()) {
  -                  this.start(query.row_name, attr);
  -                  query.serializeRow();
  -                  if (index + 1 < queries.size()) {
  -                      executeQuery(index + 1);
  -                  }
  -                  this.end(query.row_name);
  -              }
  -            } else  {
  -              query.serializeStoredProcedure();
  -            }
  -        } catch (SQLException e) {
  -            getLogger().debug("SQLTransformer.executeQuery()", e);
  -            throw new SAXException(e);
  +            if ( name != null ) {
  +                attr.addAttribute( my_uri, query.name_attribute, query.name_attribute, "CDATA",
  +                                   name );
  +            }
  +            this.start( query.rowset_name, attr );
  +            attr = new AttributesImpl();
  +            if ( !query.isStoredProcedure() ) {
  +                while ( query.next() ) {
  +                    this.start( query.row_name, attr );
  +                    query.serializeRow();
  +                    if ( index + 1 < queries.size() ) {
  +                        executeQuery( index + 1 );
  +                    }
  +                    this.end( query.row_name );
  +                }
  +            } else {
  +                query.serializeStoredProcedure();
  +            }
  +        } catch ( SQLException e ) {
  +            getLogger().debug( "SQLTransformer.executeQuery()", e );
  +            throw new SAXException( e );
           } finally {
  -            try{
  +            try {
                   query.close();
  -            }catch(SQLException e){
  -                getLogger().warn("SQLTransformer: Could not close JDBC connection", e);
  +            } catch ( SQLException e ) {
  +                getLogger().warn( "SQLTransformer: Could not close JDBC connection", e );
               }
           }
  -        this.end(query.rowset_name);
  +        this.end( query.rowset_name );
   //        this.contentHandler.endPrefixMapping("");
       }
   
  -    protected static void throwIllegalStateException(String message) {
  -        throw new IllegalStateException(my_name + ": "+message);
  +    protected static void throwIllegalStateException( String message ) {
  +        throw new IllegalStateException( my_name + ": " + message );
       }
   
       protected void startExecuteQueryElement() {
  -        switch (current_state) {
  +        switch ( current_state ) {
               case SQLTransformer.STATE_OUTSIDE:
               case SQLTransformer.STATE_INSIDE_EXECUTE_QUERY_ELEMENT:
                   current_query_index = queries.size();
  -                Query query = new Query(this, current_query_index);
  -                queries.addElement(query);
  +                Query query = new Query( this, current_query_index );
  +                queries.addElement( query );
                   current_state = SQLTransformer.STATE_INSIDE_EXECUTE_QUERY_ELEMENT;
                   break;
               default:
  -                throwIllegalStateException("Not expecting a start execute query element");
  +                throwIllegalStateException( "Not expecting a start execute query element" );
           }
       }
   
  -    protected void startValueElement(String name) {
  -        switch (current_state) {
  +    protected void startValueElement( String name ) {
  +        switch ( current_state ) {
               case SQLTransformer.STATE_INSIDE_EXECUTE_QUERY_ELEMENT:
                   current_name = name;
  -                current_value.setLength(0);
  +                current_value.setLength( 0 );
                   current_state = SQLTransformer.STATE_INSIDE_VALUE_ELEMENT;
                   break;
               default:
  -                throwIllegalStateException("Not expecting a start value element: "+
  -                                           name);
  +                throwIllegalStateException( "Not expecting a start value element: " +
  +                                            name );
           }
       }
   
  -    protected void startQueryElement(Attributes attributes) {
  -        switch (current_state) {
  +    protected void startQueryElement( Attributes attributes ) {
  +        switch ( current_state ) {
               case SQLTransformer.STATE_INSIDE_EXECUTE_QUERY_ELEMENT:
  -                current_value.setLength(0);
  +                current_value.setLength( 0 );
                   Query q = getCurrentQuery();
                   current_state = SQLTransformer.STATE_INSIDE_QUERY_ELEMENT;
                   String isupdate =
  -                  attributes.getValue("", SQLTransformer.MAGIC_UPDATE_ATTRIBUTE);
  -                if (isupdate != null && !isupdate.equalsIgnoreCase("false"))
  -                  q.setUpdate(true);
  +                        attributes.getValue( "", SQLTransformer.MAGIC_UPDATE_ATTRIBUTE );
  +                if ( isupdate != null && !isupdate.equalsIgnoreCase( "false" ) )
  +                    q.setUpdate( true );
                   String isstoredprocedure =
  -                  attributes.getValue("", SQLTransformer.MAGIC_STORED_PROCEDURE_ATTRIBUTE);
  -                if (isstoredprocedure != null && !isstoredprocedure.equalsIgnoreCase("false"))
  -                  q.setStoredProcedure(true);
  +                        attributes.getValue( "", SQLTransformer.MAGIC_STORED_PROCEDURE_ATTRIBUTE );
  +                if ( isstoredprocedure != null && !isstoredprocedure.equalsIgnoreCase( "false" ) )
  +                    q.setStoredProcedure( true );
                   String name =
  -                  attributes.getValue("", SQLTransformer.MAGIC_NAME_ATTRIBUTE);
  -                if (name != null)  {
  -                  q.setName(name);
  +                        attributes.getValue( "", SQLTransformer.MAGIC_NAME_ATTRIBUTE );
  +                if ( name != null ) {
  +                    q.setName( name );
                   }
                   break;
               default:
  -                throwIllegalStateException("Not expecting a start query element");
  +                throwIllegalStateException( "Not expecting a start query element" );
           }
       }
   
       protected void endQueryElement() {
  -        switch (current_state) {
  +        switch ( current_state ) {
               case SQLTransformer.STATE_INSIDE_QUERY_ELEMENT:
  -                if (current_value.length() > 0) {
  +                if ( current_value.length() > 0 ) {
                       getCurrentQuery().addQueryPart(
  -                      current_value.toString());
  -                    getLogger().debug("QUERY IS \""+
  -                                           current_value.toString() + "\"");
  -                    current_value.setLength(0);
  +                            current_value.toString() );
  +                    getLogger().debug( "QUERY IS \"" +
  +                                       current_value.toString() + "\"" );
  +                    current_value.setLength( 0 );
                   }
                   current_state = SQLTransformer.STATE_INSIDE_EXECUTE_QUERY_ELEMENT;
                   break;
               default:
  -                throwIllegalStateException("Not expecting a stop query element");
  +                throwIllegalStateException( "Not expecting a stop query element" );
           }
       }
   
       protected void endValueElement() {
  -        switch (current_state) {
  +        switch ( current_state ) {
               case SQLTransformer.STATE_INSIDE_VALUE_ELEMENT:
  -                getCurrentQuery().setParameter(current_name,
  -                                               current_value.toString());
  -                getLogger().debug("SETTING VALUE ELEMENT name {"+
  -                                       current_name + "} value {"+
  -                                       current_value.toString() + "}");
  +                getCurrentQuery().setParameter( current_name,
  +                                                current_value.toString() );
  +                getLogger().debug( "SETTING VALUE ELEMENT name {" +
  +                                   current_name + "} value {" +
  +                                   current_value.toString() + "}" );
   
                   current_state = SQLTransformer.STATE_INSIDE_EXECUTE_QUERY_ELEMENT;
                   break;
               default:
  -                throwIllegalStateException("Not expecting an end value element");
  +                throwIllegalStateException( "Not expecting an end value element" );
           }
       }
   
       protected void endExecuteQueryElement() throws SAXException {
  -        switch (current_state) {
  +        switch ( current_state ) {
               case SQLTransformer.STATE_INSIDE_EXECUTE_QUERY_ELEMENT:
  -                if (current_query_index == 0) {
  -                    executeQuery(0);
  +                if ( current_query_index == 0 ) {
  +                    executeQuery( 0 );
                       queries.removeAllElements();
                       current_state = SQLTransformer.STATE_OUTSIDE;
                   } else {
  @@ -362,44 +362,44 @@
                   }
                   break;
               default:
  -                throwIllegalStateException("Not expecting an end execute query element");
  +                throwIllegalStateException( "Not expecting an end execute query element" );
           }
       }
   
  -    protected void startAncestorValueElement(Attributes attributes) {
  -        switch (current_state) {
  +    protected void startAncestorValueElement( Attributes attributes ) {
  +        switch ( current_state ) {
               case SQLTransformer.STATE_INSIDE_QUERY_ELEMENT:
                   int level = 0;
                   try {
  -                    level = Integer.parseInt( attributes.getValue(my_uri,
  -                                              SQLTransformer.MAGIC_ANCESTOR_VALUE_LEVEL_ATTRIBUTE));
  -                } catch (Exception e) {
  -                    getLogger().debug("SQLTransformer", e);
  -                    throwIllegalStateException("Ancestor value elements must have a "+
  -                                               SQLTransformer.MAGIC_ANCESTOR_VALUE_LEVEL_ATTRIBUTE + " attribute");
  -                }
  -                String name = attributes.getValue(my_uri,
  -                                                  SQLTransformer.MAGIC_ANCESTOR_VALUE_NAME_ATTRIBUTE);
  -                if (name == null) {
  -                    throwIllegalStateException("Ancestor value elements must have a "+
  -                                               SQLTransformer.MAGIC_ANCESTOR_VALUE_NAME_ATTRIBUTE + " attribute");
  +                    level = Integer.parseInt( attributes.getValue( my_uri,
  +                                                                   SQLTransformer.MAGIC_ANCESTOR_VALUE_LEVEL_ATTRIBUTE ) );
  +                } catch ( Exception e ) {
  +                    getLogger().debug( "SQLTransformer", e );
  +                    throwIllegalStateException( "Ancestor value elements must have a " +
  +                                                SQLTransformer.MAGIC_ANCESTOR_VALUE_LEVEL_ATTRIBUTE + " attribute" );
  +                }
  +                String name = attributes.getValue( my_uri,
  +                                                   SQLTransformer.MAGIC_ANCESTOR_VALUE_NAME_ATTRIBUTE );
  +                if ( name == null ) {
  +                    throwIllegalStateException( "Ancestor value elements must have a " +
  +                                                SQLTransformer.MAGIC_ANCESTOR_VALUE_NAME_ATTRIBUTE + " attribute" );
                   }
  -                AncestorValue av = new AncestorValue(level, name);
  -                getLogger().debug("ANCESTOR VALUE "+level + " "+name);
  +                AncestorValue av = new AncestorValue( level, name );
  +                getLogger().debug( "ANCESTOR VALUE " + level + " " + name );
   
  -                if (current_value.length() > 0) {
  +                if ( current_value.length() > 0 ) {
                       getCurrentQuery().addQueryPart(
  -                      current_value.toString());
  -                    getLogger().debug("QUERY IS \""+
  -                                           current_value.toString() + "\"");
  +                            current_value.toString() );
  +                    getLogger().debug( "QUERY IS \"" +
  +                                       current_value.toString() + "\"" );
   
  -                    current_value.setLength(0);
  +                    current_value.setLength( 0 );
                   }
  -                getCurrentQuery().addQueryPart(av);
  +                getCurrentQuery().addQueryPart( av );
                   current_state = SQLTransformer.STATE_INSIDE_ANCESTOR_VALUE_ELEMENT;
                   break;
               default:
  -                throwIllegalStateException("Not expecting a start ancestor value element");
  +                throwIllegalStateException( "Not expecting a start ancestor value element" );
           }
       }
   
  @@ -407,31 +407,31 @@
           current_state = SQLTransformer.STATE_INSIDE_QUERY_ELEMENT;
       }
   
  -    protected void startSubstituteValueElement(Attributes attributes) {
  -        switch (current_state) {
  +    protected void startSubstituteValueElement( Attributes attributes ) {
  +        switch ( current_state ) {
               case SQLTransformer.STATE_INSIDE_QUERY_ELEMENT:
  -                String name = attributes.getValue(my_uri,
  -                                                  SQLTransformer.MAGIC_SUBSTITUTE_VALUE_NAME_ATTRIBUTE);
  -                if (name == null) {
  -                    throwIllegalStateException("Substitute value elements must have a "+
  -                                               SQLTransformer.MAGIC_SUBSTITUTE_VALUE_NAME_ATTRIBUTE + " attribute");
  +                String name = attributes.getValue( my_uri,
  +                                                   SQLTransformer.MAGIC_SUBSTITUTE_VALUE_NAME_ATTRIBUTE );
  +                if ( name == null ) {
  +                    throwIllegalStateException( "Substitute value elements must have a " +
  +                                                SQLTransformer.MAGIC_SUBSTITUTE_VALUE_NAME_ATTRIBUTE + " attribute" );
                   }
  -                String substitute = parameters.getParameter(name,null);
  +                String substitute = parameters.getParameter( name, null );
                   //escape single quote
  -                substitute = replaceCharWithString(substitute,'\'',"''");
  -                getLogger().debug("SUBSTITUTE VALUE "+substitute);
  -                if (current_value.length() > 0) {
  -                    getCurrentQuery().addQueryPart(current_value.toString());
  -                    getLogger().debug("QUERY IS \""+
  -                                           current_value.toString() + "\"");
  +                substitute = replaceCharWithString( substitute, '\'', "''" );
  +                getLogger().debug( "SUBSTITUTE VALUE " + substitute );
  +                if ( current_value.length() > 0 ) {
  +                    getCurrentQuery().addQueryPart( current_value.toString() );
  +                    getLogger().debug( "QUERY IS \"" +
  +                                       current_value.toString() + "\"" );
   
  -                    current_value.setLength(0);
  +                    current_value.setLength( 0 );
                   }
  -                getCurrentQuery().addQueryPart(substitute);
  +                getCurrentQuery().addQueryPart( substitute );
                   current_state = SQLTransformer.STATE_INSIDE_SUBSTITUTE_VALUE_ELEMENT;
                   break;
               default:
  -                throwIllegalStateException("Not expecting a start substitute value element");
  +                throwIllegalStateException( "Not expecting a start substitute value element" );
           }
       }
   
  @@ -439,44 +439,44 @@
           current_state = SQLTransformer.STATE_INSIDE_QUERY_ELEMENT;
       }
   
  -    protected void startInParameterElement(Attributes attributes)  {
  -      switch (current_state)  {
  -        case SQLTransformer.STATE_INSIDE_EXECUTE_QUERY_ELEMENT:
  -            String nr = attributes.getValue(my_uri,
  -                                              SQLTransformer.MAGIC_IN_PARAMETER_NR_ATTRIBUTE);
  -            String value = attributes.getValue(my_uri,
  -                                              SQLTransformer.MAGIC_IN_PARAMETER_VALUE_ATTRIBUTE);
  -            getLogger().debug("IN PARAMETER NR " + nr + "; VALUE "+ value);
  -            int position = Integer.parseInt(nr);
  -            getCurrentQuery().setInParameter(position,value);
  -            current_state = SQLTransformer.STATE_INSIDE_IN_PARAMETER_ELEMENT;
  -            break;
  -        default:
  -            throwIllegalStateException("Not expecting an in-parameter element");
  -      }
  +    protected void startInParameterElement( Attributes attributes ) {
  +        switch ( current_state ) {
  +            case SQLTransformer.STATE_INSIDE_EXECUTE_QUERY_ELEMENT:
  +                String nr = attributes.getValue( my_uri,
  +                                                 SQLTransformer.MAGIC_IN_PARAMETER_NR_ATTRIBUTE );
  +                String value = attributes.getValue( my_uri,
  +                                                    SQLTransformer.MAGIC_IN_PARAMETER_VALUE_ATTRIBUTE );
  +                getLogger().debug( "IN PARAMETER NR " + nr + "; VALUE " + value );
  +                int position = Integer.parseInt( nr );
  +                getCurrentQuery().setInParameter( position, value );
  +                current_state = SQLTransformer.STATE_INSIDE_IN_PARAMETER_ELEMENT;
  +                break;
  +            default:
  +                throwIllegalStateException( "Not expecting an in-parameter element" );
  +        }
       }
   
       protected void endInParameterElement() {
           current_state = SQLTransformer.STATE_INSIDE_EXECUTE_QUERY_ELEMENT;
       }
   
  -    protected void startOutParameterElement(Attributes attributes)  {
  -      switch (current_state)  {
  -        case SQLTransformer.STATE_INSIDE_EXECUTE_QUERY_ELEMENT:
  -            String name = attributes.getValue(my_uri,
  -                                              SQLTransformer.MAGIC_OUT_PARAMETER_NAME_ATTRIBUTE);
  -            String nr = attributes.getValue(my_uri,
  -                                              SQLTransformer.MAGIC_OUT_PARAMETER_NR_ATTRIBUTE);
  -            String type = attributes.getValue(my_uri,
  -                                              SQLTransformer.MAGIC_OUT_PARAMETER_TYPE_ATTRIBUTE);
  -            getLogger().debug("OUT PARAMETER NAME" + name +";NR " + nr + "; TYPE "+ type);
  -            int position = Integer.parseInt(nr);
  -            getCurrentQuery().setOutParameter(position,type,name);
  -            current_state = SQLTransformer.STATE_INSIDE_OUT_PARAMETER_ELEMENT;
  -            break;
  -        default:
  -            throwIllegalStateException("Not expecting an out-parameter element");
  -      }
  +    protected void startOutParameterElement( Attributes attributes ) {
  +        switch ( current_state ) {
  +            case SQLTransformer.STATE_INSIDE_EXECUTE_QUERY_ELEMENT:
  +                String name = attributes.getValue( my_uri,
  +                                                   SQLTransformer.MAGIC_OUT_PARAMETER_NAME_ATTRIBUTE );
  +                String nr = attributes.getValue( my_uri,
  +                                                 SQLTransformer.MAGIC_OUT_PARAMETER_NR_ATTRIBUTE );
  +                String type = attributes.getValue( my_uri,
  +                                                   SQLTransformer.MAGIC_OUT_PARAMETER_TYPE_ATTRIBUTE );
  +                getLogger().debug( "OUT PARAMETER NAME" + name + ";NR " + nr + "; TYPE " + type );
  +                int position = Integer.parseInt( nr );
  +                getCurrentQuery().setOutParameter( position, type, name );
  +                current_state = SQLTransformer.STATE_INSIDE_OUT_PARAMETER_ELEMENT;
  +                break;
  +            default:
  +                throwIllegalStateException( "Not expecting an out-parameter element" );
  +        }
       }
   
       protected void endOutParameterElement() {
  @@ -484,141 +484,140 @@
       }
   
       protected Query getCurrentQuery() {
  -        return (Query) queries.elementAt(current_query_index);
  +        return (Query) queries.elementAt( current_query_index );
       }
   
  -    protected Query getQuery(int i) {
  -        return (Query) queries.elementAt(i);
  +    protected Query getQuery( int i ) {
  +        return (Query) queries.elementAt( i );
       }
   
  -    private String replaceCharWithString(String in, char c, String with)  {
  -      Tokenizer tok;
  -      StringBuffer replaced=null;
  -      if (in.indexOf(c)>-1)  {
  -        tok = new Tokenizer(in,c);
  -        replaced=new StringBuffer();
  -        while (tok.hasMoreTokens())  {
  -          replaced.append(tok.nextToken());
  -          if (tok.hasMoreTokens())
  -            replaced.append(with);
  -        }
  -      }
  -      if (replaced!=null)  {
  -        return replaced.toString();
  -      } else  {
  -        return in;
  -      }
  +    private String replaceCharWithString( String in, char c, String with ) {
  +        Tokenizer tok;
  +        StringBuffer replaced = null;
  +        if ( in.indexOf( c ) > -1 ) {
  +            tok = new Tokenizer( in, c );
  +            replaced = new StringBuffer();
  +            while ( tok.hasMoreTokens() ) {
  +                replaced.append( tok.nextToken() );
  +                if ( tok.hasMoreTokens() )
  +                    replaced.append( with );
  +            }
  +        }
  +        if ( replaced != null ) {
  +            return replaced.toString();
  +        } else {
  +            return in;
  +        }
       }
   
       /** END my very own methods **/
   
       /** BEGIN SAX ContentHandler handlers **/
   
  -    public void setDocumentLocator(Locator locator) {
  -        getLogger().info("PUBLIC ID"+locator.getPublicId());
  -        getLogger().info("SYSTEM ID"+locator.getSystemId());
  -        if (super.contentHandler != null)
  -            super.contentHandler.setDocumentLocator(locator);
  +    public void setDocumentLocator( Locator locator ) {
  +        getLogger().info( "PUBLIC ID" + locator.getPublicId() );
  +        getLogger().info( "SYSTEM ID" + locator.getSystemId() );
  +        if ( super.contentHandler != null )
  +            super.contentHandler.setDocumentLocator( locator );
       }
   
  -    public void startElement(String uri, String name, String raw,
  -                             Attributes attributes) throws SAXException {
  -        if (!uri.equals(my_uri)) {
  -            super.startElement(uri, name, raw, attributes);
  +    public void startElement( String uri, String name, String raw,
  +                              Attributes attributes ) throws SAXException {
  +        if ( !uri.equals( my_uri ) ) {
  +            super.startElement( uri, name, raw, attributes );
               return;
           }
  -        getLogger().debug("RECEIVED START ELEMENT "+name);
  +        getLogger().debug( "RECEIVED START ELEMENT " + name );
   
  -        if (name.equals(SQLTransformer.MAGIC_EXECUTE_QUERY)) {
  +        if ( name.equals( SQLTransformer.MAGIC_EXECUTE_QUERY ) ) {
               startExecuteQueryElement();
  -        } else if (name.equals(SQLTransformer.MAGIC_QUERY)) {
  -            startQueryElement(attributes);
  -        } else if (name.equals(SQLTransformer.MAGIC_ANCESTOR_VALUE)) {
  -            startAncestorValueElement(attributes);
  -        } else if (name.equals(SQLTransformer.MAGIC_SUBSTITUTE_VALUE)) {
  -            startSubstituteValueElement(attributes);
  -        } else if (name.equals(SQLTransformer.MAGIC_IN_PARAMETER)) {
  -            startInParameterElement(attributes);
  -        } else if (name.equals(SQLTransformer.MAGIC_OUT_PARAMETER)) {
  -            startOutParameterElement(attributes);
  -        } else  {
  -            startValueElement(name);
  +        } else if ( name.equals( SQLTransformer.MAGIC_QUERY ) ) {
  +            startQueryElement( attributes );
  +        } else if ( name.equals( SQLTransformer.MAGIC_ANCESTOR_VALUE ) ) {
  +            startAncestorValueElement( attributes );
  +        } else if ( name.equals( SQLTransformer.MAGIC_SUBSTITUTE_VALUE ) ) {
  +            startSubstituteValueElement( attributes );
  +        } else if ( name.equals( SQLTransformer.MAGIC_IN_PARAMETER ) ) {
  +            startInParameterElement( attributes );
  +        } else if ( name.equals( SQLTransformer.MAGIC_OUT_PARAMETER ) ) {
  +            startOutParameterElement( attributes );
  +        } else {
  +            startValueElement( name );
           }
       }
   
  -    public void endElement(String uri, String name,
  -                           String raw) throws SAXException {
  -        if (!uri.equals(my_uri)) {
  -            super.endElement(uri, name, raw);
  +    public void endElement( String uri, String name,
  +                            String raw ) throws SAXException {
  +        if ( !uri.equals( my_uri ) ) {
  +            super.endElement( uri, name, raw );
               return;
           }
  -        getLogger().debug("RECEIVED END ELEMENT "+name + "("+uri + ")");
  +        getLogger().debug( "RECEIVED END ELEMENT " + name + "(" + uri + ")" );
   
  -        if (name.equals(SQLTransformer.MAGIC_EXECUTE_QUERY)) {
  +        if ( name.equals( SQLTransformer.MAGIC_EXECUTE_QUERY ) ) {
               endExecuteQueryElement();
  -        } else if (name.equals(SQLTransformer.MAGIC_QUERY)) {
  +        } else if ( name.equals( SQLTransformer.MAGIC_QUERY ) ) {
               endQueryElement();
  -        } else if (name.equals(SQLTransformer.MAGIC_ANCESTOR_VALUE)) {
  +        } else if ( name.equals( SQLTransformer.MAGIC_ANCESTOR_VALUE ) ) {
               endAncestorValueElement();
  -        } else if (name.equals(SQLTransformer.MAGIC_SUBSTITUTE_VALUE)) {
  +        } else if ( name.equals( SQLTransformer.MAGIC_SUBSTITUTE_VALUE ) ) {
               endSubstituteValueElement();
  -        } else if (name.equals(SQLTransformer.MAGIC_IN_PARAMETER)) {
  +        } else if ( name.equals( SQLTransformer.MAGIC_IN_PARAMETER ) ) {
               endInParameterElement();
  -        } else if (name.equals(SQLTransformer.MAGIC_OUT_PARAMETER)) {
  +        } else if ( name.equals( SQLTransformer.MAGIC_OUT_PARAMETER ) ) {
               endOutParameterElement();
  -        } else if (name.equals(SQLTransformer.MAGIC_VALUE) || current_state == SQLTransformer.STATE_INSIDE_VALUE_ELEMENT) {
  +        } else if ( name.equals( SQLTransformer.MAGIC_VALUE ) || current_state == SQLTransformer.STATE_INSIDE_VALUE_ELEMENT ) {
               endValueElement();
           } else {
  -            super.endElement(uri, name, raw);
  +            super.endElement( uri, name, raw );
           }
       }
   
  -    public void characters(char ary[], int start,
  -                           int length) throws SAXException {
  -        if (current_state != SQLTransformer.STATE_INSIDE_VALUE_ELEMENT &&
  -                current_state != SQLTransformer.STATE_INSIDE_QUERY_ELEMENT) {
  -            super.characters(ary, start, length);
  +    public void characters( char ary[], int start,
  +                            int length ) throws SAXException {
  +        if ( current_state != SQLTransformer.STATE_INSIDE_VALUE_ELEMENT &&
  +                current_state != SQLTransformer.STATE_INSIDE_QUERY_ELEMENT ) {
  +            super.characters( ary, start, length );
           }
  -        getLogger().debug("RECEIVED CHARACTERS: "+
  -                               new String(ary, start, length));
  -        current_value.append(ary, start, length);
  +        getLogger().debug( "RECEIVED CHARACTERS: " +
  +                           new String( ary, start, length ) );
  +        current_value.append( ary, start, length );
       }
   
  -    private void attribute(AttributesImpl attr, String name, String value) {
  -        attr.addAttribute("",name, name, "CDATA",value);
  +    private void attribute( AttributesImpl attr, String name, String value ) {
  +        attr.addAttribute( "", name, name, "CDATA", value );
       }
   
  -    private void start(String name,
  -                       AttributesImpl attr) throws SAXException {
  -        super.contentHandler.startElement(my_uri, name, name, attr);
  +    private void start( String name,
  +                        AttributesImpl attr ) throws SAXException {
  +        super.contentHandler.startElement( my_uri, name, name, attr );
           attr.clear();
       }
   
  -    private void end(String name) throws SAXException {
  -        super.contentHandler.endElement(my_uri, name, name);
  +    private void end( String name ) throws SAXException {
  +        super.contentHandler.endElement( my_uri, name, name );
       }
   
  -    private void data(String data) throws SAXException {
  -        if (data != null)  {
  -          super.contentHandler.characters(data.toCharArray(), 0,
  -                                            data.length());
  +    private void data( String data ) throws SAXException {
  +        if ( data != null ) {
  +            super.contentHandler.characters( data.toCharArray(), 0,
  +                                             data.length() );
           }
       }
   
  -    protected static String getStringValue(Object object) {
  -        if (object instanceof byte[]) {
  -            return new String((byte[]) object);
  -        } else if (object instanceof char[]) {
  -            return new String((char[]) object);
  -        } else if (object != null) {
  +    protected static String getStringValue( Object object ) {
  +        if ( object instanceof byte[] ) {
  +            return new String( (byte[]) object );
  +        } else if ( object instanceof char[] ) {
  +            return new String( (char[]) object );
  +        } else if ( object != null ) {
               return object.toString();
           } else {
               return "";
           }
       }
   
  -    public final Logger getTheLogger()
  -    {
  +    public final Logger getTheLogger() {
           return getLogger();
       }
   
  @@ -659,7 +658,7 @@
           /** If this query is actually a stored procedure **/
           protected boolean isstoredprocedure = false;
   
  -        protected String name=null;
  +        protected String name = null;
   
           /** If it is an update/etc, the return value (num rows modified) **/
           protected int rv = -1;
  @@ -668,210 +667,212 @@
           protected Vector query_parts = new Vector();
   
           /** In parameters **/
  -        protected HashMap inParameters=null;
  +        protected HashMap inParameters = null;
   
           /** Out parameters **/
  -        protected HashMap outParameters=null;
  +        protected HashMap outParameters = null;
   
           /** Mapping out parameters - objectModel **/
  -        protected HashMap outParametersNames=null;
  +        protected HashMap outParametersNames = null;
   
  -        protected Query(SQLTransformer transformer, int query_index) {
  +        protected Query( SQLTransformer transformer, int query_index ) {
               this.transformer = transformer;
               this.query_index = query_index;
  -            this.properties = new Properties(transformer.default_properties);
  +            this.properties = new Properties( transformer.default_properties );
           }
   
  -        protected void setParameter(String name, String value) {
  -            properties.setProperty(name, value);
  +        protected void setParameter( String name, String value ) {
  +            properties.setProperty( name, value );
           }
   
  -        protected void setUpdate(boolean flag) {
  +        protected void setUpdate( boolean flag ) {
               isupdate = flag;
           }
   
  -        protected void setStoredProcedure(boolean flag)  {
  +        protected void setStoredProcedure( boolean flag ) {
               isstoredprocedure = flag;
           }
   
  -        protected boolean isStoredProcedure()  {
  -          return isstoredprocedure;
  +        protected boolean isStoredProcedure() {
  +            return isstoredprocedure;
           }
   
  -        protected void setName(String name)  {
  -          this.name = name;
  +        protected void setName( String name ) {
  +            this.name = name;
           }
   
  -        protected String getName()  {
  -          return name;
  +        protected String getName() {
  +            return name;
           }
   
  -        protected void setInParameter(int pos, String val)  {
  -          if (inParameters == null)  {
  -            inParameters = new HashMap();
  -          }
  -          inParameters.put(new Integer(pos),val);
  +        protected void setInParameter( int pos, String val ) {
  +            if ( inParameters == null ) {
  +                inParameters = new HashMap();
  +            }
  +            inParameters.put( new Integer( pos ), val );
           }
   
  -        protected void setOutParameter(int pos, String type, String name)  {
  -          if (outParameters == null)  {
  -            outParameters = new HashMap();
  -            outParametersNames = new HashMap();
  -          }
  -          outParameters.put(new Integer(pos),type);
  -          outParametersNames.put(new Integer(pos),name);
  +        protected void setOutParameter( int pos, String type, String name ) {
  +            if ( outParameters == null ) {
  +                outParameters = new HashMap();
  +                outParametersNames = new HashMap();
  +            }
  +            outParameters.put( new Integer( pos ), type );
  +            outParametersNames.put( new Integer( pos ), name );
           }
   
  -        private void registerInParameters(PreparedStatement pst) throws SQLException{
  -          if (inParameters==null)
  -            return;
  -          Iterator itInKeys = inParameters.keySet().iterator();
  -          Integer counter;
  -          String value;
  -          while (itInKeys.hasNext()) {
  -            counter = (Integer)itInKeys.next();
  -            value = (String)inParameters.get(counter);
  -            try  {
  -              pst.setObject(counter.intValue(),value);
  -            }catch (SQLException e)  {
  -              transformer.getTheLogger().error("Caught a SQLException", e);
  -              throw e;
  +        private void registerInParameters( PreparedStatement pst ) throws SQLException {
  +            if ( inParameters == null )
  +                return;
  +            Iterator itInKeys = inParameters.keySet().iterator();
  +            Integer counter;
  +            String value;
  +            while ( itInKeys.hasNext() ) {
  +                counter = (Integer) itInKeys.next();
  +                value = (String) inParameters.get( counter );
  +                try {
  +                    pst.setObject( counter.intValue(), value );
  +                } catch ( SQLException e ) {
  +                    transformer.getTheLogger().error( "Caught a SQLException", e );
  +                    throw e;
  +                }
               }
  -          }
           }
   
  -        private void registerOutParameters(CallableStatement cst) throws SQLException {
  -          if (outParameters==null)
  -            return;
  -          Iterator itOutKeys = outParameters.keySet().iterator();
  -          Integer counter;
  -          int index;
  -          String type, className, fieldName;
  -          Class clss;
  -          Field fld;
  -          while (itOutKeys.hasNext()) {
  -            counter = (Integer)itOutKeys.next();
  -            type = (String)outParameters.get(counter);
  -            index = type.lastIndexOf(".");
  -            if (index>-1)  {
  -              className = type.substring(0,index);
  -              fieldName = type.substring(index+1,type.length());
  -            }else  {
  -              transformer.getTheLogger().error("Invalid SQLType: " +type, null);
  -              throw new SQLException("Wrong SQLType");
  -            }
  -            try  {
  -              clss = Class.forName(className);
  -              fld = clss.getField(fieldName);
  -              cst.registerOutParameter(counter.intValue(),fld.getInt(fieldName));
  -            }catch (Exception e)  { //lots of different exceptions to catch
  -              transformer.getTheLogger().error("Invalid SQLType: " +
  -                                                className +"."+fieldName, e);
  +        private void registerOutParameters( CallableStatement cst ) throws SQLException {
  +            if ( outParameters == null )
  +                return;
  +            Iterator itOutKeys = outParameters.keySet().iterator();
  +            Integer counter;
  +            int index;
  +            String type, className, fieldName;
  +            Class clss;
  +            Field fld;
  +            while ( itOutKeys.hasNext() ) {
  +                counter = (Integer) itOutKeys.next();
  +                type = (String) outParameters.get( counter );
  +                index = type.lastIndexOf( "." );
  +                if ( index > -1 ) {
  +                    className = type.substring( 0, index );
  +                    fieldName = type.substring( index + 1, type.length() );
  +                } else {
  +                    transformer.getTheLogger().error( "Invalid SQLType: " + type, null );
  +                    throw new SQLException( "Wrong SQLType" );
  +                }
  +                try {
  +                    clss = Class.forName( className );
  +                    fld = clss.getField( fieldName );
  +                    cst.registerOutParameter( counter.intValue(), fld.getInt( fieldName ) );
  +                } catch ( Exception e ) {
  +                    //lots of different exceptions to catch
  +                    transformer.getTheLogger().error( "Invalid SQLType: " +
  +                                                      className + "." + fieldName, e );
  +                }
               }
  -          }
           }
   
           /** Get a Connection. Made this a separate method to separate the logic from the actual execution. */
           protected Connection getConnection() throws SQLException {
               Connection result = null;
   
  -            String connection = properties.getProperty(SQLTransformer.MAGIC_CONNECTION);
  -            String dburl = properties.getProperty(SQLTransformer.MAGIC_DBURL);
  -            String username = properties.getProperty(SQLTransformer.MAGIC_USERNAME);
  -            String password = properties.getProperty(SQLTransformer.MAGIC_PASSWORD);
  +            String connection = properties.getProperty( SQLTransformer.MAGIC_CONNECTION );
  +            String dburl = properties.getProperty( SQLTransformer.MAGIC_DBURL );
  +            String username = properties.getProperty( SQLTransformer.MAGIC_USERNAME );
  +            String password = properties.getProperty( SQLTransformer.MAGIC_PASSWORD );
   
               DataSourceComponent datasource = null;
               try {
  -                if (connection != null) {
  -                    datasource = (DataSourceComponent) dbSelector.select(connection);
  -                    while (result == null) {
  +                if ( connection != null ) {
  +                    datasource = (DataSourceComponent) dbSelector.select( connection );
  +                    while ( result == null ) {
                           try {
                               result = datasource.getConnection();
  -                        } catch (Exception e) {
  -                            long waittime = 5000 * (long)Math.random();
  -                            getTheLogger().debug("SQLTransformer$Query: could not acquire a Connection -- waiting "+waittime+" ms to try again.");
  +                        } catch ( Exception e ) {
  +                            long waittime = 5000 * (long) Math.random();
  +                            getTheLogger().debug( "SQLTransformer$Query: could not acquire a Connection -- waiting " + waittime + " ms to try again." );
                               try {
  -                                Thread.sleep(waittime);
  -                            } catch (InterruptedException ie) {}
  +                                Thread.sleep( waittime );
  +                            } catch ( InterruptedException ie ) {
  +                            }
                           }
                       }
                   } else {
  -                    if (username == null || password == null) {
  -                        result = DriverManager.getConnection(dburl);
  +                    if ( username == null || password == null ) {
  +                        result = DriverManager.getConnection( dburl );
                       } else {
  -                        result = DriverManager.getConnection(dburl, username,
  -                                                           password);
  +                        result = DriverManager.getConnection( dburl, username,
  +                                                              password );
                       }
                   }
  -            } catch (ComponentException cme) {
  -                transformer.getTheLogger().error("Could not use connection: " + connection, cme);
  -            } catch (SQLException e) {
  -                transformer.getTheLogger().error("Caught a SQLException", e);
  +            } catch ( ComponentException cme ) {
  +                transformer.getTheLogger().error( "Could not use connection: " + connection, cme );
  +            } catch ( SQLException e ) {
  +                transformer.getTheLogger().error( "Caught a SQLException", e );
                   throw e;
               } finally {
  -                if (datasource != null) dbSelector.release(datasource);
  +                if ( datasource != null ) dbSelector.release( datasource );
               }
   
               return result;
           }
   
           protected void execute() throws SQLException {
  -            if (null != properties.getProperty(SQLTransformer.MAGIC_DOC_ELEMENT)) {
  -                this.rowset_name = properties.getProperty(SQLTransformer.MAGIC_DOC_ELEMENT);
  +            if ( null != properties.getProperty( SQLTransformer.MAGIC_DOC_ELEMENT ) ) {
  +                this.rowset_name = properties.getProperty( SQLTransformer.MAGIC_DOC_ELEMENT );
               }
  -            if (null != properties.getProperty(SQLTransformer.MAGIC_ROW_ELEMENT)) {
  -                this.row_name = properties.getProperty(SQLTransformer.MAGIC_ROW_ELEMENT);
  +            if ( null != properties.getProperty( SQLTransformer.MAGIC_ROW_ELEMENT ) ) {
  +                this.row_name = properties.getProperty( SQLTransformer.MAGIC_ROW_ELEMENT );
               }
   
               Enumeration enum = query_parts.elements();
               StringBuffer sb = new StringBuffer();
  -            while (enum.hasMoreElements()) {
  +            while ( enum.hasMoreElements() ) {
                   Object object = enum.nextElement();
  -                if (object instanceof String) {
  -                    sb.append((String) object);
  -                } else if (object instanceof AncestorValue) {
  +                if ( object instanceof String ) {
  +                    sb.append( (String) object );
  +                } else if ( object instanceof AncestorValue ) {
                       /** Do a lookup into the ancestors' result's values **/
                       AncestorValue av = (AncestorValue) object;
  -                    Query query = transformer.getQuery(query_index - av.level);
  -                    sb.append(query.getColumnValue(av.name));
  +                    Query query = transformer.getQuery( query_index - av.level );
  +                    sb.append( query.getColumnValue( av.name ) );
                   }
               }
               String query = sb.toString();
  -            transformer.getTheLogger().debug("EXECUTING " + query);
  +            transformer.getTheLogger().debug( "EXECUTING " + query );
   
               conn = getConnection();
   
               try {
  -                if (!isstoredprocedure)  {
  -                    if (oldDriver) {
  -                        pst = conn.prepareStatement(query);
  +                if ( !isstoredprocedure ) {
  +                    if ( oldDriver ) {
  +                        pst = conn.prepareStatement( query );
                       } else {
  -                        pst = conn.prepareStatement(query,
  -                                                    ResultSet.TYPE_SCROLL_INSENSITIVE,
  -                                                    ResultSet.CONCUR_READ_ONLY );
  +                        pst = conn.prepareStatement( query,
  +                                                     ResultSet.TYPE_SCROLL_INSENSITIVE,
  +                                                     ResultSet.CONCUR_READ_ONLY );
                       }
  -                } else  {
  -                    if (oldDriver) {
  -                        cst = conn.prepareCall(query);
  +                } else {
  +                    if ( oldDriver ) {
  +                        cst = conn.prepareCall( query );
                       } else {
  -                        cst = conn.prepareCall(query,
  -                                               ResultSet.TYPE_SCROLL_INSENSITIVE,
  -                                               ResultSet.CONCUR_READ_ONLY );
  +                        cst = conn.prepareCall( query,
  +                                                ResultSet.TYPE_SCROLL_INSENSITIVE,
  +                                                ResultSet.CONCUR_READ_ONLY );
                       }
  -                    registerOutParameters(cst);
  +                    registerOutParameters( cst );
                       pst = cst;
                   }
   
  -                registerInParameters(pst);
  +                registerInParameters( pst );
                   boolean result = pst.execute();
  -                if (result)  {
  +                if ( result ) {
                       rs = pst.getResultSet();
                       md = rs.getMetaData();
                   } else {
                       rv = pst.getUpdateCount();
                   }
  -            } catch (SQLException e) {
  -                transformer.getTheLogger().error("Caught a SQLException", e);
  +            } catch ( SQLException e ) {
  +                transformer.getTheLogger().error( "Caught a SQLException", e );
                   throw e;
               } finally {
                   conn.close();
  @@ -879,143 +880,144 @@
               }
           }
   
  -        protected int getNrOfRows() throws SQLException  {
  -          int nr = 0;
  -          if (rs!=null) {
  -              if (oldDriver){
  -                nr=-1;
  -              } else {
  -                  try {
  +        protected int getNrOfRows() throws SQLException {
  +            int nr = 0;
  +            if ( rs != null ) {
  +                if ( oldDriver ) {
  +                    nr = -1;
  +                } else {
  +                    try {
                           rs.last();
                           nr = rs.getRow();
                           rs.beforeFirst();
  -                  } catch (NullPointerException e) {        // A NullPointerException here crashes a whole lot of C2 -- catching it so it won't do any harm for now, but seems like it should be solved seriously
  -                      getTheLogger().error("NPE while getting the nr of rows", e);
  -                  }
  -              }
  -          } else  {
  -            if (outParameters!=null)  {
  -              nr=outParameters.size();
  +                    } catch ( NullPointerException e ) {
  +                        // A NullPointerException here crashes a whole lot of C2 -- catching it so it won't do any harm for now, but seems like it should be solved seriously
  +                        getTheLogger().error( "NPE while getting the nr of rows", e );
  +                    }
  +                }
  +            } else {
  +                if ( outParameters != null ) {
  +                    nr = outParameters.size();
  +                }
               }
  -          }
  -          return nr;
  +            return nr;
           }
   
  -        protected String getColumnValue(int i) throws SQLException {
  -            return transformer.getStringValue(rs.getObject(i));
  +        protected String getColumnValue( int i ) throws SQLException {
  +            return transformer.getStringValue( rs.getObject( i ) );
           }
   
  -        protected String getColumnValue(String name) throws SQLException {
  -            return transformer.getStringValue(rs.getObject(name));
  +        protected String getColumnValue( String name ) throws SQLException {
  +            return transformer.getStringValue( rs.getObject( name ) );
           }
   
           protected boolean next() throws SQLException {
  -          // if rv is not -1, then an SQL insert, update, etc, has
  -          // happened (see JDBC docs - return codes for executeUpdate)
  -          if (rv != -1)
  -            return true;
  -          try {
  -              if (rs == null || !rs.next()) {
  -                //close();
  +            // if rv is not -1, then an SQL insert, update, etc, has
  +            // happened (see JDBC docs - return codes for executeUpdate)
  +            if ( rv != -1 )
  +                return true;
  +            try {
  +                if ( rs == null || !rs.next() ) {
  +                    //close();
  +                    return false;
  +                }
  +            } catch ( NullPointerException e ) {
  +                getTheLogger().debug( "NullPointerException, returning false.", e );
                   return false;
  -              }
  -          } catch (NullPointerException e) {
  -              getTheLogger().debug("NullPointerException, returning false.", e);
  -              return false;
  -          }
  -          return true;
  +            }
  +            return true;
           }
   
           protected void close() throws SQLException {
               try {
  -                if (rs != null)
  +                if ( rs != null )
                       try {
                           //getTheLogger().debug("Trying to close resultset "+rs.toString());
                           rs.close();
                           rs = null;      // This prevents us from using the resultset again.
                           //250getTheLogger().debug("Really closed the resultset now.");
  -                    } catch (NullPointerException e) {
  -                        getTheLogger().debug("NullPointer while closing the resultset.", e);
  +                    } catch ( NullPointerException e ) {
  +                        getTheLogger().debug( "NullPointer while closing the resultset.", e );
                       }
  -                if (pst != null)
  +                if ( pst != null )
                       pst.close();
                   pst = null;        // Prevent using pst again.
  -                if (cst != null)
  +                if ( cst != null )
                       cst.close();
                   cst = null;        // Prevent using cst again.
               } finally {
  -                if (conn != null)
  -                  conn.close();
  +                if ( conn != null )
  +                    conn.close();
                   conn = null;
               }
           }
   
  -        protected void addQueryPart(Object object) {
  -            query_parts.addElement(object);
  +        protected void addQueryPart( Object object ) {
  +            query_parts.addElement( object );
           }
   
           protected void serializeRow() throws SQLException, SAXException {
  -          AttributesImpl attr = new AttributesImpl();
  -          if (!isupdate && !isstoredprocedure) {
  -            for (int i = 1; i <= md.getColumnCount(); i++) {
  -                transformer.start(md.getColumnName(i).toLowerCase(), attr);
  -                transformer.data(getColumnValue(i));
  -                transformer.end(md.getColumnName(i).toLowerCase());
  -            }
  -          } else if (isupdate && !isstoredprocedure){
  -              transformer.start("returncode", attr);
  -              transformer.data(String.valueOf(rv));
  -              transformer.end("returncode");
  -              rv = -1; // we only want the return code shown once.
  -          }
  +            AttributesImpl attr = new AttributesImpl();
  +            if ( !isupdate && !isstoredprocedure ) {
  +                for ( int i = 1; i <= md.getColumnCount(); i++ ) {
  +                    transformer.start( md.getColumnName( i ).toLowerCase(), attr );
  +                    transformer.data( getColumnValue( i ) );
  +                    transformer.end( md.getColumnName( i ).toLowerCase() );
  +                }
  +            } else if ( isupdate && !isstoredprocedure ) {
  +                transformer.start( "returncode", attr );
  +                transformer.data( String.valueOf( rv ) );
  +                transformer.end( "returncode" );
  +                rv = -1; // we only want the return code shown once.
  +            }
           }
   
           protected void serializeStoredProcedure() throws SQLException, SAXException {
  -          if (outParametersNames==null || cst==null)
  -            return;
  -          //make sure output follows order as parameter order in stored procedure
  -          Iterator itOutKeys = (new TreeMap(outParameters)).keySet().iterator();
  -          Integer counter;
  -          AttributesImpl attr = new AttributesImpl();
  -          try {
  -              while (itOutKeys.hasNext()) {
  -                  counter = (Integer)itOutKeys.next();
  -                  try  {
  -                    if (cst == null) getTheLogger().debug("SQLTransformer: cst is null");
  -                    if (counter == null) getTheLogger().debug(" SQLTransformer: counter is null");
  -                    Object obj = cst.getObject(counter.intValue());
  -                    if (!(obj instanceof ResultSet))  {
  -                      transformer.start((String)outParametersNames.get(counter), attr);
  -                      transformer.data(transformer.getStringValue(obj));
  -                      transformer.end((String)outParametersNames.get(counter));
  -                    } else  {
  -                        ResultSet rs = (ResultSet)obj;
  -                        try{
  -                            transformer.start((String)outParametersNames.get(counter), attr);
  -                            ResultSetMetaData md = rs.getMetaData();
  -                            while (rs.next())  {
  -                              transformer.start(this.row_name, attr);
  -                              for (int i = 1; i <= md.getColumnCount(); i++) {
  -                                  transformer.start(md.getColumnName(i).toLowerCase(), attr);
  -                                  transformer.data(transformer.getStringValue(rs.getObject(i)));
  -                                  transformer.end(md.getColumnName(i).toLowerCase());
  -                              }
  -                              transformer.end(this.row_name);
  +            if ( outParametersNames == null || cst == null )
  +                return;
  +            //make sure output follows order as parameter order in stored procedure
  +            Iterator itOutKeys = ( new TreeMap( outParameters ) ).keySet().iterator();
  +            Integer counter;
  +            AttributesImpl attr = new AttributesImpl();
  +            try {
  +                while ( itOutKeys.hasNext() ) {
  +                    counter = (Integer) itOutKeys.next();
  +                    try {
  +                        if ( cst == null ) getTheLogger().debug( "SQLTransformer: cst is null" );
  +                        if ( counter == null ) getTheLogger().debug( " SQLTransformer: counter is null" );
  +                        Object obj = cst.getObject( counter.intValue() );
  +                        if ( !( obj instanceof ResultSet ) ) {
  +                            transformer.start( (String) outParametersNames.get( counter ), attr );
  +                            transformer.data( transformer.getStringValue( obj ) );
  +                            transformer.end( (String) outParametersNames.get( counter ) );
  +                        } else {
  +                            ResultSet rs = (ResultSet) obj;
  +                            try {
  +                                transformer.start( (String) outParametersNames.get( counter ), attr );
  +                                ResultSetMetaData md = rs.getMetaData();
  +                                while ( rs.next() ) {
  +                                    transformer.start( this.row_name, attr );
  +                                    for ( int i = 1; i <= md.getColumnCount(); i++ ) {
  +                                        transformer.start( md.getColumnName( i ).toLowerCase(), attr );
  +                                        transformer.data( transformer.getStringValue( rs.getObject( i ) ) );
  +                                        transformer.end( md.getColumnName( i ).toLowerCase() );
  +                                    }
  +                                    transformer.end( this.row_name );
  +                                }
  +                            } finally {
  +                                rs.close();
  +                                rs = null;
                               }
  -                        }finally{
  -                            rs.close();
  -                            rs = null;
  +                            transformer.end( (String) outParametersNames.get( counter ) );
                           }
  -                        transformer.end((String)outParametersNames.get(counter));
  +                    } catch ( SQLException e ) {
  +                        transformer.getTheLogger().error( "Caught a SQLException", e );
  +                        throw e;
                       }
  -                  }catch (SQLException e)  {
  -                    transformer.getTheLogger().error("Caught a SQLException", e);
  -                    throw e;
  -                  }
  -              }
  -          } finally  {
  +                }
  +            } finally {
                   //close();
  -          }
  +            }
           }
       }
   
  @@ -1023,7 +1025,7 @@
           protected int level;
           protected String name;
   
  -        protected AncestorValue(int level, String name) {
  +        protected AncestorValue( int level, String name ) {
               this.level = level;
               this.name = name;
           }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message