avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hamm...@apache.org
Subject cvs commit: jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/actions BasicSelect.java
Date Mon, 12 Nov 2001 21:01:18 GMT
hammant     01/11/12 13:01:18

  Modified:    apps/db/src/java/org/apache/avalon/db/basic/actions
                        BasicSelect.java
  Log:
  bracing changes plus indent
  
  Revision  Changes    Path
  1.12      +32 -18    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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- BasicSelect.java	2001/11/12 20:03:21	1.11
  +++ BasicSelect.java	2001/11/12 21:01:18	1.12
  @@ -174,6 +174,7 @@
       }
   
       private StringBuffer parseWhereRoot(Element rootElement) {
  +        int indent = 0;
           System.out.println("Enter parseWhereRoot()");
           StringBuffer sb = new StringBuffer();
           Element whereElement = null;
  @@ -185,26 +186,26 @@
                   whereElement = (Element)subRootNodes.item(i);
               }
           }
  -        this.parseWhereTerm((Element)whereElement.getFirstChild(),sb);
  +        this.parseWhereTerm((Element)whereElement.getFirstChild(),sb, indent+1);
           System.out.println("parseWhereRoot(): END");
  -        System.out.println("sb=[" + sb + "]");
  +        System.out.println("sb=[\n" + sb + "\n]");
           return sb;
       }
   
  -    private void parseWhereTerm(Element element, StringBuffer sb) {
  +    private void parseWhereTerm(Element element, StringBuffer sb, int indent) {
           System.out.println("Enter parseWhereTerm()");
  -        sb.append("{\n");
  +        sb.append(getIndent(indent) + "(\n");
           if(element != null) {
               System.out.println("Element != null " + element);
               if(element.getTagName().equals("and")) {
                   System.out.println("parseWhereTerm(): found and");
  -                parseWhereAndTerm(element.getChildNodes(),sb);
  +                parseWhereAndTerm(element.getChildNodes(),sb, indent +1);
               } else if(element.getTagName().equals("or")) {
                   System.out.println("parseWhereTerm(): found or");
  -                parseWhereOrTerm(element.getChildNodes(),sb);
  +                parseWhereOrTerm(element.getChildNodes(),sb, indent +1);
               } else if(element.getTagName().equals("condition")) {
                   System.out.println("parseWhereTerm(): found condition");
  -                parseWhereConditionTerm(element,sb);
  +                parseWhereConditionTerm(element,sb,indent+1);
               } else {
                   return;
               }
  @@ -216,44 +217,57 @@
           //System.exit(0);
           //System.out.println("sb=" + sb.toString());
           System.out.println("parseWhereTerm at the end");
  -        sb.append("}\n");
  +        sb.append(getIndent(indent) + ")\n");
           return;
       }
   
  -    private void parseWhereAndTerm(NodeList nodes, StringBuffer sb) {
  +    private void parseWhereAndTerm(NodeList nodes, StringBuffer sb, int indent) {
           try {
               for(int i=0; i<nodes.getLength(); i++) {
                   System.out.println("Looping and");
  -                parseWhereTerm((Element)nodes.item(i),sb);
  -                sb.append("&\n");
  +                parseWhereTerm((Element)nodes.item(i),sb, indent +1);
  +                if (i+1 < nodes.getLength()) {
  +                  sb.append( getIndent(indent) + "&\n");
  +                }
               }
           } catch(Exception e) {
               e.printStackTrace();
           }
       }
   
  -    private void parseWhereOrTerm(NodeList nodes, StringBuffer sb) {
  +    private void parseWhereOrTerm(NodeList nodes, StringBuffer sb, int indent) {
           try {
               for(int i=0; i<nodes.getLength(); i++) {
                   System.out.println("Looping or");
  -                parseWhereTerm((Element)nodes.item(i),sb);
  -                sb.append("|\n");
  +                parseWhereTerm((Element)nodes.item(i),sb, indent +1);
  +                if (i+1 < nodes.getLength()) {
  +                  sb.append(getIndent(indent) + "|\n");
  +                }
               }
           } catch(Exception e) {
               e.printStackTrace();
           }
       }
   
  -    private void parseWhereConditionTerm(Element element, StringBuffer sb) {
  +    private void parseWhereConditionTerm(Element element, StringBuffer sb, int indent)
{
           try {
               System.out.println("parseWhereConditionTerm(): found condition");
  -            Node nextSibling = (Node)element.getNextSibling();
  -            sb.append(element.getAttribute("expr") + "\n");
  -            parseWhereTerm((Element)nextSibling,sb);
  +            //Node nextSibling = (Node)element.getNextSibling();
  +            sb.append(getIndent(indent) + element.getAttribute("expr") + "\n");
  +            //parseWhereTerm((Element)nextSibling,sb);
           } catch(Exception e) {
               e.printStackTrace();
           }
       }
  +
  +    private String getIndent(int indent) {
  +        String rval = "";
  +        for (int f = 0; f < indent; f++) {
  +            rval = rval + "  ";
  +        }
  +        return rval;
  +    }
  +
   
       private NodeList getSubRootNodes(Element rootElement) {
           return rootElement.getChildNodes();
  
  
  

--
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