avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From froehl...@apache.org
Subject cvs commit: jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/actions BasicSelect.java
Date Tue, 13 Nov 2001 17:25:57 GMT
froehlich    01/11/13 09:25:57

  Modified:    apps/db/src/java/org/apache/avalon/db/basic/actions
                        BasicSelect.java
  Log:
  removed "system.out" and did some fixes. select col1,col2 from table works now
  
  Revision  Changes    Path
  1.20      +19 -8     jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/actions/BasicSelect.java
  
  Index: BasicSelect.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/actions/BasicSelect.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- BasicSelect.java	2001/11/13 16:05:06	1.19
  +++ BasicSelect.java	2001/11/13 17:25:56	1.20
  @@ -84,14 +84,18 @@
                   BasicRow row = (BasicRow)it.next();
                   if (testRow(row)) {
                       if(((String)mCols[0]).equals("*")) {
  +                        getLogger().debug("wildcard select");
                           selectedRow = new Object[row.getColumsLength()];
                           for (int j=0; j < row.getColumsLength(); j++) {
                              selectedRow[j] = row.getValue(j);
                           }
                       } else {
  +                        getLogger().debug("specific select=" + mCols);
                           selectedRow = new Object[mCols.length];
                           for (int j=0; j < mCols.length; j++) {
  -                           selectedRow[j] = row.getValue(mCols[j]);
  +                            getLogger().debug("mCols[" + j + "]=" + mCols[j]);
  +                            getLogger().debug("row.getValue(mCols[" + j + "]=" + row.getValue(mCols[j]));
  +                            selectedRow[j] = row.getValue(mCols[j]);
                           }
                       }
                       selectedRows.add(selectedRow);
  @@ -181,7 +185,6 @@
   
       }
   
  -
       private String[] parseSelect(Element rootElement) throws ActionException {
           NodeList subRootNodes = this.getSubRootNodes(rootElement);
           String[] cols = null;
  @@ -189,15 +192,23 @@
           for (int i=0; i < subRootNodes.getLength(); i++) {
               if(subRootNodes.item(i).getNodeName().equals("columns")) {
                   Element columnsElement = (Element)subRootNodes.item(i);
  -                if(columnsElement.getFirstChild().getNodeValue().equals("*")) {
  -                   cols = new String[1];
  -                   cols[0] = "*";
  -                } else if(subRootNodes.item(i).hasChildNodes()) {
  +                getLogger().debug("columnsElement.getFirstChild()=" + columnsElement.getFirstChild().getNodeName());
  +                //First test if *
  +                if(columnsElement.getFirstChild().getNodeName().equals("#text")) {
  +                   if(columnsElement.getFirstChild().getNodeValue().equals("*")) {
  +                       cols = new String[1];
  +                       cols[0] = "*";
  +                   } else {
  +                       throw new ActionException(columnsElement.getFirstChild().getNodeValue()
  +                                              + " is not valid SQL Syntax");
  +                   }
  +                } else if (subRootNodes.item(i).hasChildNodes()) {
                       NodeList subColumnsNodes = subRootNodes.item(i).getChildNodes();
                       cols = new String[subColumnsNodes.getLength()];
                       for (int j=0; j < subColumnsNodes.getLength(); j++) {
  -                      Element columnElement = (Element)subColumnsNodes.item(j);
  -                      cols[j] = columnElement.getAttribute("name");
  +                        //TODO checking columns, function...maybe extern syntax checking!?
  +                        Element columnElement = (Element)subColumnsNodes.item(j);
  +                        cols[j] = columnElement.getAttribute("name");
                       }
                   } else {
                       throw new ActionException(columnsElement.getFirstChild().getNodeValue()
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-dev-help@jakarta.apache.org>


Mime
View raw message